Skip to content

Commit 0ee5ed5

Browse files
committed
Add a test that shows names are not poisoned when lookup fails
#4622
1 parent bf5c891 commit 0ee5ed5

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon

+67-1
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,29 @@ interface A {
285285
class X {
286286
extend impl as A {
287287
fn F() { return; }
288-
// CHECK:STDERR: fail_using_poisoned_name_in_impl_outside_class.carbon:[[@LINE+3]]:10: error: `impl as` can only be used in a class [ImplAsOutsideClass]
288+
// CHECK:STDERR: fail_using_poisoned_name_in_impl_outside_class.carbon:[[@LINE+4]]:10: error: `impl as` can only be used in a class [ImplAsOutsideClass]
289289
// CHECK:STDERR: impl as B {}
290290
// CHECK:STDERR: ^~
291+
// CHECK:STDERR:
291292
impl as B {}
292293
}
293294
}
294295

296+
// --- fail_no_poison_when_lookup_fails.carbon
297+
298+
library "[[@TEST_NAME]]";
299+
300+
namespace N;
301+
// Here we fail to find C so we don't poison anything.
302+
// CHECK:STDERR: fail_no_poison_when_lookup_fails.carbon:[[@LINE+3]]:11: error: name `C` not found [NameNotFound]
303+
// CHECK:STDERR: fn N.F(x: C);
304+
// CHECK:STDERR: ^
305+
fn N.F(x: C);
306+
307+
// No failures below because nothing was poisoned.
308+
class C {}
309+
class N.C {}
310+
295311
// CHECK:STDOUT: --- no_poison.carbon
296312
// CHECK:STDOUT:
297313
// CHECK:STDOUT: constants {
@@ -1142,3 +1158,53 @@ class X {
11421158
// CHECK:STDOUT:
11431159
// CHECK:STDOUT: specific @B(constants.%Self) {}
11441160
// CHECK:STDOUT:
1161+
// CHECK:STDOUT: --- fail_no_poison_when_lookup_fails.carbon
1162+
// CHECK:STDOUT:
1163+
// CHECK:STDOUT: constants {
1164+
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
1165+
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
1166+
// CHECK:STDOUT: %C.f79: type = class_type @C.1 [template]
1167+
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
1168+
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
1169+
// CHECK:STDOUT: %C.9f4: type = class_type @C.2 [template]
1170+
// CHECK:STDOUT: }
1171+
// CHECK:STDOUT:
1172+
// CHECK:STDOUT: file {
1173+
// CHECK:STDOUT: package: <namespace> = namespace [template] {
1174+
// CHECK:STDOUT: .N = %N
1175+
// CHECK:STDOUT: .C = %C.decl.loc12
1176+
// CHECK:STDOUT: }
1177+
// CHECK:STDOUT: %N: <namespace> = namespace [template] {
1178+
// CHECK:STDOUT: .F = %F.decl
1179+
// CHECK:STDOUT: .C = %C.decl.loc13
1180+
// CHECK:STDOUT: }
1181+
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
1182+
// CHECK:STDOUT: %x.patt: <error> = binding_pattern x
1183+
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0
1184+
// CHECK:STDOUT: } {
1185+
// CHECK:STDOUT: %x.param: <error> = value_param runtime_param0
1186+
// CHECK:STDOUT: %C.ref: <error> = name_ref C, <error> [template = <error>]
1187+
// CHECK:STDOUT: %x: <error> = bind_name x, %x.param
1188+
// CHECK:STDOUT: }
1189+
// CHECK:STDOUT: %C.decl.loc12: type = class_decl @C.1 [template = constants.%C.f79] {} {}
1190+
// CHECK:STDOUT: %C.decl.loc13: type = class_decl @C.2 [template = constants.%C.9f4] {} {}
1191+
// CHECK:STDOUT: }
1192+
// CHECK:STDOUT:
1193+
// CHECK:STDOUT: class @C.1 {
1194+
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
1195+
// CHECK:STDOUT:
1196+
// CHECK:STDOUT: !members:
1197+
// CHECK:STDOUT: .Self = constants.%C.f79
1198+
// CHECK:STDOUT: complete_type_witness = %complete_type
1199+
// CHECK:STDOUT: }
1200+
// CHECK:STDOUT:
1201+
// CHECK:STDOUT: class @C.2 {
1202+
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
1203+
// CHECK:STDOUT:
1204+
// CHECK:STDOUT: !members:
1205+
// CHECK:STDOUT: .Self = constants.%C.9f4
1206+
// CHECK:STDOUT: complete_type_witness = %complete_type
1207+
// CHECK:STDOUT: }
1208+
// CHECK:STDOUT:
1209+
// CHECK:STDOUT: fn @F(%x.param_patt: <error>);
1210+
// CHECK:STDOUT:

0 commit comments

Comments
 (0)