mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-27 17:11:40 +00:00
* new .gensym implementation * make astspec test green again * introduce a --useVersion switch to group compatibility switches * fixes #10180 * fixes #11494 * fixes #11483 * object constructor fields and named parameters are also not gensym'ed * disabled broken package
45 lines
686 B
Nim
45 lines
686 B
Nim
discard """
|
|
output: '''0
|
|
|
|
0.0'''
|
|
"""
|
|
|
|
# bug #11494
|
|
import macros
|
|
|
|
macro staticForEach(arr: untyped, body: untyped): untyped =
|
|
result = newNimNode(nnkStmtList)
|
|
|
|
arr.expectKind(nnkBracket)
|
|
for n in arr:
|
|
let b = copyNimTree(body)
|
|
result.add quote do:
|
|
block:
|
|
type it {.inject.} = `n`
|
|
`b`
|
|
|
|
template forEveryMatchingEntity*() =
|
|
staticForEach([int, string, float]):
|
|
var a: it
|
|
echo a
|
|
|
|
forEveryMatchingEntity()
|
|
|
|
|
|
# bug #11483
|
|
proc main =
|
|
template first(body) =
|
|
template second: var int =
|
|
var o: int
|
|
var i = addr(o)
|
|
i[]
|
|
|
|
body
|
|
|
|
first:
|
|
second = 5
|
|
second = 6
|
|
|
|
main()
|
|
|