Skip to content

Commit 1d0f30d

Browse files
authored
Fix a use of an imported InstId used where a local InstId is required (#5998)
Found by WIP validation for this type of issue ongoing in #5997 I'm not entirely sure how the one test update falls out of this change - but it is from the same test that I originally reduced the problem from, which is reassuring. The reduced test case I investigated the issue with was this: `a.carbon`: ``` library "lib"; interface I1(Other:! type) { let Result:! type; } ``` `b.carbon`: ``` import library "lib"; class T1 { } impl T1 as I1(Self) where .Result = Self { } ``` The SemIR dump diff looked like this: ``` 89c89 < %Main.import_ref.b6f = import_ref Main//lib, inst28 [no loc], unloaded --- > %Main.import_ref.b6f = import_ref Main//lib, inst27 [no loc], unloaded 96c96 < %Main.import_ref.f7b: @i1.%I1.type (%I1.type.e87) = import_ref Main//lib, inst28 [no loc], loaded [symbolic = @i1.%Self (constants.%Self.c47)] --- > %Main.import_ref.f7b: @i1.%I1.type (%I1.type.e87) = import_ref Main//lib, inst27 [no loc], loaded [symbolic = @i1.%Self (constants.%Self.c47)] ``` Which is a difference, but given the `inst28`/`inst27` don't appear anywhere else than these two lines, it doesn't give a terribly meaningful diff/story about what changed - but perhaps it's sufficient... Not sure if this test ^ is sufficiently more interesting than the diff update already in this patch. If so, happy to add the above as a new test case. Open to ideas.
1 parent 9cfbe9e commit 1d0f30d

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

toolchain/check/import_ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ static auto MakeAssociatedConstant(
13511351
.name_id = GetLocalNameId(context, import_assoc_const.name_id),
13521352
.parent_scope_id = SemIR::NameScopeId::None,
13531353
.decl_id = assoc_const_decl_id,
1354-
.generic_id = MakeIncompleteGeneric(context, import_assoc_const.decl_id,
1354+
.generic_id = MakeIncompleteGeneric(context, assoc_const_decl_id,
13551355
import_assoc_const.generic_id),
13561356
.default_value_id =
13571357
import_assoc_const.default_value_id.has_value()

toolchain/check/testdata/for/actual.carbon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ fn Read() {
7070
// CHECK:STDOUT: %IntRange.Make.type.51f: type = fn_type @IntRange.Make, @IntRange(%N.c80) [symbolic]
7171
// CHECK:STDOUT: %IntRange.Make.2ec: %IntRange.Make.type.51f = struct_value () [symbolic]
7272
// CHECK:STDOUT: %Iterate.type: type = facet_type <@Iterate> [concrete]
73-
// CHECK:STDOUT: %Self.a96: %Iterate.type = bind_symbolic_name Self, 0 [symbolic]
7473
// CHECK:STDOUT: %.Self.ef1: %Iterate.type = bind_symbolic_name .Self [symbolic_self]
7574
// CHECK:STDOUT: %Iterate.assoc_type: type = assoc_entity_type @Iterate [concrete]
7675
// CHECK:STDOUT: %assoc1.02e: %Iterate.assoc_type = assoc_entity element1, imports.%Core.import_ref.9e6 [concrete]
@@ -128,7 +127,6 @@ fn Read() {
128127
// CHECK:STDOUT: %assoc0.8dc: %OrderedWith.assoc_type.d92 = assoc_entity element0, imports.%Core.import_ref.13d [symbolic]
129128
// CHECK:STDOUT: %require_complete.0f5: <witness> = require_complete_type %ptr.784 [symbolic]
130129
// CHECK:STDOUT: %Inc.type: type = facet_type <@Inc> [concrete]
131-
// CHECK:STDOUT: %Iterate.facet.7f1: %Iterate.type = facet_value %.Self.as_type.935, (%Iterate.lookup_impl_witness.65a) [symbolic_self]
132130
// CHECK:STDOUT: %assoc0.724: %Iterate.assoc_type = assoc_entity element0, imports.%Core.import_ref.4f9 [concrete]
133131
// CHECK:STDOUT: %Iterate_where.type.fce: type = facet_type <@Iterate where %impl.elem1.164 = %Int.49d0e6.1 and %impl.elem0.19f = %Int.49d0e6.1> [symbolic]
134132
// CHECK:STDOUT: %require_complete.d96: <witness> = require_complete_type %Iterate_where.type.fce [symbolic]
@@ -766,14 +764,6 @@ fn Read() {
766764
// CHECK:STDOUT: %pattern_type.loc5_49 => constants.%pattern_type.dcd
767765
// CHECK:STDOUT: }
768766
// CHECK:STDOUT:
769-
// CHECK:STDOUT: specific @CursorType(constants.%Self.a96) {}
770-
// CHECK:STDOUT:
771-
// CHECK:STDOUT: specific @CursorType(constants.%Iterate.facet.7f1) {}
772-
// CHECK:STDOUT:
773-
// CHECK:STDOUT: specific @ElementType(constants.%Self.a96) {}
774-
// CHECK:STDOUT:
775-
// CHECK:STDOUT: specific @ElementType(constants.%Iterate.facet.7f1) {}
776-
// CHECK:STDOUT:
777767
// CHECK:STDOUT: specific @IntRange.as.Iterate.impl(constants.%N.c80) {
778768
// CHECK:STDOUT: %N => constants.%N.c80
779769
// CHECK:STDOUT: %IntRange => constants.%IntRange.349

0 commit comments

Comments
 (0)