diff options
author | alaviss <alaviss@users.noreply.github.com> | 2019-02-13 14:07:58 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-02-13 23:30:14 +0100 |
commit | 9e754c3b0623433380de171d25bfb862eb2f9ab7 (patch) | |
tree | dee5611f89fd3d5c34866f551317bf633a3a46eb | |
parent | 1ae61767f8664635404c75a4b4c369b19ab75c22 (diff) | |
download | Nim-9e754c3b0623433380de171d25bfb862eb2f9ab7.tar.gz |
compiler/types: correctly generates signature for non-proc types (#10658)
This makes signatures generated for nimsuggest correctly distinguish template/macro/converter from proc.
-rw-r--r-- | compiler/types.nim | 10 | ||||
-rw-r--r-- | nimsuggest/tests/tsug_template.nim | 12 |
2 files changed, 21 insertions, 1 deletions
diff --git a/compiler/types.nim b/compiler/types.nim index 23902459e..7034917d4 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -588,7 +588,15 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = if prefer != preferExported: result.add("(" & typeToString(t.sons[0]) & ")") 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*]" result.add "(" for i in countup(1, sonsLen(t) - 1): diff --git a/nimsuggest/tests/tsug_template.nim b/nimsuggest/tests/tsug_template.nim new file mode 100644 index 000000000..3fa69322f --- /dev/null +++ b/nimsuggest/tests/tsug_template.nim @@ -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 +""" |