From dc3ffb6a71f36e3cfd1fc001d128a86b46c88e7a Mon Sep 17 00:00:00 2001 From: metagn Date: Fri, 27 Sep 2024 12:11:21 +0300 Subject: consider calling convention and iterator in getType for procs (#24181) fixes #19010 `getType` for proc types generated an `nkProcTy` for iterator types instead of `nkIteratorTy`, and didn't generate a calling convention pragma unless it was in the proc AST. Iterator types now generate `nkIteratorTy`, and a calling convention pragma is added if the calling convention isn't `closure` or was explicitly provided. --- compiler/vmdeps.nim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'compiler') diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 5f9a2b5bc..294aaaa79 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -237,7 +237,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; of tySequence: result = mapTypeToBracket("seq", mSeq, t, info) of tyProc: if inst: - result = newNodeX(nkProcTy) + result = newNodeX(if tfIterator in t.flags: nkIteratorTy else: nkProcTy) var fp = newNodeX(nkFormalParams) if t.returnType == nil: fp.add newNodeI(nkEmpty, info) @@ -246,8 +246,15 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; for i in FirstParamAt.. 0: t.n[0][pragmasEffects].copyTree - else: newNodeI(nkEmpty, info) + var prag = + if t.n[0].len > 0: + t.n[0][pragmasEffects].copyTree + else: + newNodeI(nkEmpty, info) + if t.callConv != ccClosure or tfExplicitCallConv in t.flags: + if prag.kind == nkEmpty: prag = newNodeI(nkPragma, info) + prag.add newIdentNode(getIdent(cache, $t.callConv), info) + result.add prag else: result = mapTypeToBracket("proc", mNone, t, info) of tyOpenArray: result = mapTypeToBracket("openArray", mOpenArray, t, info) -- cgit 1.4.1-2-gfad0 value='committer'>committer
blob: da99ea264ef12c3f57a3b329ad05d5918f257feb (plain) (tree)
1
2
3
4
5
6
7
8
9
10