feat(types): name types via a symbol, render the nominal name#180
Merged
Conversation
A `$Type` carries its declared name as a `$name` symbol (tagged i31)
instead of the dead `(mod_id, cps_id)` pair, which was stored and
threaded through every constructor but never resolved. The renderer
resolves the symbol to a source name in-band via `symbol_to_str`, so a
typed instance reprs and fmts under its nominal name (`Foo {bar: 1}`).
- types.wat: replace `(mod_id, cps_id)` with `$name (ref i31)` across
`$Type`/`$RecType`/`$TupleType`/`$Union`/`$Enum`; seed constructors
take `(ctx, name, cont)`; `type_inherit` keeps the derived type's own
name; add `inst_type_name`.
- repr.wat / str.wat: `$Inst` arms prepend the nominal name (`inst_repr`
/ `inst_fmt`); an anonymous `type _` (null-name symbol) stays bare.
- transform.rs: name a `type`/`union`/`enum` declaration after its bind
LHS ident; enum cases after the case name; inline decls stay anonymous.
- lower.rs: the type-seed boxes the name symbol via the symbol path.
|
📦 This PR will release v0.88.0 (minor) when merged. |
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
A
$Typecarries its declared name as a$namesymbol (tagged i31) instead of the dead(mod_id, cps_id)pair. The pair was stored and threaded through every type constructor but never resolved host-side; its one intended consumer (printing a type name) was a standing TODO. The renderer now resolves the name symbol in-band viasymbol_to_str, so a typed instance reprs and fmts under its nominal name.Behaviour
'${Foo {bar: 1}}'->Foo {bar: 1}(was{bar: 1})'${[Foo {bar: 1}]}'->[Foo {bar: 1}]Some {...})type _(null-name symbol) stays bare-payloadChanges
(mod_id, cps_id)with$name (ref i31)across$Type/$RecType/$TupleType/$Union/$Enum; seed constructors take(ctx, name, cont);type_inheritkeeps the derived type's own name (so a subtype reprs under its own name, not its base's); addinst_type_name.$Instarms prepend the nominal name (inst_repr/inst_fmt).type/union/enumdeclaration after its bind LHS ident; enum case-types after the case name; inline/unbound declarations carry the null name.Functions are intentionally out of scope - naming a function value is a separate, larger increment (a name field on the universal closure type, threaded at every construction site).
Tests
Full suite green (1366 lib + 42 CLI + 1 JS interop, 0 failures). CPS and WAT type snapshots re-blessed for the new name-symbol seed arg. Clippy clean.