ISyntaxUtil: give the handwritten List cons struct its true SDataCon sort#1052
Open
nanavati wants to merge 1 commit into
Open
ISyntaxUtil: give the handwritten List cons struct its true SDataCon sort#1052nanavati wants to merge 1 commit into
nanavati wants to merge 1 commit into
Conversation
ISyntaxUtil.itListCons hand-builds the type of the Cons constructor's internal struct (Prelude::List_$Cons with fields _1, _2) for iMkCons/iMkList -- the path IPrims takes to materialize a List result (PrimRealToDigits and friends, reached from realToDigits and from Real formatting in Printf/$format). It rebuilt the tycon from struct shape alone, tagging it (TIstruct SStruct [_1,_2]). The frontend records a positional data constructor's struct as TIstruct (SDataCon parent False) fields (CParser), and that is what the List_$Cons tycon built from the Prelude's own source carries. So evaluated designs mix two distinct ISyntax nodes for the same tycon: the frontend's correct form, and this hand-built one whose metadata is factually wrong (an SStruct claim for what is a data constructor's struct). ITCon equality compares only the Id, so the disagreement is latent today -- but anything that inspects the sort, or ever wants to share type nodes, would see the two forms differ. iMkCons is the only handwritten multi-arg constructor (the other iMk* constructors are single-arg and need no internal struct), so this is the lone site of its class. Thread the true SDataCon identity. Validated: full build, plus bsc.real/evaluator and bsc.lib/Printf localchecks, green with no regolds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vjo7EmAfHvZTWPDJ923FVz
This was referenced Jul 15, 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.
What
ISyntaxUtil.itListCons— the hand-built type of the Cons constructor's internal structused by
iMkCons/iMkList— rebuilt its tycon from struct shape alone, asTIstruct SStruct [_1,_2]. The frontend records a positional data constructor's structas
TIstruct (SDataCon parent False) fields(CParser), and that is what the canonicalPrelude::List_$Conscarries. Build the sameSDataCon Listsort here.Why
iMkConsis the path IPrims takes to materialize a List result (e.g.PrimRealToDigitsvia
realToDigits; Real formatting in Printf hits the same prim). It is the onlyhandwritten multi-arg constructor (the other
iMk*constructors are single-arg and needno internal struct), so this is the lone site of its class. On main nothing compares the
payload — TyCon/ITCon comparisons are by qualified Id — so the disagreement is invisible
today, but the IType interning stack (#1048) enforces one (kind, sort) payload per
qualified name and ICEs on the mismatch. The corrected payload is exactly what
symtab-derived
List_$Constypes already carry.Validation
Found as a one-tycon-invariant ICE compiling
bsc.real/evaluator/Introspect.bsvunderthe interning stack's checker. With the fix, bsc.real/evaluator (30 passes) and
bsc.lib/Printf (5 passes) localchecks are fully green under the checked build, no
regolds; the full stack records fullparallel 20281/0/134.
Stack
Standalone on main. One of four independent fixes (#1051 (ATF canonical ids), #1052 (this),
#1053 (S0015 field position), #1054 (CIclass sort members)) below the reworked #1048.