diff options
| author | Yong He <yonghe@outlook.com> | 2025-07-21 21:35:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-22 04:35:44 +0000 |
| commit | 9d47a352960efd71494c7dfa0918debd5b405077 (patch) | |
| tree | f0acf898cb5c4de8a1951ac8010168b119bf94ff /source/slang/slang-check-overload.cpp | |
| parent | 9adac4069fbcc7ce5bea2c42d19c61eb1dcd7f25 (diff) | |
Fix Conditioanl<T, false> fields with a semantic. (#7855)
* Fix Conditioanl<T, false> fields with a semantic.
* Add unit test.
* Fix test.
Diffstat (limited to 'source/slang/slang-check-overload.cpp')
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 52b0ef5bc..18fb9798b 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -270,12 +270,31 @@ bool SemanticsVisitor::TryCheckOverloadCandidateVisibility( return true; } +static bool isArrayDecl(Decl* decl) +{ + if (auto magicMod = decl->findModifier<MagicTypeModifier>()) + { + if (magicMod->magicNodeType.getTag() == ASTNodeType::ArrayExpressionType) + return true; + } + return false; +} + bool SemanticsVisitor::TryCheckGenericOverloadCandidateTypes( OverloadResolveContext& context, OverloadCandidate& candidate) { auto genericDeclRef = candidate.item.declRef.as<GenericDecl>(); + // All generic arguments, except array sizes, need to be at least a link-time constant. + // Exception: array sizes can also be a specialization constant. + // + ConstantFoldingKind argFoldingKind = ConstantFoldingKind::LinkTime; + if (isArrayDecl(genericDeclRef.getDecl())) + { + argFoldingKind = ConstantFoldingKind::SpecializationConstant; + } + // Only allow constructing a PartialGenericAppExpr when referencing a callable decl. // Other types of generic decls must be fully specified. bool allowPartialGenericApp = false; @@ -497,6 +516,7 @@ bool SemanticsVisitor::TryCheckGenericOverloadCandidateTypes( val = ExtractGenericArgInteger( arg, getType(m_astBuilder, valParamRef), + argFoldingKind, context.mode == OverloadResolveContext::Mode::JustTrying ? nullptr : getSink()); } |
