summary refs log tree commit diff stats
path: root/tests/lookups/tambsym3.nim
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-09-03 14:59:03 +0300
committerGitHub <noreply@github.com>2023-09-03 13:59:03 +0200
commit480e98c479035a8a19ff543bace3616d202e1ea2 (patch)
treee4de712b5ce6473919a1f37cb732459425d3068b /tests/lookups/tambsym3.nim
parentd2f36c071b1967e864961f423596d3931e84e49b (diff)
downloadNim-480e98c479035a8a19ff543bace3616d202e1ea2.tar.gz
resolve unambiguous enum symchoices from local scope, error on rest (#22606)
fixes #22598, properly fixes #21887 and fixes test case issue number

When an enum field sym choice has to choose a type, check if its name is
ambiguous in the local scope, then check if the first symbol found in
the local scope is the first symbol in the sym choice. If so, choose
that symbol. Otherwise, give an ambiguous identifier error.

The dependence on the local scope implies this will always give
ambiguity errors for unpicked enum symchoices from generics and
templates and macros from other scopes. We can change `not
isAmbiguous(...) and foundSym == first` to `not (isAmbiguous(...) and
foundSym == first)` to make it so they never give ambiguity errors, and
always pick the first symbol in the symchoice. I can do this if this is
preferred, but no code from CI seems affected.
Diffstat (limited to 'tests/lookups/tambsym3.nim')
-rw-r--r--tests/lookups/tambsym3.nim7
1 files changed, 2 insertions, 5 deletions
diff --git a/tests/lookups/tambsym3.nim b/tests/lookups/tambsym3.nim
index e50f9c461..6e7589cd8 100644
--- a/tests/lookups/tambsym3.nim
+++ b/tests/lookups/tambsym3.nim
@@ -1,15 +1,12 @@
 discard """
-  errormsg: "ambiguous enum field"
+  errormsg: "ambiguous identifier 'mDec' -- use one of the following:"
   file: "tambsym3.nim"
-  line: 14
+  line: 11
 """
 # Test ambiguous symbols
 
 import mambsym1, times
 
-{.hint[AmbiguousEnum]: on.}
-{.hintAsError[AmbiguousEnum]: on.}
-
 var
   v = mDec #ERROR_MSG ambiguous identifier