diff options
author | Jake Leahy <jake@leahy.dev> | 2024-09-23 18:14:26 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 10:14:26 +0200 |
commit | 6f6e34ebb037cdc83f8ec24b0422e70fc70d7107 (patch) | |
tree | d663619bd0de426b1a1a9c7c31371f3bd5aecdb2 /compiler | |
parent | a55c15c651b805c5eca4475f9845a57adf6cddef (diff) | |
download | Nim-6f6e34ebb037cdc83f8ec24b0422e70fc70d7107.tar.gz |
Fix line info used for `UnunsedImport` from subdirectories (#24158)
When importing from subdirectories, the line info used in `UnusedImport` warning would be the `/` node and not the actual module node. More obvious with grouped imports where all unused imports would show the same column ![image](https://github.com/user-attachments/assets/42850130-1e0e-46b9-bd72-54864a1ad41c) Fix is to just use the last child node for infixes when getting the line info
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/importer.nim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index 176b33b7b..ffb7e0305 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -246,7 +246,8 @@ proc importModuleAs(c: PContext; n: PNode, realModule: PSym, importHidden: bool) result = createModuleAliasImpl(realModule.name) if importHidden: result.options.incl optImportHidden - c.unusedImports.add((result, n.info)) + let moduleIdent = if n.kind == nkInfix: n[^1] else: n + c.unusedImports.add((result, moduleIdent.info)) c.importModuleMap[result.id] = realModule.id c.importModuleLookup.mgetOrPut(result.name.id, @[]).addUnique realModule.id |