summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-impl.h5
-rw-r--r--source/slang/slang-check-modifier.cpp13
-rw-r--r--source/slang/slang-check.cpp20
3 files changed, 38 insertions, 0 deletions
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index 433c6ca70..c15428877 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -237,6 +237,11 @@ namespace Slang
Dictionary<LookupRequestKey, LookupResult> lookupCache;
};
+
+ /// Give a cache and a name, will remove all entries associated with a name
+ /// Might be useful/necessary if a new name is introduced
+ void removeLookupForName(TypeCheckingCache* cache, Name* name);
+
/// Shared state for a semantics-checking session.
struct SharedSemanticsContext
{
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index a7fb641a2..a2b411c22 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -226,6 +226,19 @@ namespace Slang
attrDecl->parentDecl = parentDecl;
parentDecl->members.add(attrDecl);
+ SLANG_ASSERT(!parentDecl->isMemberDictionaryValid());
+
+ // TODO(JS): A bit of a work around(!)
+ //
+ // To get to this point we must have already have performed a lookup for attributeName,
+ // and it failed. That lookup used the TypeCheckingCache, and
+ // so we know there is a cache entry that will be *wrong*, now we have created and
+ // added the AttributeDecl with the attributeName.
+ //
+ // To work around, we remove all cached lookups around the name, such that when a subsequent
+ // lookup is made, the cache will not return the old (wrong) result.
+ removeLookupForName(getLinkage()->getTypeCheckingCache(), attributeName);
+
// Finally, we perform any required semantic checks on
// the newly constructed attribute decl.
//
diff --git a/source/slang/slang-check.cpp b/source/slang/slang-check.cpp
index bcc74a6d0..8c6cddbfe 100644
--- a/source/slang/slang-check.cpp
+++ b/source/slang/slang-check.cpp
@@ -210,4 +210,24 @@ namespace Slang
throw;
}
}
+
+ void removeLookupForName(TypeCheckingCache* cache, Name* name)
+ {
+ auto& lookupCache = cache->lookupCache;
+
+ List<LookupRequestKey> keys;
+
+ for (const auto& pairs : lookupCache)
+ {
+ const auto& key = pairs.Key;
+ if (key.name == name)
+ {
+ keys.add(key);
+ }
+ }
+ for (auto& key : keys)
+ {
+ lookupCache.Remove(key);
+ }
+ }
}