Add a resolution phase to Laurel#501
Merged
keyboardDrummer merged 97 commits intomainfrom Mar 6, 2026
Merged
Conversation
…to remy/pureProcedures
joehendrix
reviewed
Mar 4, 2026
joehendrix
reviewed
Mar 4, 2026
joehendrix
reviewed
Mar 4, 2026
joscoh
reviewed
Mar 4, 2026
Contributor
joscoh
left a comment
There was a problem hiding this comment.
Do you have any tests for these changes (e.g. ensuring resolution works, Laurel programs with datatypes)?
joscoh
approved these changes
Mar 5, 2026
joehendrix
approved these changes
Mar 5, 2026
joehendrix
reviewed
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Instead of redefining how to do name resolution in each phase in the translation from Laurel to Core, define resolution once in a single phase. Currently resolution is done again after each phase. This introduces partially duplicated work but we expect to reduce that in the future using caching.
The Python through Laurel pipeline currently can not resolve each reference because it adds some prelude definitions, that are referenced by the generated code, only at the Core level instead of at the Laurel level. To still enable the Python through Laurel pipeline to work, I had to turn off reporting of resolution errors. I'll resolve that in a follow-up PR.
For Laurel tests, this PR includes changes to ensure that the program resolves without errors after each phase:
typeTag: TypeTagfield of the composite datatype is only added to that datatype during the typeHierarchy phase, since that's the phase whereTypeTagis defined.const,selectandupdateare now added as part ofCoreDefinitionsForLaurel.lean, as Laurel functions with an "External" body, meaning they're ignored during the translation to Core. This way, references to them can be resolved during resolution.HeapParameterization, fields for composite type definitions are deleted, so their names don't conflict with the constructors of the generatedFielddatatypeTesting
Refactoring. No changes to existing tests. I will follow-up with first removing the hacks, and then adding tests containing name conflicts that'll make use of this new resolution phase.