Add min_prelude/convert.carbon to tests missing ImplicitAs (#5677)

import_use_generic.carbon has the comment "// We're just checking that
this doesn't crash. It's not expected to compile." Because it involves
import behavior by name, I'm not touching it. Other than that, while
maybe it's better to test with less, the `ImplicitAs` errors at best
feel difficult to understand, and at worst could be masking an issue.
This commit is contained in:
Jon Ross-Perkins
2025-06-16 23:50:45 +00:00
committed by GitHub
parent c9e4761f0c
commit 1c09de9b87
8 changed files with 165 additions and 48 deletions
+8 -5
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// EXTRA-ARGS: --no-prelude-import
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
@@ -262,10 +262,13 @@ import Cpp library "inheritance_pointers.h";
//@dump-sem-ir-begin
fn MyF1(bar : Cpp.Bar1*);
// TODO: Support C++ inheritance.
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+7]]:33: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+10]]:33: error: cannot implicitly convert expression of type `Cpp.Bar2*` to `Cpp.Bar1*` [ConversionFailure]
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE-5]]:9: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+7]]:33: note: type `Cpp.Bar2*` does not implement interface `Core.ImplicitAs(Cpp.Bar1*)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE-8]]:9: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn MyF1(bar : Cpp.Bar1*);
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -731,7 +734,7 @@ fn MyF(bar: Cpp.Bar*);
// CHECK:STDOUT: %bar.param_patt: %pattern_type.92a = value_param_pattern %bar.patt, call_param0 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bar.param: %ptr.eca = value_param call_param0
// CHECK:STDOUT: %.loc16_23: type = splice_block %ptr [concrete = constants.%ptr.eca] {
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr [concrete = constants.%ptr.eca] {
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Bar2.ref: type = name_ref Bar2, imports.%Bar2.decl [concrete = constants.%Bar2]
@@ -747,7 +750,7 @@ fn MyF(bar: Cpp.Bar*);
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %MyF1.ref: %MyF1.type = name_ref MyF1, file.%MyF1.decl [concrete = constants.%MyF1]
// CHECK:STDOUT: %bar.ref: %ptr.eca = name_ref bar, %bar
// CHECK:STDOUT: %.loc16_33: %ptr.f68 = converted %bar.ref, <error> [concrete = <error>]
// CHECK:STDOUT: %.loc19_33: %ptr.f68 = converted %bar.ref, <error> [concrete = <error>]
// CHECK:STDOUT: %MyF1.call: init %empty_tuple.type = call %MyF1.ref(<error>)
// CHECK:STDOUT: return
// CHECK:STDOUT: }
+8 -5
View File
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// EXTRA-ARGS: --no-prelude-import
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
@@ -256,10 +256,13 @@ import Cpp library "inheritance_pointers.h";
//@dump-sem-ir-begin
fn MyF1(bar : Cpp.Bar1*);
// TODO: Support C++ inheritance.
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+7]]:33: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+10]]:33: error: cannot implicitly convert expression of type `Cpp.Bar2*` to `Cpp.Bar1*` [ConversionFailure]
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE-5]]:9: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE+7]]:33: note: type `Cpp.Bar2*` does not implement interface `Core.ImplicitAs(Cpp.Bar1*)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: fn MyF2(bar : Cpp.Bar2*) { MyF1(bar); }
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_todo_import_inheritance_pointers.carbon:[[@LINE-8]]:9: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn MyF1(bar : Cpp.Bar1*);
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -721,7 +724,7 @@ fn MyF(bar: Cpp.Bar*);
// CHECK:STDOUT: %bar.param_patt: %pattern_type.92a = value_param_pattern %bar.patt, call_param0 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %bar.param: %ptr.eca = value_param call_param0
// CHECK:STDOUT: %.loc16_23: type = splice_block %ptr [concrete = constants.%ptr.eca] {
// CHECK:STDOUT: %.loc19_23: type = splice_block %ptr [concrete = constants.%ptr.eca] {
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Bar2.ref: type = name_ref Bar2, imports.%Bar2.decl [concrete = constants.%Bar2]
@@ -737,7 +740,7 @@ fn MyF(bar: Cpp.Bar*);
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %MyF1.ref: %MyF1.type = name_ref MyF1, file.%MyF1.decl [concrete = constants.%MyF1]
// CHECK:STDOUT: %bar.ref: %ptr.eca = name_ref bar, %bar
// CHECK:STDOUT: %.loc16_33: %ptr.f68 = converted %bar.ref, <error> [concrete = <error>]
// CHECK:STDOUT: %.loc19_33: %ptr.f68 = converted %bar.ref, <error> [concrete = <error>]
// CHECK:STDOUT: %MyF1.call: init %empty_tuple.type = call %MyF1.ref(<error>)
// CHECK:STDOUT: return
// CHECK:STDOUT: }