nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

--styleCheck:hint gives incorrect [Name] refactoring suggestion #11756

Open kaushalmodi opened 5 years ago

kaushalmodi commented 5 years ago

When running compiling the below test code with --styleCheck:hint, I get an incorrect [Name] refactoring suggestion.

The compiler is mixing up the enum element reSet with the reset proc of Nim objects.

# t.nim
type
  SomeType = enum
    reSet
  SomeObj = object
    foo: int

var
  obj = SomeObj(foo: 123)
echo obj
obj.reset()
echo obj

Command to run

nim c --styleCheck:hint t.nim

Expected outcome

The below [Name] warning should not show up.

Actual output

t.nim(12, 5) Hint: 'reset' should be: 'reSet' [Name]

What's worse is that I can never run with --styleCheck:error on such projects due to this incorrect warning.

Ref: https://github.com/nitely/nim-regex/pull/40#issue-298183684

Nim version

Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-07-16
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 44d80dd86373b9ba41051428948eae30ed97acd3
active boot switches: -d:release
Araq commented 5 years ago

Funny bug. :-)