Skip to content

Conversation

@jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Oct 16, 2025

Right now, the impl lookup can both fail to resolve the specific definition because it's symbolic, and return a "final" constant because it's a final impl. This is adding an instruction to help ensure the specific is resolved.

The constant evaluation is fully recursive, but I'm not adding a TODO since that's a known issue with impl lookup in general.

@jonmeow jonmeow force-pushed the lower-crash branch 2 times, most recently from 992322b to f0f19d5 Compare November 24, 2025 23:36
@jonmeow jonmeow marked this pull request as ready for review November 24, 2025 23:36
@jonmeow jonmeow requested a review from a team as a code owner November 24, 2025 23:36
@jonmeow jonmeow requested review from geoffromer and removed request for a team November 24, 2025 23:36
Copy link
Contributor

@geoffromer geoffromer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I haven't reviewed all the testdata yet)


auto EvalConstantInst(Context& context, SemIR::RequireSpecificDefinition inst)
-> ConstantEvalResult {
ResolveSpecificDefinition(context, SemIR::LocId::None, inst.specific_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns false on failure, right? Should we CHECK it?

// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/bound_values.carbon

// TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks incomplete?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is a case of a deleted file getting accidentally restored by the merge-then-autoupdate workflow?

// CHECK:STDOUT: !definition:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.binding.as_type [symbolic = %Class.elem (constants.%Class.elem.bc9)]
// CHECK:STDOUT: %.loc15_12.2: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%T.binding.as_type) [symbolic = %.loc15_12.2 (constants.%.d8a)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in impl_lookup.cpp says this is used when the impl is final, but I'm having trouble working out what final impl this is referring to. Am I misunderstanding something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another restored _addr test, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants