From faf042ecc3e688a1a3ffbe1ac44d18dd7ddf441a Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 29 May 2025 08:05:57 -0700 Subject: Language version + tuple syntax. (#7230) * Language version + tuple syntax. * Fix compile error. * regenerate documentation Table of Contents * Fix. * regenerate command line reference * Fix. * Fix. * Fix more test failures. * revert empty line change, * Retrigger CI * #version->#lang * Update source/core/slang-type-text-util.cpp Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> * Remove comments. * Fix parsing logic. * Fix parser. * Fix parser. * update test comment * Update options. * regenerate documentation Table of Contents * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> --- source/slang/slang-check-decl.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index f8a80c09b..71aa71e69 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -34,21 +34,18 @@ static bool isAssociatedTypeDecl(Decl* decl) return false; } -static bool isSlang2026(CompilerOptionSet& optionSet) +static bool isSlang2026OrLater(SemanticsVisitor* visitor) { - if (!optionSet.hasOption(CompilerOptionName::Language)) - return false; - return SLANG_SOURCE_LANGUAGE_SLANG == - SlangSourceLanguage( - optionSet.getEnumOption(CompilerOptionName::Language)) && - SLANG_STD_REVISION_2026 == - optionSet.getEnumOption(CompilerOptionName::StdRevision); + return visitor->getShared()->m_module->getModuleDecl()->languageVersion >= + SLANG_LANGUAGE_VERSION_2026; } -static bool allowExperimentalDynamicDispatch(CompilerOptionSet& optionSet) +static bool allowExperimentalDynamicDispatch( + SemanticsVisitor* visitor, + CompilerOptionSet& optionSet) { return optionSet.getBoolOption(CompilerOptionName::EnableExperimentalDynamicDispatch) || - !isSlang2026(optionSet); + !isSlang2026OrLater(visitor); } static void validateDynInterfaceUsage( @@ -57,7 +54,7 @@ static void validateDynInterfaceUsage( CompilerOptionSet& optionSet, InterfaceDecl* decl) { - if (allowExperimentalDynamicDispatch(optionSet)) + if (allowExperimentalDynamicDispatch(visitor, optionSet)) return; if (!decl->hasModifier()) @@ -134,7 +131,7 @@ static void validateDynInterfaceUseWithInheritanceDecl( if (!interfaceDeclIsDyn) return; - if (!allowExperimentalDynamicDispatch(optionSet)) + if (!allowExperimentalDynamicDispatch(visitor, optionSet)) { if (auto extensionDeclParent = as(decl->parentDecl)) { @@ -665,6 +662,13 @@ struct SemanticsDeclReferenceVisitor : public SemanticsDeclVisitorBase, void visitParenExpr(ParenExpr* expr) { dispatchIfNotNull(expr->base); } + void visitTupleExpr(TupleExpr* expr) + { + for (auto element : expr->elements) + dispatchIfNotNull(element); + } + + void visitAssignExpr(AssignExpr* expr) { dispatchIfNotNull(expr->left); @@ -13817,7 +13821,7 @@ void SemanticsDeclCapabilityVisitor::visitInheritanceDecl(InheritanceDecl* inher if (!implDecl) continue; - if (getModuleDecl(implDecl.getDecl())->isInLegacyLanguage) + if (getModuleDecl(implDecl.getDecl())->languageVersion == SLANG_LANGUAGE_VERSION_LEGACY) break; ensureDecl(requirementDecl, DeclCheckState::CapabilityChecked); @@ -13880,8 +13884,9 @@ DeclVisibility getDeclVisibility(Decl* decl) auto defaultVis = DeclVisibility::Default; if (auto parentModule = getModuleDecl(decl)) { - defaultVis = parentModule->isInLegacyLanguage ? DeclVisibility::Public - : parentModule->defaultVisibility; + defaultVis = parentModule->languageVersion == SLANG_LANGUAGE_VERSION_LEGACY + ? DeclVisibility::Public + : parentModule->defaultVisibility; } // Members of other agg type decls will have their default visibility capped to the -- cgit v1.2.3