loosen compiler assert for ident node in dotcall matching [backport:2.2] (#25003)

fixes #25000

A failed match on `nfDotField` tries to assert that the name of the dot
field is an identifier node. I am not exactly sure how but at some point
typed generics causes an `nfDotField` call to contain a symchoice for
the field name. The compiler does not use the fact that the field name
is an identifier, so the assert is loosened to allow any identifier-like
node kind. Could also investigate why the symchoice gets created, my
guess is that typed generics detects that the match fails but still
sends it through generic prechecking and doesn't remove the
`nfDotField`, which is harmless and it might cause more trouble to work
around it.

(cherry picked from commit 8e5ed5dbb7)
This commit is contained in:
metagn
2025-06-16 20:22:23 +03:00
committed by narimiran
parent d65a0a3144
commit 62df0b7586
2 changed files with 7 additions and 1 deletions

View File

@@ -581,7 +581,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
let overloadsState = result.state
if overloadsState != csMatch:
if nfDotField in n.flags:
internalAssert c.config, f.kind == nkIdent and n.len >= 2
internalAssert c.config, f.kind in nkIdentKinds and n.len >= 2
# leave the op head symbol empty,
# we are going to try multiple variants

View File

@@ -0,0 +1,6 @@
# issue #25000
proc r(T: typedesc[int]): int = discard
proc c[J: typedesc[uint]](u = J.r) = discard #[tt.Error
^ undeclared field: 'r']#
c[uint]()