diff options
Diffstat (limited to 'source/slang/slang-parser.cpp')
| -rw-r--r-- | source/slang/slang-parser.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index eb1671aa7..c225ff4ee 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4250,6 +4250,9 @@ static void parseModernVarDeclBaseCommon(Parser* parser, VarDeclBase* decl) decl->type = parser->ParseTypeExp(); } + auto modifiers = _parseOptSemantics(parser); + _addModifiers(decl, modifiers); + if (AdvanceIf(parser, TokenType::OpAssign)) { decl->initExpr = parser->ParseInitExpr(); @@ -4351,6 +4354,8 @@ static NodeBase* parseFuncDecl(Parser* parser, void* /*userData*/) { parser->PushScope(decl); parseModernParamList(parser, decl); + auto funcScope = parser->currentScope; + parser->PopScope(); if (AdvanceIf(parser, "throws")) { decl->errorType = parser->ParseTypeExp(); @@ -4359,8 +4364,6 @@ static NodeBase* parseFuncDecl(Parser* parser, void* /*userData*/) { decl->returnType = parser->ParseTypeExp(); } - auto funcScope = parser->currentScope; - parser->PopScope(); maybeParseGenericConstraints(parser, genericParent); parser->PushScope(funcScope); decl->body = parseOptBody(parser); @@ -5509,10 +5512,16 @@ Decl* Parser::ParseStruct() rs->wrappedType = ParseTypeExp(); PushScope(rs); PopScope(); - ReadToken(TokenType::Semicolon); + if (!LookAheadToken(TokenType::Semicolon)) + { + this->diagnose( + this->tokenReader.peekToken().loc, + Diagnostics::unexpectedTokenExpectedTokenType, + "';'"); + } return rs; } - if (AdvanceIf(this, TokenType::Semicolon)) + if (LookAheadToken(TokenType::Semicolon)) { rs->hasBody = false; return rs; |
