Skip to content

selfhost: add canonical metadata for reference-span sugar - #772

Closed
godofecht wants to merge 4 commits into
selfhost/span-type-namefrom
selfhost/reference-span-meta
Closed

godofecht wants to merge 4 commits into
selfhost/span-type-namefrom
selfhost/reference-span-meta

Conversation

@godofecht

@godofecht godofecht commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

First isolated #720 slice, stacked on #770.

&[T] / &mut [T] currently cannot be canonicalized because Stage-A discards & before parsing the slice and the resulting anonymous AST_TYPE has no literal span source token. This PR gives those source-less span nodes an explicit identity without changing the 40-byte AstNode layout.

Adds AST_TYPE_SYNTHETIC_SPAN_CONST / AST_TYPE_SYNTHETIC_SPAN_MUTABLE encodings in the existing AST_TYPE.c metadata slot, plus flowc_ast_type_set_synthetic_span and flowc_ast_type_is_synthetic_span. The existing mutability setter preserves synthetic identity when toggling const/mut. ival remains available for an optional sized-reference extent.

Extends flowc_type_name_into so synthetic spans take the exact same canonical path as explicit spans: span_const_<elem> / span_mut_<elem>. No fake source offsets or alternate ABI spelling are introduced. Sized-reference extent remains AST metadata and does not perturb overload identity.

Tests cover source-less const/mutable normalization, synthetic identity, mutability, extent preservation, toggling without losing the tag, and the invariant that extent does not change the canonical overload name.

All commits use [skip ci]; qualification is local only. Remaining #720 work is parser wiring for &[T], &mut [T], &[T; N], and &mut [T; N] so it constructs these synthetic span nodes directly.

Related: #674 #677 #718 #720 #769 #770

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