Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facet types support rewrite (where .A =...) constraints #4613

Merged
merged 40 commits into from
Dec 3, 2024

Conversation

josh11b
Copy link
Contributor

@josh11b josh11b commented Dec 3, 2024

  • Rewrite constraints are stored in a facet type, substituted, imported, and formatted.
  • We now distinguish .Self from other symbolic bindings in two ways:
    • .Self itself now has an invalid compile time binding index (since it doesn't bind to any of the generic parameters). As a result, we no longer need to create a generic region in handle_where.cpp.
    • There is a new phase tracking values that are only symbolic because they transitively depend on .Self. This allows us to give the result of a where expression template phase as long as it doesn't use any symbolic constants other than .Self or other designators.
  • AddConstant has been removed from check/context since it was only used from eval. This meant less plumbing of the phase change.
  • Evaluation of BindSymbolicName now also performs substitution into its type.
  • Include a bit more information in some diagnostics.
  • StringifyTypeExpr outputs rewrites, which required adding support for associated entities as well.
    • Associated entities now have an entity name set when importing.
  • Adds tests for some interesting cases with rewrites and uses of .Self mixed with other symbolic constants.

Still to do:

  • There is no validation that any particular type satisfies rewrite constraints.
  • Access to members of a facet type do not see the rewritten values.
  • Impls don't recognize whether associated constants have rewrites setting their values.
  • No support for resolving facet types.

@josh11b josh11b requested a review from zygoloid December 3, 2024 00:05
@github-actions github-actions bot requested a review from chandlerc December 3, 2024 00:06
@josh11b josh11b removed the request for review from chandlerc December 3, 2024 00:31
toolchain/check/eval.cpp Outdated Show resolved Hide resolved
toolchain/check/handle_where.cpp Show resolved Hide resolved
toolchain/check/testdata/where_expr/equal_rewrite.carbon Outdated Show resolved Hide resolved
toolchain/check/testdata/where_expr/equal_rewrite.carbon Outdated Show resolved Hide resolved
toolchain/sem_ir/constant.h Outdated Show resolved Hide resolved
toolchain/sem_ir/constant.h Outdated Show resolved Hide resolved
toolchain/sem_ir/stringify_type.cpp Show resolved Hide resolved
toolchain/sem_ir/stringify_type.cpp Outdated Show resolved Hide resolved
toolchain/sem_ir/stringify_type.cpp Outdated Show resolved Hide resolved
@josh11b josh11b requested a review from zygoloid December 3, 2024 18:01
@josh11b josh11b added this pull request to the merge queue Dec 3, 2024
Merged via the queue into carbon-language:trunk with commit 33110d0 Dec 3, 2024
8 checks passed
@josh11b josh11b deleted the rewrite branch December 3, 2024 22:57
josh11b added a commit to josh11b/carbon-lang that referenced this pull request Dec 4, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 4, 2024
Issue was not properly handling `ImportRef` instructions in
`AddAssociatedEntities` in `check/import_ref.cpp`. Using `CARBON_CHECK`
instead of `CARBON_FATAL` was hiding the error.

---------

Co-authored-by: Josh L <[email protected]>
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.

3 participants