Skip to content

Thread class sort members through CIclass; keep SClass sorts package-independent#1054

Open
nanavati wants to merge 1 commit into
B-Lang-org:mainfrom
nanavati:ciclass-sort-members
Open

Thread class sort members through CIclass; keep SClass sorts package-independent#1054
nanavati wants to merge 1 commit into
B-Lang-org:mainfrom
nanavati:ciclass-sort-members

Conversation

@nanavati

@nanavati nanavati commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What

GenSign emits classes exported without (..) as CIclass, which carried no member
names, so an importing package's MakeSymTab.getTI rebuilt the class tycon's sort from
the superclass list alone — an empty TIstruct SClass. The defining package meanwhile
carries the full member list. Thread the defining package's sort member list (field
names ++ superclass ids, exactly as getTI computes it for Cclass) through CIclass:
GenSign records it both when exporting a class abstractly and when embedding a
used-but-unexported class (classToIClass, from the symtab's own TypeInfo), and the
importer's getTI/getCls use it verbatim for the TypeInfo sort and the Class
tyConOf. The members stay hidden: nothing new enters the field table, and
TypeAnalysis.analyzeNonNumTCon now skips sort members without a FieldInfo instead of
internal-erroring on them. The .bo header tag is bumped for the CIclass encoding
change.

Why

A tycon's sort payload should not depend on which package is looking at it. Abstract
structs already satisfy this (their signature form keeps the fields, merely invisible);
abstract classes did not. The base compiler papers over the divergence in
SymTab.addTypes (pickBetter's "abstract typeclasses have hidden methods" length
comparison), so the empty form was tolerated but never load-bearing. The IType interning
stack (#1048) enforces one sort payload per qualified name
(one-tycon-per-qualified-name) and ICEs on the divergence (first seen:
Prelude::AppendTuple'' compiling bsc.verilog/splitports/ShallowSplit.bs).

Validation

bsc.verilog/splitports localcheck fully green (317 passes), plus bsc.bluetcl/commands
and bsc.typechecker/dontcare spot checks, under the interning stack's checked build; the
full stack records fullparallel 20281/0/134.

Stack

Standalone on main. Last of four independent fixes (#1051 (ATF canonical ids), #1052 (listcons SDataCon sort), #1053 (S0015 field position), #1054 (this)) below the reworked #1048.

…independent

A class exported without (..) appears in its package's signature as
CIclass, which carried no member names.  An importing package's
MakeSymTab.getTI therefore rebuilt the class tycon's TIstruct SClass
sort from the superclass preds alone -- an impoverished payload,
divergent from the defining compile's (field names ++ superclass
ids).  Abstract structs never had this problem: their signature form
keeps the fields, merely invisible.  For abstract classes,
SymTab.addTypes has papered over the divergence forever via
pickBetter's "abstract typeclasses have hidden methods" length
comparison, so the impoverished form was tolerated -- but the sort
payload of the same qualified tycon differed between the defining
compile and its importers, depending on which package's view you
happened to hold.

Thread the defining package's sort member list (field names ++
superclass ids, exactly as getTI computes it for Cclass) through
CIclass: GenSign records it both when exporting a class abstractly
(genDefSign) and when embedding a used-but-unexported class
(classToIClass, from the symtab's own TypeInfo), and the importer's
getTI/getCls use it verbatim for the TypeInfo sort and the Class
tyConOf.  The fields themselves stay hidden: nothing new enters the
field table, and TypeAnalysis's typeclass analysis now skips sort
members without a FieldInfo instead of internal-erroring on them.

CIclass gains a field, so the .bo signature encoding changes: bump
the .bo header tag to bsc-bo-20260715-3 (and the .ba tag in lockstep
to bsc-ba-20260715-3).

Validated: full install-src build, plus green localchecks in
bsc.typechecker/dontcare, bsc.typechecker/typeclasses, and
bsc.bluetcl/commands.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vjo7EmAfHvZTWPDJ923FVz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant