mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 06:23:25 +00:00
fixes #5467
This commit is contained in:
@@ -851,7 +851,11 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||
put(g, tkRStrLit, '\"' & replace(n[1].strVal, "\"", "\"\"") & '\"')
|
||||
else:
|
||||
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:
|
||||
put(g, tkCast, "cast")
|
||||
put(g, tkBracketLe, "[")
|
||||
|
||||
@@ -2324,12 +2324,16 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
of nkIfExpr, nkIfStmt: result = semIf(c, n)
|
||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkHiddenCallConv:
|
||||
checkSonsLen(n, 2)
|
||||
considerGenSyms(c, n)
|
||||
of nkStringToCString, nkCStringToString, nkObjDownConv, nkObjUpConv:
|
||||
checkSonsLen(n, 1)
|
||||
considerGenSyms(c, n)
|
||||
of nkChckRangeF, nkChckRange64, nkChckRange:
|
||||
checkSonsLen(n, 3)
|
||||
considerGenSyms(c, n)
|
||||
of nkCheckedFieldExpr:
|
||||
checkMinSonsLen(n, 2)
|
||||
considerGenSyms(c, n)
|
||||
of nkTableConstr:
|
||||
result = semTableConstr(c, n)
|
||||
of nkClosedSymChoice, nkOpenSymChoice:
|
||||
|
||||
@@ -3,7 +3,8 @@ discard """
|
||||
|
||||
[0.0, 0.0, 0.0, 0.0]
|
||||
|
||||
5050'''
|
||||
5050
|
||||
123'''
|
||||
"""
|
||||
|
||||
template mathPerComponent(op: untyped): untyped =
|
||||
@@ -47,3 +48,26 @@ proc main2() =
|
||||
echo s
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user