compiler/types: correctly generates signature for non-proc types (#10658)
This makes signatures generated for nimsuggest correctly distinguish template/macro/converter from proc.
This commit is contained in:
parent
1ae61767f8
commit
9e754c3b06
2 changed files with 21 additions and 1 deletions
|
|
@ -588,7 +588,15 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
if prefer != preferExported:
|
if prefer != preferExported:
|
||||||
result.add("(" & typeToString(t.sons[0]) & ")")
|
result.add("(" & typeToString(t.sons[0]) & ")")
|
||||||
of tyProc:
|
of tyProc:
|
||||||
result = if tfIterator in t.flags: "iterator " else: "proc "
|
result = if tfIterator in t.flags: "iterator "
|
||||||
|
elif t.owner != nil:
|
||||||
|
case t.owner.kind
|
||||||
|
of skTemplate: "template "
|
||||||
|
of skMacro: "macro "
|
||||||
|
of skConverter: "converter "
|
||||||
|
else: "proc "
|
||||||
|
else:
|
||||||
|
"proc "
|
||||||
if tfUnresolved in t.flags: result.add "[*missing parameters*]"
|
if tfUnresolved in t.flags: result.add "[*missing parameters*]"
|
||||||
result.add "("
|
result.add "("
|
||||||
for i in countup(1, sonsLen(t) - 1):
|
for i in countup(1, sonsLen(t) - 1):
|
||||||
|
|
|
||||||
12
nimsuggest/tests/tsug_template.nim
Normal file
12
nimsuggest/tests/tsug_template.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
template tmpa() = discard
|
||||||
|
macro tmpb() = discard
|
||||||
|
converter tmpc() = discard
|
||||||
|
tmp#[!]#
|
||||||
|
|
||||||
|
discard """
|
||||||
|
$nimsuggest --tester $file
|
||||||
|
>sug $1
|
||||||
|
sug;;skMacro;;tsug_template.tmpb;;macro (){.noSideEffect, gcsafe, locks: 0.};;$file;;2;;6;;"";;0;;Prefix
|
||||||
|
sug;;skConverter;;tsug_template.tmpc;;converter ();;$file;;3;;10;;"";;0;;Prefix
|
||||||
|
sug;;skTemplate;;tsug_template.tmpa;;template (): typed;;$file;;1;;9;;"";;0;;Prefix
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue