fixes #5467
This commit is contained in:
parent
4a77b66b19
commit
3fa428c88b
3 changed files with 34 additions and 2 deletions
|
|
@ -851,7 +851,11 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
put(g, tkRStrLit, '\"' & replace(n[1].strVal, "\"", "\"\"") & '\"')
|
put(g, tkRStrLit, '\"' & replace(n[1].strVal, "\"", "\"\"") & '\"')
|
||||||
else:
|
else:
|
||||||
gsub(g, n.sons[1])
|
gsub(g, n.sons[1])
|
||||||
of nkHiddenStdConv, nkHiddenSubConv, nkHiddenCallConv: gsub(g, n.sons[1])
|
of nkHiddenStdConv, nkHiddenSubConv, nkHiddenCallConv:
|
||||||
|
if n.len >= 2:
|
||||||
|
gsub(g, n.sons[1])
|
||||||
|
else:
|
||||||
|
put(g, tkSymbol, "(wrong conv)")
|
||||||
of nkCast:
|
of nkCast:
|
||||||
put(g, tkCast, "cast")
|
put(g, tkCast, "cast")
|
||||||
put(g, tkBracketLe, "[")
|
put(g, tkBracketLe, "[")
|
||||||
|
|
|
||||||
|
|
@ -2324,12 +2324,16 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
of nkIfExpr, nkIfStmt: result = semIf(c, n)
|
of nkIfExpr, nkIfStmt: result = semIf(c, n)
|
||||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkHiddenCallConv:
|
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkHiddenCallConv:
|
||||||
checkSonsLen(n, 2)
|
checkSonsLen(n, 2)
|
||||||
|
considerGenSyms(c, n)
|
||||||
of nkStringToCString, nkCStringToString, nkObjDownConv, nkObjUpConv:
|
of nkStringToCString, nkCStringToString, nkObjDownConv, nkObjUpConv:
|
||||||
checkSonsLen(n, 1)
|
checkSonsLen(n, 1)
|
||||||
|
considerGenSyms(c, n)
|
||||||
of nkChckRangeF, nkChckRange64, nkChckRange:
|
of nkChckRangeF, nkChckRange64, nkChckRange:
|
||||||
checkSonsLen(n, 3)
|
checkSonsLen(n, 3)
|
||||||
|
considerGenSyms(c, n)
|
||||||
of nkCheckedFieldExpr:
|
of nkCheckedFieldExpr:
|
||||||
checkMinSonsLen(n, 2)
|
checkMinSonsLen(n, 2)
|
||||||
|
considerGenSyms(c, n)
|
||||||
of nkTableConstr:
|
of nkTableConstr:
|
||||||
result = semTableConstr(c, n)
|
result = semTableConstr(c, n)
|
||||||
of nkClosedSymChoice, nkOpenSymChoice:
|
of nkClosedSymChoice, nkOpenSymChoice:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ discard """
|
||||||
|
|
||||||
[0.0, 0.0, 0.0, 0.0]
|
[0.0, 0.0, 0.0, 0.0]
|
||||||
|
|
||||||
5050'''
|
5050
|
||||||
|
123'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template mathPerComponent(op: untyped): untyped =
|
template mathPerComponent(op: untyped): untyped =
|
||||||
|
|
@ -47,3 +48,26 @@ proc main2() =
|
||||||
echo s
|
echo s
|
||||||
|
|
||||||
main2()
|
main2()
|
||||||
|
|
||||||
|
# bug #5467
|
||||||
|
import macros
|
||||||
|
|
||||||
|
converter int2string(x: int): string = $x
|
||||||
|
|
||||||
|
template wrap(body: typed): untyped =
|
||||||
|
body
|
||||||
|
|
||||||
|
macro makeProc(): typed =
|
||||||
|
# Make a template tree
|
||||||
|
result = (quote do:
|
||||||
|
proc someProc* =
|
||||||
|
wrap do:
|
||||||
|
let x = 123
|
||||||
|
# Implicit conversion here
|
||||||
|
let s: string = x
|
||||||
|
echo s
|
||||||
|
)
|
||||||
|
|
||||||
|
makeProc()
|
||||||
|
|
||||||
|
someProc()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue