fixes nim-lang/nimsuggest#103 con dot exprs (#16657)
- con calls for dot exprs now returns results - discovered an issue with dot expr results -- documented
This commit is contained in:
parent
e5ea3f0cce
commit
bb3c6d0797
2 changed files with 33 additions and 2 deletions
|
|
@ -298,6 +298,7 @@ proc suggestObject(c: PContext, n, f: PNode; info: TLineInfo, outputs: var Sugge
|
||||||
proc nameFits(c: PContext, s: PSym, n: PNode): bool =
|
proc nameFits(c: PContext, s: PSym, n: PNode): bool =
|
||||||
var op = if n.kind in nkCallKinds: n[0] else: n
|
var op = if n.kind in nkCallKinds: n[0] else: n
|
||||||
if op.kind in {nkOpenSymChoice, nkClosedSymChoice}: op = op[0]
|
if op.kind in {nkOpenSymChoice, nkClosedSymChoice}: op = op[0]
|
||||||
|
if op.kind == nkDotExpr: op = op[1]
|
||||||
var opr: PIdent
|
var opr: PIdent
|
||||||
case op.kind
|
case op.kind
|
||||||
of nkSym: opr = op.sym.name
|
of nkSym: opr = op.sym.name
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,43 @@
|
||||||
|
## Test Invocation `con`text in various situations
|
||||||
|
|
||||||
|
## various of this proc are used as the basis for these tests
|
||||||
proc test(s: string; a: int) = discard
|
proc test(s: string; a: int) = discard
|
||||||
|
|
||||||
|
## This overload should be used to ensure the lower airity `test` doesn't match
|
||||||
|
proc test(s: string; a: string, b: int) = discard
|
||||||
|
|
||||||
|
## similar signature but different name to ensure `con` doesn't get greedy
|
||||||
proc testB(a, b: string) = discard
|
proc testB(a, b: string) = discard
|
||||||
|
|
||||||
|
# with a param already specified
|
||||||
test("hello here", #[!]#)
|
test("hello here", #[!]#)
|
||||||
|
|
||||||
|
# as first param
|
||||||
testB(#[!]#
|
testB(#[!]#
|
||||||
|
|
||||||
|
# dot expressions
|
||||||
|
"from behind".test(#[!]#
|
||||||
|
|
||||||
|
# two params matched, so disqualify the lower airity `test`
|
||||||
|
# TODO: this doesn't work, because dot exprs, overloads, etc aren't currently
|
||||||
|
# handled by suggest.suggestCall. sigmatch.partialMatch by way of
|
||||||
|
# sigmatch.matchesAux. Doesn't use the operand before the dot as part of
|
||||||
|
# the formal parameters. Changing this is tricky because it's used by
|
||||||
|
# the proper compilation sem pass and that's a big change all in one go.
|
||||||
|
"and again".test("more", #[!]#
|
||||||
|
|
||||||
|
|
||||||
discard """
|
discard """
|
||||||
$nimsuggest --tester $file
|
$nimsuggest --tester $file
|
||||||
>con $1
|
>con $1
|
||||||
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;1;;5;;"";;100
|
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;4;;5;;"";;100
|
||||||
|
con;;skProc;;tcon1.test;;proc (s: string, a: string, b: int);;$file;;7;;5;;"";;100
|
||||||
>con $2
|
>con $2
|
||||||
con;;skProc;;tcon1.testB;;proc (a: string, b: string);;$file;;2;;5;;"";;100
|
con;;skProc;;tcon1.testB;;proc (a: string, b: string);;$file;;10;;5;;"";;100
|
||||||
|
>con $3
|
||||||
|
con;;skProc;;tcon1.test;;proc (s: string, a: string, b: int);;$file;;7;;5;;"";;100
|
||||||
|
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;4;;5;;"";;100
|
||||||
|
>con $4
|
||||||
|
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;4;;5;;"";;100
|
||||||
|
con;;skProc;;tcon1.test;;proc (s: string, a: string, b: int);;$file;;7;;5;;"";;100
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue