@@ -293,21 +293,49 @@ class X {
293293 }
294294}
295295
296- // --- fail_no_poison_when_lookup_fails .carbon
296+ // --- fail_poison_when_lookup_fails .carbon
297297
298298library "[[@TEST_NAME]]" ;
299299
300300namespace 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]
301+ // CHECK:STDERR: fail_poison_when_lookup_fails.carbon:[[@LINE+5]]:11: error: name `C` not found [NameNotFound]
303302// CHECK:STDERR: fn N.F(x: C);
304303// CHECK:STDERR: ^
304+ // CHECK:STDERR:
305+ // CHECK:STDERR: fail_poison_when_lookup_fails.carbon: error: name used before it was declared [NameUseBeforeDecl]
305306fn N .F (x: C);
306307
307- // No failures below because nothing was poisoned.
308+ // TODO: We should ideally only produce one diagnostic here.
309+ // CHECK:STDERR: fail_poison_when_lookup_fails.carbon:[[@LINE+5]]:1: note: declared here [NameUseBeforeDeclNote]
310+ // CHECK:STDERR: class C {}
311+ // CHECK:STDERR: ^~~~~~~~~
312+ // CHECK:STDERR:
313+ // CHECK:STDERR: fail_poison_when_lookup_fails.carbon: error: name used before it was declared [NameUseBeforeDecl]
308314class C {}
315+ // CHECK:STDERR: fail_poison_when_lookup_fails.carbon:[[@LINE+4]]:1: note: declared here [NameUseBeforeDeclNote]
316+ // CHECK:STDERR: class N.C {}
317+ // CHECK:STDERR: ^~~~~~~~~~~
318+ // CHECK:STDERR:
309319class N.C {}
310320
321+ // --- fail_poison_with_lexical_result.carbon
322+ // CHECK:STDERR: fail_poison_with_lexical_result.carbon: error: name used before it was declared [NameUseBeforeDecl]
323+
324+ library "[[@TEST_NAME]]" ;
325+
326+ fn F () {
327+ class A {}
328+
329+ class B {
330+ var v: A;
331+
332+ // CHECK:STDERR: fail_poison_with_lexical_result.carbon:[[@LINE+3]]:5: note: declared here [NameUseBeforeDeclNote]
333+ // CHECK:STDERR: class A {}
334+ // CHECK:STDERR: ^~~~~~~~~
335+ class A {}
336+ }
337+ }
338+
311339// CHECK:STDOUT: --- no_poison.carbon
312340// CHECK:STDOUT:
313341// CHECK:STDOUT: constants {
@@ -1158,25 +1186,23 @@ class N.C {}
11581186// CHECK:STDOUT:
11591187// CHECK:STDOUT: specific @B(constants.%Self) {}
11601188// CHECK:STDOUT:
1161- // CHECK:STDOUT: --- fail_no_poison_when_lookup_fails .carbon
1189+ // CHECK:STDOUT: --- fail_poison_when_lookup_fails .carbon
11621190// CHECK:STDOUT:
11631191// CHECK:STDOUT: constants {
11641192// CHECK:STDOUT: %F.type: type = fn_type @F [template]
11651193// CHECK:STDOUT: %F: %F.type = struct_value () [template]
1166- // CHECK:STDOUT: %C.f79 : type = class_type @C .1 [template]
1194+ // CHECK:STDOUT: %.a95 : type = class_type @.1 [template]
11671195// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
11681196// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
1169- // CHECK:STDOUT: %C.9f4 : type = class_type @C .2 [template]
1197+ // CHECK:STDOUT: %.fb7 : type = class_type @.2 [template]
11701198// CHECK:STDOUT: }
11711199// CHECK:STDOUT:
11721200// CHECK:STDOUT: file {
11731201// CHECK:STDOUT: package: <namespace> = namespace [template] {
11741202// CHECK:STDOUT: .N = %N
1175- // CHECK:STDOUT: .C = %C.decl.loc12
11761203// CHECK:STDOUT: }
11771204// CHECK:STDOUT: %N: <namespace> = namespace [template] {
11781205// CHECK:STDOUT: .F = %F.decl
1179- // CHECK:STDOUT: .C = %C.decl.loc13
11801206// CHECK:STDOUT: }
11811207// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
11821208// CHECK:STDOUT: %x.patt: <error> = binding_pattern x
@@ -1186,25 +1212,81 @@ class N.C {}
11861212// CHECK:STDOUT: %C.ref: <error> = name_ref C, <error> [template = <error>]
11871213// CHECK:STDOUT: %x: <error> = bind_name x, %x.param
11881214// 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 ] {} {}
1215+ // CHECK:STDOUT: %.decl.loc18 : type = class_decl @.1 [template = constants.%.a95 ] {} {}
1216+ // CHECK:STDOUT: %.decl.loc23 : type = class_decl @.2 [template = constants.%.fb7 ] {} {}
11911217// CHECK:STDOUT: }
11921218// CHECK:STDOUT:
1193- // CHECK:STDOUT: class @C .1 {
1219+ // CHECK:STDOUT: class @.1 {
11941220// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
11951221// CHECK:STDOUT:
11961222// CHECK:STDOUT: !members:
1197- // CHECK:STDOUT: .Self = constants.%C.f79
1223+ // CHECK:STDOUT: .Self = constants.%.a95
11981224// CHECK:STDOUT: complete_type_witness = %complete_type
11991225// CHECK:STDOUT: }
12001226// CHECK:STDOUT:
1201- // CHECK:STDOUT: class @C .2 {
1227+ // CHECK:STDOUT: class @.2 {
12021228// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
12031229// CHECK:STDOUT:
12041230// CHECK:STDOUT: !members:
1205- // CHECK:STDOUT: .Self = constants.%C.9f4
1231+ // CHECK:STDOUT: .Self = constants.%.fb7
12061232// CHECK:STDOUT: complete_type_witness = %complete_type
12071233// CHECK:STDOUT: }
12081234// CHECK:STDOUT:
12091235// CHECK:STDOUT: fn @F(%x.param_patt: <error>);
12101236// CHECK:STDOUT:
1237+ // CHECK:STDOUT: --- fail_poison_with_lexical_result.carbon
1238+ // CHECK:STDOUT:
1239+ // CHECK:STDOUT: constants {
1240+ // CHECK:STDOUT: %F.type: type = fn_type @F [template]
1241+ // CHECK:STDOUT: %F: %F.type = struct_value () [template]
1242+ // CHECK:STDOUT: %A: type = class_type @A [template]
1243+ // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
1244+ // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
1245+ // CHECK:STDOUT: %B: type = class_type @B [template]
1246+ // CHECK:STDOUT: %B.elem: type = unbound_element_type %B, %A [template]
1247+ // CHECK:STDOUT: %.96d: type = class_type @.1 [template]
1248+ // CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %A} [template]
1249+ // CHECK:STDOUT: %complete_type.57e: <witness> = complete_type_witness %struct_type.v [template]
1250+ // CHECK:STDOUT: }
1251+ // CHECK:STDOUT:
1252+ // CHECK:STDOUT: file {
1253+ // CHECK:STDOUT: package: <namespace> = namespace [template] {
1254+ // CHECK:STDOUT: .F = %F.decl
1255+ // CHECK:STDOUT: }
1256+ // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
1257+ // CHECK:STDOUT: }
1258+ // CHECK:STDOUT:
1259+ // CHECK:STDOUT: class @A {
1260+ // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
1261+ // CHECK:STDOUT:
1262+ // CHECK:STDOUT: !members:
1263+ // CHECK:STDOUT: .Self = constants.%A
1264+ // CHECK:STDOUT: complete_type_witness = %complete_type
1265+ // CHECK:STDOUT: }
1266+ // CHECK:STDOUT:
1267+ // CHECK:STDOUT: class @B {
1268+ // CHECK:STDOUT: %.loc9: %B.elem = field_decl v, element0 [template]
1269+ // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.96d] {} {}
1270+ // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.v [template = constants.%complete_type.57e]
1271+ // CHECK:STDOUT:
1272+ // CHECK:STDOUT: !members:
1273+ // CHECK:STDOUT: .Self = constants.%B
1274+ // CHECK:STDOUT: .v = %.loc9
1275+ // CHECK:STDOUT: complete_type_witness = %complete_type
1276+ // CHECK:STDOUT: }
1277+ // CHECK:STDOUT:
1278+ // CHECK:STDOUT: class @.1 {
1279+ // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
1280+ // CHECK:STDOUT:
1281+ // CHECK:STDOUT: !members:
1282+ // CHECK:STDOUT: .Self = constants.%.96d
1283+ // CHECK:STDOUT: complete_type_witness = %complete_type
1284+ // CHECK:STDOUT: }
1285+ // CHECK:STDOUT:
1286+ // CHECK:STDOUT: fn @F() {
1287+ // CHECK:STDOUT: !entry:
1288+ // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
1289+ // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
1290+ // CHECK:STDOUT: return
1291+ // CHECK:STDOUT: }
1292+ // CHECK:STDOUT:
0 commit comments