Nim icon indicating copy to clipboard operation
Nim copied to clipboard

add back enum ident inference, only on undeclared identifiers

Open metagn opened this issue 1 year ago • 1 comments

closes #23611, refs #23588

This adds back the enum identifier inference removed in #23588 but altered so that it only triggers when no symbol in scope with the same name is found. This is just to prevent further breakage while not causing bugs as the old behavior did (however #23596 still needs #23597 to work with this). Otherwise this behavior was never documented and only introduced in 1.6.14.

There are still some cases that would compile with the old behavior but not with this, such as the case where the symbol is found in scope but does not match with the enum type:

# a.nim
type Foo* = enum abc
# b.nim
import a

type
  Bar* = enum abc
  Obj* = object
    val*: Foo
# c.nim
import b

var x: Obj
x.val = abc

We could maybe make this work but it would be even more complexity for the compiler that was never promised.

metagn avatar May 15 '24 16:05 metagn

Seems not to be worth it: https://github.com/nim-lang/Nim/issues/23611#issuecomment-2132816066

Araq avatar Jun 05 '24 22:06 Araq