diff options
author | metagn <metagngn@gmail.com> | 2024-08-20 22:32:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-20 21:32:35 +0200 |
commit | e38cbd3c846a8e95bed0d709e4d61cc1ad5279b2 (patch) | |
tree | b556b87bbf9fcec4ee94b96d3ca08dc0f709564b /tests/lookups | |
parent | ab189620857a9fe36480044732c407dfcfdec73a (diff) | |
download | Nim-e38cbd3c846a8e95bed0d709e4d61cc1ad5279b2.tar.gz |
consider ambiguity for qualified symbols (#23989)
fixes #23893 When type symbols are ambiguous, calls to them aren't allowed to be type conversions and only routine symbols are considered instead. But the compiler doesn't acknowledge that qualified symbols can be ambiguous, `qualifiedLookUp` directly tries to access the identifier from the module string table. Now it checks the relevant symbol iterators for any symbol after the first received symbol, in which case the symbol is considered ambiguous. `nkDotExpr` is also included in the whitelist of node kinds for ambiguous type symbols (not entirely sure why this exists, it's missing `nkAccQuoted` as well).
Diffstat (limited to 'tests/lookups')
-rw-r--r-- | tests/lookups/mqualifiedamb1.nim | 1 | ||||
-rw-r--r-- | tests/lookups/mqualifiedamb2.nim | 4 | ||||
-rw-r--r-- | tests/lookups/tqualifiedamb.nim | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/tests/lookups/mqualifiedamb1.nim b/tests/lookups/mqualifiedamb1.nim new file mode 100644 index 000000000..47046142e --- /dev/null +++ b/tests/lookups/mqualifiedamb1.nim @@ -0,0 +1 @@ +type K* = object diff --git a/tests/lookups/mqualifiedamb2.nim b/tests/lookups/mqualifiedamb2.nim new file mode 100644 index 000000000..3ea5bd04f --- /dev/null +++ b/tests/lookups/mqualifiedamb2.nim @@ -0,0 +1,4 @@ +import ./mqualifiedamb1 +export mqualifiedamb1 +template K*(kind: static int): auto = typedesc[mqualifiedamb1.K] +template B*(kind: static int): auto = typedesc[mqualifiedamb1.K] diff --git a/tests/lookups/tqualifiedamb.nim b/tests/lookups/tqualifiedamb.nim new file mode 100644 index 000000000..a5e1955f3 --- /dev/null +++ b/tests/lookups/tqualifiedamb.nim @@ -0,0 +1,4 @@ +import ./mqualifiedamb2 +discard default(K(0)) # works +discard default(mqualifiedamb2.B(0)) # works +discard default(mqualifiedamb2.K(0)) # doesn't work |