Skip to content

Commit 8e5ed5d

Browse files
authored
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.
1 parent 7701b3c commit 8e5ed5d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/semcall.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
581581
let overloadsState = result.state
582582
if overloadsState != csMatch:
583583
if nfDotField in n.flags:
584-
internalAssert c.config, f.kind == nkIdent and n.len >= 2
584+
internalAssert c.config, f.kind in nkIdentKinds and n.len >= 2
585585

586586
# leave the op head symbol empty,
587587
# we are going to try multiple variants

tests/generics/twrongdotcallcrash.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# issue #25000
2+
3+
proc r(T: typedesc[int]): int = discard
4+
proc c[J: typedesc[uint]](u = J.r) = discard #[tt.Error
5+
^ undeclared field: 'r']#
6+
c[uint]()

0 commit comments

Comments
 (0)