Fix nimsuggest not suggesting fields in when theres static parameters (#21189)

Don't check against empty arguments

Add test case
This commit is contained in:
Jake Leahy 2022-12-28 17:35:11 +11:00 • committed by GitHub
commit 3d5dbf8f96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -2055,7 +2055,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
a.n == nil and
tfGenericTypeParam notin a.flags:
return newNodeIT(nkType, argOrig.info, makeTypeFromExpr(c, arg))
else:
elif arg.kind != nkEmpty:
var evaluated = c.semTryConstExpr(c, arg)
if evaluated != nil:
# Don't build the type in-place because `evaluated` and `arg` may point

View file

@ -0,0 +1,18 @@
# Reduced case of 21185. Issue was first parameter being static
proc foo(x: static[int]) = discard
type
Person = object
name: string
age: int
let p = Person()
p.#[!]#
discard """
$nimsuggest --tester --v3 --maxresults:2 $file
>sug $1
sug;;skField;;age;;int;;$file;;8;;4;;"";;100;;None
sug;;skField;;name;;string;;$file;;7;;4;;"";;100;;None
"""