fix(compiler): false-positive duplicate-using with file-level (blockless) namespace - #11486
fix(compiler): false-positive duplicate-using with file-level (blockless) namespace#11486timotheeguerin with Copilot wants to merge 6 commits into
duplicate-using with file-level (blockless) namespace#11486Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
…space Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
duplicate-using with file-level (blockless) namespace
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
…less namespace Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
…ssion test Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
commit: |
|
@copilot lots of failures now to note our namespace system is inspired by dotnet and they don't have the same issue |
…s in blockless namespace files Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
... Fixed in the latest commit. The previous fix was too broad — it changed the resolution order for ALL identifiers at the The correct fix is narrower: added a |
usingstatements placed before a blockless namespace declaration were incorrectly treated as duplicates of the sameusingappearing inside that namespace. This is inconsistent with block namespace behavior, whereusing N;outside +using N;inside is explicitly allowed.Root cause
checkDuplicateUsingsgroups statements by their parent symbol. All top-level statements in a file shareparent = TypeSpecScriptNode, so ausingbefore and after a blocklessnamespacedeclaration were indistinguishable — both got the same tracker key, triggering the duplicate check.Fix
In
checkDuplicateUsings, when a file has a blockless namespace (file.inScopeNamespaces[0]), usings that appear after the namespace declaration (by source position) are keyed on the namespace's merged symbol rather than the TypeSpecScript symbol. This creates separate duplicate-detection buckets for pre-namespace and post-namespace usings, matching block namespace behavior.Changes
checker.ts—checkDuplicateUsings: use blockless namespace symbol as tracker key for usings positioned after the namespace declarationusing.test.ts— two new test cases:using N; namespace Z; using N;→ no diagnostic;namespace Z; using N; using N;→ duplicate still reported