Skip to content

Commit bb3c6d0

Browse files
authored
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
1 parent e5ea3f0 commit bb3c6d0

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

compiler/suggest.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ proc suggestObject(c: PContext, n, f: PNode; info: TLineInfo, outputs: var Sugge
298298
proc nameFits(c: PContext, s: PSym, n: PNode): bool =
299299
var op = if n.kind in nkCallKinds: n[0] else: n
300300
if op.kind in {nkOpenSymChoice, nkClosedSymChoice}: op = op[0]
301+
if op.kind == nkDotExpr: op = op[1]
301302
var opr: PIdent
302303
case op.kind
303304
of nkSym: opr = op.sym.name

nimsuggest/tests/tcon1.nim

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
1+
## Test Invocation `con`text in various situations
2+
3+
## various of this proc are used as the basis for these tests
14
proc test(s: string; a: int) = discard
5+
6+
## This overload should be used to ensure the lower airity `test` doesn't match
7+
proc test(s: string; a: string, b: int) = discard
8+
9+
## similar signature but different name to ensure `con` doesn't get greedy
210
proc testB(a, b: string) = discard
11+
12+
# with a param already specified
313
test("hello here", #[!]#)
14+
15+
# as first param
416
testB(#[!]#
517

18+
# dot expressions
19+
"from behind".test(#[!]#
20+
21+
# two params matched, so disqualify the lower airity `test`
22+
# TODO: this doesn't work, because dot exprs, overloads, etc aren't currently
23+
# handled by suggest.suggestCall. sigmatch.partialMatch by way of
24+
# sigmatch.matchesAux. Doesn't use the operand before the dot as part of
25+
# the formal parameters. Changing this is tricky because it's used by
26+
# the proper compilation sem pass and that's a big change all in one go.
27+
"and again".test("more", #[!]#
28+
629

730
discard """
831
$nimsuggest --tester $file
932
>con $1
10-
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;1;;5;;"";;100
33+
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;4;;5;;"";;100
34+
con;;skProc;;tcon1.test;;proc (s: string, a: string, b: int);;$file;;7;;5;;"";;100
1135
>con $2
12-
con;;skProc;;tcon1.testB;;proc (a: string, b: string);;$file;;2;;5;;"";;100
36+
con;;skProc;;tcon1.testB;;proc (a: string, b: string);;$file;;10;;5;;"";;100
37+
>con $3
38+
con;;skProc;;tcon1.test;;proc (s: string, a: string, b: int);;$file;;7;;5;;"";;100
39+
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;4;;5;;"";;100
40+
>con $4
41+
con;;skProc;;tcon1.test;;proc (s: string, a: int);;$file;;4;;5;;"";;100
42+
con;;skProc;;tcon1.test;;proc (s: string, a: string, b: int);;$file;;7;;5;;"";;100
1343
"""

0 commit comments

Comments
 (0)