mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 12:18:31 +00:00
Support -> val T and -> var T return forms (#7912)
Proposal p5434 specifies `-> val T`, `-> ref T`, and `-> var T` as return forms. `-> ref T` is parsed as a `RefPrimitiveForm`; extend that to parse a leading `val` or `var` after `->` as a `ValPrimitiveForm` or `VarPrimitiveForm`, reusing the nodes produced by `form(val T)` and `form(var T)`, and check them as forms. --------- Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
This commit is contained in:
1 parent
831a2aee9f
commit
1c69fe3447
6 files changed
+414
-8
No files matched your search
@@ -35,8 +35,10 @@ auto HandleFunctionAfterParams(Context& context) -> void {
|
||||
auto HandleReturnTypeOrFormExpr(Context& context) -> void {
|
||||
context.PopAndDiscardState();
|
||||
|
||||
// `-> ref T` specifies a primitive return form.
|
||||
if (context.PositionIs(Lex::TokenKind::Ref)) {
|
||||
// `-> val T`, `-> ref T`, and `-> var T` specify a primitive return form.
|
||||
if (context.PositionIs(Lex::TokenKind::Val) ||
|
||||
context.PositionIs(Lex::TokenKind::Ref) ||
|
||||
context.PositionIs(Lex::TokenKind::Var)) {
|
||||
context.PushState(StateKind::PrimitiveFormFinish, context.Consume());
|
||||
}
|
||||
context.PushStateForExpr(PrecedenceGroup::ForType());
|
||||
|
||||
Reference in new issue
Block a user