Files
carbon-lang/toolchain/parse/testdata/function
David BlaikieandNicholas Bishop 059ee7b9ed Parse -> ref T as a primitive return form (#7911)
Previously `-> ref T` was parsed as a type expression whose outermost
node is a `ref` prefix operator (the same one used for `F(ref x)`
arguments), and `ReturnExprAsForm` recognized the resulting `RefTagExpr`
and turned it into a `RefForm`.

Per p5434, a return form that begins with `val`, `ref`, or `var` is not
a type expression. Parse a leading `ref` after `->` as a
`RefPrimitiveForm` node wrapping the type expression, reusing the node
produced by `form(ref T)`, and check it as a form. This prepares for
supporting `-> val T` and `-> var T` in the same way.

The only SemIR change is that the `ref_tag` instruction is no longer
emitted, and the return slot pattern refers to a `type_component_of` the
form, matching `->? form(ref T)`.

---------

Co-authored-by: Nicholas Bishop <nbishop@nbishop.net>
2026-10-07 23:05:55 +00:00
..