Skip to content

Fix resolution errors during phases#1389

Merged
keyboardDrummer merged 13 commits into
reviewed-kbd-will-merge-to-mainfrom
fixResolutionErrorsDuringPhases
Jun 19, 2026
Merged

Fix resolution errors during phases#1389
keyboardDrummer merged 13 commits into
reviewed-kbd-will-merge-to-mainfrom
fixResolutionErrorsDuringPhases

Conversation

@keyboardDrummer

@keyboardDrummer keyboardDrummer commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Changes

  • Report resolution errors that occur after transformation passes during the compilation of Laurel to Core. This change triggers errors in existing tests that lead to the remainder of the changes in this PR.
  • Remove .THeap and .TTypedField. The usages have been replaced by .UserDefinedType "Heap" and .UserDefinedType "Field", so that all references to the heap type use that form, preventing type equality errors.
  • Only re-resolve after HeapParam, TypeInference and ModifiesClauses passes all complete, since they are part of the same logical pass. In the future, we should refactor so they're actually one pass, but still three components, since TypeHierarchy and ModifiesClauses are features that built on top of Composite types.
  • Replace all reference types with Composite during the TypeInference pass. This also enables a slight simplification of LaurelToCoreTranslator.
  • Correct a source location usage in the lifting pass. Without this change, the reported location for an error would change, and this is detected during re-resolution.
  • In Resolution.lean, synth instead of void-check non-last block elements. This is required because some passes create non-void non-last block elements. In particular the EliminateIncrDecr pass creates them. This change also means that Resolution.lean no longer needs to special-case checking | .StaticCall .. | .InstanceCall .. | .IncrDecr .
  • Because of the previous change, Resolution.lean needs to support synthing for any StmtExpr, which it now does.
  • In the resolver, add special casing for calls to select/update/const. These are polymorphic procedures which we can't type check without special casing yet, since we don't support polymorphism yet.
  • Remove expecting the body of a function to correspond to its result type. This check failed for more complicated functions from T3_ControlFlow after they were lowered by some passes. Note that function will be removed entirely. In the test related to this removed check, I have changed the function into a procedure and the same diagnostic is reported then, although through a different mechanism.
  • Refactor TypeAliasElim so it uses a generic traversal to update types. This generic traversal was added a part of changes to TypeHierarchy

Testing

Added one test, but mostly this PR relies on the existing tests.

@keyboardDrummer
keyboardDrummer changed the base branch from main to reviewed-kbd-will-merge-to-main June 18, 2026 13:52
@keyboardDrummer
keyboardDrummer marked this pull request as ready for review June 18, 2026 14:30
@keyboardDrummer
keyboardDrummer requested a review from a team as a code owner June 18, 2026 14:30
@keyboardDrummer
keyboardDrummer marked this pull request as draft June 18, 2026 14:30
auto-merge was automatically disabled June 18, 2026 14:30

Pull request was converted to draft

keyboardDrummer and others added 2 commits June 18, 2026 15:05
- Statement forms (Var-Declare, Exit, Return-*, While, Assert, Assume)
  are now synth rules (⇒ TVoid) instead of check rules (⇐ A)
- Replace [⋄] Stmt / [⋄] Discard-Call with single [⋄] Synth-Discard rule
- Remove TVoid <:_~ T premise from Return-None-Single
- Procedure body is now synthesized, not checked against procedureBodyType
- Update all index entries accordingly
…ules

- Var-Declare, While, Exit, Return, Assert, Assume: ⇐ A → ⇒ TVoid
- Check.statement (Discard): describe single synth-and-discard rule
- Remove references to Discard-Call carve-out (no longer needed)
- resolveBody: remove stale reference to expected type parameter
- resolveProcedure: body is now synthesized, not checked against procedureBodyType
- Return-None-Single: remove TVoid <:~ T subtype check from doc
- Block: update non-last description to match synth-and-discard semantics
- Overview section: rewrite statement-form explanation
@keyboardDrummer
keyboardDrummer marked this pull request as ready for review June 18, 2026 15:46
@keyboardDrummer
keyboardDrummer requested review from ssomayyajula and removed request for ssomayyajula June 18, 2026 15:46
Comment thread Strata/Languages/Laurel/Resolution.lean

@kadirayk kadirayk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Reporting errors that were silently dropping after transformation steps. Giving each type a single consistent name (and grouping the related steps) is a nice clean up.

@keyboardDrummer
keyboardDrummer added this pull request to the merge queue Jun 19, 2026
Merged via the queue into reviewed-kbd-will-merge-to-main with commit 81f20ab Jun 19, 2026
20 checks passed
@keyboardDrummer
keyboardDrummer deleted the fixResolutionErrorsDuringPhases branch June 19, 2026 12:05
@leo-leesco
leo-leesco restored the fixResolutionErrorsDuringPhases branch June 19, 2026 13:42
@leo-leesco
leo-leesco deleted the fixResolutionErrorsDuringPhases branch June 19, 2026 13:42
Comment thread Strata/Languages/Laurel/Resolution.lean
strata-git-sync Bot pushed a commit that referenced this pull request Jul 14, 2026
### Changes
- Report resolution errors that occur after transformation passes during
the compilation of Laurel to Core. This change triggers errors in
existing tests that lead to the remainder of the changes in this PR.
- Remove `.THeap` and `.TTypedField`. The usages have been replaced by
`.UserDefinedType "Heap"` and `.UserDefinedType "Field"`, so that all
references to the heap type use that form, preventing type equality
errors.
- Only re-resolve after HeapParam, TypeInference and ModifiesClauses
passes all complete, since they are part of the same logical pass. In
the future, we should refactor so they're actually one pass, but still
three components, since TypeHierarchy and ModifiesClauses are features
that built on top of Composite types.
- Replace all reference types with `Composite` during the TypeInference
pass. This also enables a slight simplification of
LaurelToCoreTranslator.
- Correct a source location usage in the lifting pass. Without this
change, the reported location for an error would change, and this is
detected during re-resolution.
- In `Resolution.lean`, synth instead of void-check non-last block
elements. This is required because some passes create non-void non-last
block elements. In particular the `EliminateIncrDecr` pass creates them.
This change also means that `Resolution.lean` no longer needs to
special-case checking `| .StaticCall .. | .InstanceCall .. | .IncrDecr
`.
- Because of the previous change, `Resolution.lean` needs to support
synthing for any StmtExpr, which it now does.
- In the resolver, add special casing for calls to select/update/const.
These are polymorphic procedures which we can't type check without
special casing yet, since we don't support polymorphism yet.
- Remove expecting the body of a function to correspond to its result
type. This check failed for more complicated functions from
`T3_ControlFlow` after they were lowered by some passes. Note that
function will be removed entirely. In the test related to this removed
check, I have changed the function into a procedure and the same
diagnostic is reported then, although through a different mechanism.
- Refactor TypeAliasElim so it uses a generic traversal to update types.
This generic traversal was added a part of changes to TypeHierarchy

### Testing

Added one test, but mostly this PR relies on the existing tests.

---------

Co-authored-by: keyboardDrummer-bot <keyboardDrummer-bot@users.noreply.github.com>
fabiomadge added a commit to fabiomadge/Strata that referenced this pull request Jul 15, 2026
38 comment lines -> ~20 for the cascade-suppression + collision block. Cut: the
three-way enumeration of cascade sources (one example makes the point), the strata-org#1389
'supersedes an earlier workaround' changelog history, the '$body' example, and the
'HeapParam/TypeHierarchy set needsResolves:=false' aside (a DUPLICATE — that rationale
already lives inline at both pass definitions). Kept every load-bearing reason: why
suppress, why fold-loud, the duplicate-can-only-be-a-user/generated-collision proof
that justifies UserError, and the source-location TODO. Comments only; corpus green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants