Skip to content

Conversation

@danakj
Copy link
Contributor

@danakj danakj commented Mar 27, 2025

It is possible to construct a symbolic impl lookup query that, when evaluated against a specific, will have a self type that is:

  • A facet value instruction with a symbolic constant value
  • That constant value is rewritten to a FacetValue pointing through a FacetAccessType to a symbolic facet value.

Impl lookup looks through the FacetValue to the type inside since FacetValue will reduce the number of interfaces available to match the minimum deduced requirements.

Impl lookup also unwraps FacetAccessType in the self type of the query and the impl, so that queries on FacetAccessType and on facet values can both compare against the impl's self type with a simple constant value equality check.

We were unwrapping FacetAccessType on the way into impl lookup, and then assumed that meant it would never be a FacetAccessType in the symbolic impl lookup instruction. However, as we can see, the query self instruction can be symbolic and its value can be rewritten. And in that case it can contain or become a FacetAccessType.

So we need to also unwrap the FacetAccessType when doing a symbolic impl lookup.

Closes #5187

It is possible to construct a symbolic impl lookup query that, when
evaluated against a specific, will have a self type that is:
- A facet value instruction with a symbolic constant value
- That constant value is rewritten to a FacetValue pointing through
  a FacetAccessType to a symbolic facet value.

Impl lookup looks through the FacetValue to the type inside since
FacetValue will reduce the number of interfaces available to match the
minimum deduced requirements.

Impl lookup also unwraps FacetAccessType in the self type of the query
and the impl, so that queries on FacetAccessType and on facet values can
both compare against the impl's self type with a simple constant value
equality check.

We were unwrapping FacetAccessType on the way into impl lookup, and then
assumed that meant it would never be a FacetAccessType in the symbolic
impl lookup instruction. However, as we can see, the query self
instruction can be symbolic and its value can be rewritten. And in that
case it can contain or become a FacetAccessType.

So we need to also unwrap the FacetAccessType when doing a symbolic impl
lookup.
@danakj
Copy link
Contributor Author

danakj commented Mar 27, 2025

I was debating moving the UnwrapFacetAccessType() deeper, in next to the actual self comparison, since it's getting duplicated on the query now. But then we'd still need a second UnwrapFacetAccessType() in the get-witness-from-the-facet-value path, so idk. I welcome preferences.

@geoffromer geoffromer added this pull request to the merge queue Mar 28, 2025
Merged via the queue into carbon-language:trunk with commit 496eddf Mar 28, 2025
8 checks passed
@danakj danakj deleted the crash-sym branch March 28, 2025 17:54
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.

CHECK failure with ImplSymbolicWitness failing to find an impl

2 participants