summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/parser.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 5cc048cf5..914ec0a23 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -2992,7 +2992,14 @@ namespace Slang
{
// Add any modifiers we parsed before the declaration to the list
// of modifiers on the declaration itself.
- AddModifiers(decl.Ptr(), modifiers.first);
+ //
+ // We need to be careful, because if `decl` is a generic declaration,
+ // then we really want the modifiers to apply to the inner declaration.
+ //
+ RefPtr<Decl> declToModify = decl;
+ if(auto genericDecl = decl.As<GenericDecl>())
+ declToModify = genericDecl->inner;
+ AddModifiers(declToModify.Ptr(), modifiers.first);
// Make sure the decl is properly nested inside its lexical parent
if (containerDecl)