Don't repeat suggestions for same symbol (#21140)

* Track seen module graphs so symbols from the same module aren't repeated
Add test case

* Track symbols instead of modules

* Don't show duplicate symbols in spell checker

Removes the declared location from the message. Since we don't show duplicates anymore it would be a bit misleading if we only show the location for the first declaration of the symbol
This commit is contained in:
Jake Leahy
2022-12-23 00:44:10 +11:00
committed by GitHub
parent 37daed3897
commit 18c115c8d0
5 changed files with 71 additions and 35 deletions

View File

@@ -5,21 +5,21 @@ discard """
nimout: '''
tspellsuggest.nim(45, 13) Error: undeclared identifier: 'fooBar'
candidates (edit distance, scope distance); see '--spellSuggest':
(1, 0): 'fooBar8' [var declared in tspellsuggest.nim(43, 9)]
(1, 1): 'fooBar7' [var declared in tspellsuggest.nim(41, 7)]
(1, 3): 'fooBar1' [var declared in tspellsuggest.nim(33, 5)]
(1, 3): 'fooBar2' [let declared in tspellsuggest.nim(34, 5)]
(1, 3): 'fooBar3' [const declared in tspellsuggest.nim(35, 7)]
(1, 3): 'fooBar4' [proc declared in tspellsuggest.nim(36, 6)]
(1, 3): 'fooBar5' [template declared in tspellsuggest.nim(37, 10)]
(1, 3): 'fooBar6' [macro declared in tspellsuggest.nim(38, 7)]
(1, 5): 'FooBar' [type declared in mspellsuggest.nim(5, 6)]
(1, 5): 'fooBar4' [proc declared in mspellsuggest.nim(1, 6)]
(1, 5): 'fooBar9' [var declared in mspellsuggest.nim(2, 5)]
(1, 5): 'fooCar' [var declared in mspellsuggest.nim(4, 5)]
(2, 5): 'FooCar' [type declared in mspellsuggest.nim(6, 6)]
(2, 5): 'GooBa' [type declared in mspellsuggest.nim(7, 6)]
(3, 0): 'fooBarBaz' [const declared in tspellsuggest.nim(44, 11)]
(1, 0): 'fooBar8'
(1, 1): 'fooBar7'
(1, 3): 'fooBar1'
(1, 3): 'fooBar2'
(1, 3): 'fooBar3'
(1, 3): 'fooBar4'
(1, 3): 'fooBar5'
(1, 3): 'fooBar6'
(1, 5): 'FooBar'
(1, 5): 'fooBar4'
(1, 5): 'fooBar9'
(1, 5): 'fooCar'
(2, 5): 'FooCar'
(2, 5): 'GooBa'
(3, 0): 'fooBarBaz'
'''
"""

View File

@@ -5,18 +5,18 @@ discard """
nimout: '''
tspellsuggest2.nim(45, 13) Error: undeclared identifier: 'fooBar'
candidates (edit distance, scope distance); see '--spellSuggest':
(1, 0): 'fooBar8' [var declared in tspellsuggest2.nim(43, 9)]
(1, 1): 'fooBar7' [var declared in tspellsuggest2.nim(41, 7)]
(1, 3): 'fooBar1' [var declared in tspellsuggest2.nim(33, 5)]
(1, 3): 'fooBar2' [let declared in tspellsuggest2.nim(34, 5)]
(1, 3): 'fooBar3' [const declared in tspellsuggest2.nim(35, 7)]
(1, 3): 'fooBar4' [proc declared in tspellsuggest2.nim(36, 6)]
(1, 3): 'fooBar5' [template declared in tspellsuggest2.nim(37, 10)]
(1, 3): 'fooBar6' [macro declared in tspellsuggest2.nim(38, 7)]
(1, 5): 'FooBar' [type declared in mspellsuggest.nim(5, 6)]
(1, 5): 'fooBar4' [proc declared in mspellsuggest.nim(1, 6)]
(1, 5): 'fooBar9' [var declared in mspellsuggest.nim(2, 5)]
(1, 5): 'fooCar' [var declared in mspellsuggest.nim(4, 5)]
(1, 0): 'fooBar8'
(1, 1): 'fooBar7'
(1, 3): 'fooBar1'
(1, 3): 'fooBar2'
(1, 3): 'fooBar3'
(1, 3): 'fooBar4'
(1, 3): 'fooBar5'
(1, 3): 'fooBar6'
(1, 5): 'FooBar'
(1, 5): 'fooBar4'
(1, 5): 'fooBar9'
(1, 5): 'fooCar'
'''
"""

View File

@@ -0,0 +1,21 @@
discard """
# pending bug #16521 (bug 12) use `matrix`
cmd: "nim c --spellsuggest:4 --hints:off $file"
action: "reject"
nimout: '''
tspellsuggest3.nim(21, 1) Error: undeclared identifier: 'fooBar'
candidates (edit distance, scope distance); see '--spellSuggest':
(1, 2): 'FooBar'
(1, 2): 'fooBar4'
(1, 2): 'fooBar9'
(1, 2): 'fooCar'
'''
"""
import ./mspellsuggest
import ./mspellsuggest
import ./mspellsuggest
import ./mspellsuggest
fooBar