diff options
author | metagn <metagngn@gmail.com> | 2024-01-01 14:21:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-01 12:21:19 +0100 |
commit | b280100499fafe43657c860e3c79d9347be5b4b6 (patch) | |
tree | 804eae96580a2614a0014e24d11c3fdb89a3323a /tests/lookups/tambsym3.nim | |
parent | ccc7c45d718c13714e8e9e1040c29b9b286d2448 (diff) | |
download | Nim-b280100499fafe43657c860e3c79d9347be5b4b6.tar.gz |
ambiguous identifier resolution (#23123)
fixes #23002, fixes #22841, refs comments in #23097 When an identifier is ambiguous in scope (i.e. multiple imports contain symbols with the same name), attempt resolving it through type inference (by creating a symchoice). To do this efficiently, `qualifiedLookUp` had to be broken up so that `semExpr` can access the ambiguous candidates directly (now obtained directly via `lookUpCandidates`). This fixes the linked issues, but an example like: ```nim let on = 123 {.warning[ProveInit]: on.} ``` will still fail, since `on` is unambiguously the local `let` symbol here (this is also true for `proc on` but `proc` symbols generate symchoices anyway). Type symbols are not considered to not confuse the type inference. This includes the change in sigmatch, up to this point symchoices with nonoverloadable symbols could be created, they just wouldn't be considered during disambiguation. Now every proper symbol except types are considered in disambiguation, so the correct symbols must be picked during the creation of the symchoice node. I remember there being a violating case of this in the compiler, but this was very likely fixed by excluding type symbols as CI seems to have found no issues. The pure enum ambiguity test was disabled because ambiguous pure enums now behave like overloadable enums with this behavior, so we get a longer error message for `echo amb` like `type mismatch: got <MyEnum | OtherEnum> but expected T`
Diffstat (limited to 'tests/lookups/tambsym3.nim')
-rw-r--r-- | tests/lookups/tambsym3.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/lookups/tambsym3.nim b/tests/lookups/tambsym3.nim index 6e7589cd8..6bbebca10 100644 --- a/tests/lookups/tambsym3.nim +++ b/tests/lookups/tambsym3.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "ambiguous identifier 'mDec' -- use one of the following:" + errormsg: "ambiguous identifier: 'mDec' -- use one of the following:" file: "tambsym3.nim" line: 11 """ |