Repository navigation
Deduplicate Marks between Syn/Ana - #2849
Open
Negabinary wants to merge 17 commits into
Open
Negabinary wants to merge 17 commits into
Negabinary wants to merge 17 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #2849 +/- ##
==========================================
+ Coverage 48.43% 48.51% +0.08%
==========================================
Files 498 499 +1
Lines 57542 57723 +181
==========================================
+ Hits 27871 28005 +134
- Misses 29671 29718 +47
🚀 New features to boost your workflow:
|
Negabinary
marked this pull request as draft
November 20, 2026 19:33
fresh_ascription built the casts elaboration inserts with a fresh id on every statics run, so a cons whose tail is not a list (`?:: ?`, `1:: 2`) elaborated with an id the incremental cache can never hit. The cast's id now derives from the expression it wraps, through IdTagged.derived. Taken from the full-pbt stack (its "Give an elaboration-inserted cast an id derived from what it wraps" and the IdTagged.derived helper from "Keep elaboration ids stable through label inference"), without the property infrastructure those commits extend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each Info gets syn_ty: the type of the term as the user wrote it, with any errors in it. Rules that pass a child through (parens, let and sequence bodies, filters, aliases) take the child's; rules that build a type from their children (tuples, labels, lists, functions, branches) build it from the children's syn types, with unknown where branches or elements have no meet. A function's parameter contributes the type it binds, whose own errors are marked on the pattern. Everything else takes the type its rule builds. A tuple's or label's TupleLabelError describes the entry as written, so it takes the syn types. Nothing reads syn_ty yet: this prepares for elab_syn_ty to become the type settled against ana. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
elab_syn_ty is the type a node passes to its parent. It is the type the rule built from its children's elab syn types, unless that fails ana: then the mismatch is marked there and the node passes ana instead, so the failure goes no further up. A function whose body is marked, or a tuple whose element is marked, is no longer marked again (#2507). A synthetic ana (a function position) leaves the rule's type alone. Holes and free variables keep their unknown type. Wherever a type is settled, the elaboration is ascribed with it, so an elaborated term synthesizes its elab_syn_ty with no ana: `let x : String = 4 in x` elaborates its definition as `4 : String`. An annotation already carries the type, so it does not repeat the ascription its body's rule added. Inserted ascriptions are canonical, as the evaluator expects. If and Match cast each branch to the type the branches meet at, so the value has that type whichever branch runs; the cast no longer folds in ana, which the branches have already settled against. An expression's ty is, as before, its elab syn type refined by ana. A capitalised name that resolves to a variable keeps the ascription its settling added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An expression's inspector message compares its syn_ty with ana. Where they are inconsistent but the expression is unmarked (its error is marked further down), the inspector says so in a neutral status rather than falling back to the synthesized type alone, which hid the expectation. The neutral status shares the inspector's status layout. Parentheses and projectors around an expression no longer repeat its marks, so an error is marked once however deeply it is parenthesized. At the parentheses of a tuple, which are part of its syntax, the inspector shows the tuple. A projector hides its syntax, so its widget shows an error anywhere in that syntax, not only on the term it replaces, and the CLI reports an error there at the nearest enclosing term with a position. Pattern parentheses still repeat their content's marks: a pattern's elab_syn_ty is not settled, so they would mark it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each program has one error and it is marked once, with the types the expression actually has. The syn type keeps an error the elab syn type has settled on ana. Every sub-expression's elaboration synthesizes the type recorded for it, and the syntax elaboration inserts has the same ids on every run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tuple that does not fit the expected tuple type is described by its size and labels and, if it has labels, the labels it is missing or should not have, in the CLI and the inspector: both for a type mismatch and for a tuple whose labels are not the expected ones. A recursive tuple type is unrolled to count its elements; labels are quoted as they would be written. Against the empty tuple the type mismatch is clearer, so it is kept. Adapted from #2502 by way of #2733. (#1958) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A value written where a singleton labelled tuple is expected is lifted into one, but its elaboration was the lifted source syntax rather than the lifted tuple's elaboration. So the labels the value's own elaboration infers, a module's lowering, and the ascriptions settling adds were all missing at run time: `f((1, 2))` with `f` taking `(a=(b=Int, c=Int))` got stuck projecting `b`. The lifted tuple's elaboration is now used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its ascriptions' ids derive from what they wrap, so they are not fresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Negabinary
force-pushed
the
settle-elab-syn-ty
branch
from
November 20, 2026 20:25
c502d1c to
f84180f
Compare
Negabinary
marked this pull request as ready for review
November 20, 2026 20:34
7h3kk1d
requested changes
Nov 24, 2026
…flows With settling, an expression's ty differed from its elab syn type only where ana agrees with it and says more (a hole expected to be an Int). Every reader of an expression's ty sits where ana is synthetic, or gets the same results from the elab syn type: the quick tests and the CLI on 85 programs are unchanged. The few readers that want the expected type folded in (a custom builtin's argument, a table projector, the inspector's lifted singleton) compute the meet themselves. Patterns keep ty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
should_emit_nomeet_mark, added in #2213, dropped the NoMeet mark on a list whose elements do not meet whenever List(?) met ana, and it always meets SynSwitch, so [1, "s", 3] had no error. Before that a list's NoMeet in synthesis was an error, as an if's still is. The CLI message names the parts (elements, operands, branches) from the form, as the inspector does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ere settled to An if, match or list whose parts have no common syn type now reports the type they were settled to, not unknown: their disagreement is marked on the part that failed. let r : Int = if true then 1 else "s" shows Int at the if, while a function whose body is wrong still shows its own type against ana. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In (a=1, b=2, c=3) against (a=Int, b=Int), the label c, its entry and the tuple were all marked. Now only the entry is, with the labels expected. Its other entries are matched with the expected ones without it, so each is still checked against its own type (b="s" was not), and the tuple settles on ana without a mark of its own when it fits once the unexpected entries are left out. A tuple also missing a label keeps its shape message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d over a tuple's parentheses ErrorSites says where the editor shows a mark. A mark on syntax a projector folds away is shown, listed and reached by next/previous problem at the projector, as the CLI already did; without a mark of its own on the projector, navigation skipped it. The parentheses directly around a marked tuple are drawn with its mark (#1997) without being marked themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s on ana A node with another mark used to drop its mismatch. Since it settles on ana either way, that mismatch was then reported nowhere: [fun 1 -> 2] : [Int] had no type error. A free constructor's type is a placeholder, so it settles without a mismatch beside FreeConstructor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its self type was the elab syn type, which is settled on the expected type exactly where they disagree, so it read the expected type and reported a match. A known constructor records its own type as its syn type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Segment.ids stops at a nested projector, whose own Info no longer carries the marks of what it folds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shape_mismatch_message lists every non-tuple type form instead of a catch-all, and info_where moves to Test_Statics_Prelude for the tuple shape tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Supersedes #2733. Fixes #2507 and #1958. Followed by #2866 (patterns) and #2867 (ascribed types).
An error is marked once, on the term where it arises.
The types
Each expression has three types:
ana: what its parent expects. Passed down.elab_syn_ty: the type its rule builds from its children'selab_syn_ty, oranawhere that is inconsistent withana. The inconsistency is marked there, and the elaboration is ascribed there, so every elaborated subterm synthesizes itselab_syn_tyon its own. Passed up, and it is what parents and every other reader use.syn_ty: built by the same rules from the children'ssyn_ty, never settled. It is the type of what is written, errors included. Only the inspector and the type projector read it.Because a failure is settled where it is marked, nothing above it fails again. An expression's old
ty,elab_syn_tyrefined byana, now differs fromelab_syn_tyonly whereanaagrees but says more (a hole expected to be anInt), so it is gone. Patterns are in #2866.Examples (dev on top)
The
ifhas the type its branches were settled to. A function whose body is wrong still showsInt -> IntagainstInt -> Bool.On dev,
"s"was not checked, andcwas marked three times. An unexpected label is now marked on its entry, with the expected labels. The other entries are checked against their own types.#2213 had dropped this mark by accident. An
ifin the same position was still marked.Also
[fun 1 -> 2] : [Int]). A free constructor is the exception: its type is a placeholder.syn_tywithana. Above an error it shows a neutral status.ifandmatchcast each branch to the type the branches meet at.f((1, 2))withftaking(a=(b=Int, c=Int))used to get stuck.Not done
let z : (y=Int) = { let y = 1 } in z.yevaluates to(y=1).Testing
make test-quick: 4573 tests. New tests are inStatics.Settling,Statics.TuplesandProblemCollection. The CLI gives the same results onhazel-programs/as dev. The examples above were checked in a browser.🤖 Generated with Claude Code