Skip to content

Commit

Permalink
Register declaration of enum field has a use (#22990)
Browse files Browse the repository at this point in the history
Currently when using `use` with nimsuggest on an enum field, it doesn't
return the definition of the field.

Breaks renaming in IDEs since it will replace all the usages, but not
the declaration
  • Loading branch information
ire4ever1190 authored Nov 27, 2023
1 parent 5b2fcab commit c31bbb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
result.n.add symNode
styleCheckDef(c, e)
onDef(e.info, e)
suggestSym(c.graph, e.info, e, c.graph.usageSym)
if sfGenSym notin e.flags:
if not isPure:
addInterfaceOverloadableSymAt(c, c.currentScope, e)
Expand Down
15 changes: 15 additions & 0 deletions nimsuggest/tests/tuse_enum.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
discard """
$nimsuggest --tester $file
>use $1
def;;skEnumField;;tuse_enum.Colour.Red;;Colour;;$file;;10;;4;;"";;100
use;;skEnumField;;tuse_enum.Colour.Red;;Colour;;$file;;14;;8;;"";;100
"""

type
Colour = enum
Red
Green
Blue

discard #[!]#Red

0 comments on commit c31bbb0

Please sign in to comment.