diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-01 13:25:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-01 13:25:47 -0700 |
| commit | d63f5e20f1edf7c51ca5c456baceb9eb9a84c95b (patch) | |
| tree | 26432253494454c0b3ad921a2852184cbf06abc2 /source | |
| parent | 69dd7f40efd4988ba0fe3d4d5f6fee2d4d5d4a87 (diff) | |
Allow a enum case to reference a previously defined value. (#4768)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 3 | ||||
| -rw-r--r-- | source/slang/slang-parser.cpp | 2 |
2 files changed, 5 insertions, 0 deletions
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<ConstructorDecl>(decl)) return true; + if (as<EnumCaseDecl>(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; }); |
