Skip to content

Keep struct in a when ^T struct static optimization - #3516

Merged
nojaf merged 2 commits into
fsprojects:mainfrom
nojaf:fix-3514
Oct 5, 2026
Merged

nojaf merged 2 commits into
fsprojects:mainfrom
nojaf:fix-3514

Conversation

@nojaf

@nojaf nojaf commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The printer wrote only the type parameter of a WhenTyparIsStruct constraint, so when ^T struct = 0 became when ^T = 0, which does not parse. The case that pinned the bug as ignored now runs as a regular negative case.

Fixes #3514

nojaf added 2 commits October 5, 2026 13:12
The printer wrote only the type parameter of a WhenTyparIsStruct
constraint, so `when ^T struct = 0` became `when ^T = 0`, which does
not parse. The case that pinned the bug as ignored now runs as a
regular negative case.

Fixes fsprojects#3514
Conditions of one `when` were printed with only a space between them,
so `when ^T : int and ^U struct` lost its `and`. The parser also keeps
those conditions in reverse, and nests several `when` clauses with the
first one outermost, so formatting reversed both. Reversed conditions
put the Oak children out of source order, and reversed clauses made
the result swap back on every format.

The transformer now rebuilds the clauses and their conditions in
source order, and the printer joins conditions with `and`.
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.

Static optimization when ^T struct loses struct

1 participant