From b280100499fafe43657c860e3c79d9347be5b4b6 Mon Sep 17 00:00:00 2001 From: metagn Date: Mon, 1 Jan 2024 14:21:19 +0300 Subject: 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 but expected T` --- tests/lookups/tambsym3.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/lookups/tambsym3.nim') 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 """ -- cgit 1.4.1-2-gfad0