From d63f5e20f1edf7c51ca5c456baceb9eb9a84c95b Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 1 Aug 2024 13:25:47 -0700 Subject: Allow a enum case to reference a previously defined value. (#4768) --- source/slang/slang-check-decl.cpp | 3 +++ source/slang/slang-parser.cpp | 2 ++ 2 files changed, 5 insertions(+) (limited to 'source') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index cd25e9d66..7211565dd 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -788,6 +788,9 @@ namespace Slang if(as(decl)) return true; + if (as(decl)) + return true; + // Things nested inside functions may have dependencies // on values from the enclosing scope, but this needs to // be dealt with via "capture" so they are also effectively diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index aefe7f362..6510793f3 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4945,6 +4945,7 @@ namespace Slang parseOptionalInheritanceClause(parser, decl); parser->ReadToken(TokenType::LBrace); Token closingToken; + parser->pushScopeAndSetParent(decl); while (!AdvanceIfMatch(parser, MatchedTokenType::CurlyBraces, &closingToken)) { EnumCaseDecl* caseDecl = parseEnumCaseDecl(parser); @@ -4955,6 +4956,7 @@ namespace Slang parser->ReadToken(TokenType::Comma); } + parser->PopScope(); decl->closingSourceLoc = closingToken.loc; return decl; }); -- cgit v1.2.3