mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-14 15:08:35 +00:00
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>