diff options
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 21a16cae5..da2300d8a 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -10589,6 +10589,7 @@ void SemanticsDeclHeaderVisitor::visitIncludeDecl(IncludeDecl* decl) if (fileDecl->members.getCount() == 0) return; + auto firstMember = fileDecl->members[0]; if (auto moduleDeclaration = as<ModuleDeclarationDecl>(firstMember)) { @@ -10610,6 +10611,7 @@ void SemanticsDeclHeaderVisitor::visitIncludeDecl(IncludeDecl* decl) auto moduleName = getSimpleModuleName(implementing->moduleNameAndLoc.name); auto expectedModuleName = moduleDecl->getName(); bool shouldSkipDiagnostic = false; + if (moduleDecl->members.getCount()) { if (auto moduleDeclarationDecl = as<ModuleDeclarationDecl>(moduleDecl->members[0])) @@ -10629,16 +10631,44 @@ void SemanticsDeclHeaderVisitor::visitIncludeDecl(IncludeDecl* decl) } } } - if (!shouldSkipDiagnostic && !moduleName.getUnownedSlice().caseInsensitiveEquals( - getText(expectedModuleName).getUnownedSlice())) + + if (!shouldSkipDiagnostic) { - getSink()->diagnose( - decl->moduleNameAndLoc.loc, - Diagnostics::includedFileDoesNotImplementCurrentModule, - expectedModuleName, - moduleName); - return; + // First check for the case when the user has put a file extension + // in the include path + String moduleNameStr = moduleName.getUnownedSlice(); + String expectedModuleNameStr = getText(expectedModuleName).getUnownedSlice(); + + // Check if module name has a source file extension + if (moduleNameStr.endsWith(".slang")) + { + String normalizedName = moduleNameStr.subString(0, moduleNameStr.getLength() - 6); + + // If the normalized name would match, emit warning but continue + if (normalizedName.getUnownedSlice().caseInsensitiveEquals( + expectedModuleNameStr.getUnownedSlice())) + { + getSink()->diagnose( + implementing->moduleNameAndLoc.loc, + Diagnostics::moduleImplementationHasFileExtension, + moduleNameStr, + normalizedName); + return; + } + } + + if (!moduleNameStr.getUnownedSlice().caseInsensitiveEquals( + expectedModuleNameStr.getUnownedSlice())) + { + getSink()->diagnose( + decl->moduleNameAndLoc.loc, + Diagnostics::includedFileDoesNotImplementCurrentModule, + expectedModuleName, + moduleName); + return; + } } + return; } @@ -10648,6 +10678,7 @@ void SemanticsDeclHeaderVisitor::visitIncludeDecl(IncludeDecl* decl) name); } + void SemanticsDeclScopeWiringVisitor::visitImplementingDecl(ImplementingDecl* decl) { // Don't need to do anything unless we are in a language server context. |
