fixes #1940; code breakage! stricter template evaluation
This commit is contained in:
parent
c914532c26
commit
d58212ccc5
6 changed files with 479 additions and 435 deletions
|
|
@ -946,10 +946,7 @@ template `{}=`*(n: PNode, i: int, s: PNode): stmt =
|
|||
n.sons[i -| n] = s
|
||||
|
||||
when defined(useNodeIds):
|
||||
const nodeIdToDebug* = -1 # 884953 # 612794
|
||||
#612840 # 612905 # 614635 # 614637 # 614641
|
||||
# 423408
|
||||
#429107 # 430443 # 441048 # 441090 # 441153
|
||||
const nodeIdToDebug* = -1 # 299750 # 300761 #300863 # 300879
|
||||
var gNodeId: int
|
||||
|
||||
proc newNode*(kind: TNodeKind): PNode =
|
||||
|
|
|
|||
|
|
@ -1232,7 +1232,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType,
|
|||
elif f.kind == tyStatic:
|
||||
return arg.typ.n
|
||||
else:
|
||||
return argOrig
|
||||
return argSemantized # argOrig
|
||||
|
||||
if r != isNone and f.isInlineIterator:
|
||||
var inlined = newTypeS(tyStatic, c)
|
||||
|
|
|
|||
|
|
@ -1222,7 +1222,7 @@ proc processBody(node, retFutureSym: PNimrodNode,
|
|||
of nnkTryStmt:
|
||||
# try: await x; except: ...
|
||||
result = newNimNode(nnkStmtList, node)
|
||||
template wrapInTry(n, tryBody: PNimrodNode) =
|
||||
template wrapInTry(n, tryBody: expr) =
|
||||
var temp = n
|
||||
n[0] = tryBody
|
||||
tryBody = temp
|
||||
|
|
|
|||
47
tests/template/texponential_eval.nim
Normal file
47
tests/template/texponential_eval.nim
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# bug #1940
|
||||
|
||||
discard """
|
||||
nimout: '''===
|
||||
merge (A) with (B)
|
||||
merge (A B) with (C)
|
||||
merge (A B C) with (D)
|
||||
merge (A B C D) with (E)
|
||||
merge (A B C D E) with (F)
|
||||
==='''
|
||||
"""
|
||||
|
||||
type SqlStmt = tuple
|
||||
sql: string
|
||||
parts: int
|
||||
|
||||
proc sql(q: string): SqlStmt =
|
||||
result.sql = q
|
||||
result.parts = 1
|
||||
|
||||
template `&%%`(x, y: SqlStmt): SqlStmt =
|
||||
const a = x
|
||||
const b = y
|
||||
|
||||
static:
|
||||
#echo "some merge"
|
||||
echo "merge (", a.sql, ") with (", b.sql, ")"
|
||||
|
||||
|
||||
const newSql = a.sql & " " & b.sql
|
||||
const newParts = a.parts + b.parts
|
||||
|
||||
SqlStmt((sql: newSql, parts: newParts))
|
||||
|
||||
static:
|
||||
echo "==="
|
||||
|
||||
let c =(sql("A") &%%
|
||||
sql("B")) &%%
|
||||
sql("C") &%%
|
||||
sql("D") &%%
|
||||
sql("E") &%%
|
||||
sql("F")
|
||||
echo c.sql
|
||||
|
||||
static:
|
||||
echo "==="
|
||||
Loading…
Add table
Add a link
Reference in a new issue