Skip to content

Commit

Permalink
add test that shows this fixes nim-lang#11986
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Mar 22, 2021
1 parent a038d95 commit a9f47ef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/macros/tgenast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,22 @@ block: # test passing function and type symbols
(z1(), z2(), z3('a'), z4(), $Z1, $Z2, $Z3, $Z4)
type Z1 = type('c')
doAssert bar(Z1) == (41, 42, 43, 44, "char", "bool", "uint8", "int8")

block: # fix https://github.com/nim-lang/Nim/issues/11986
proc foo(): auto =
var s = { 'a', 'b' }
# var n = quote do: `s` # would print {97, 98}
var n = genAst(s): s
n.repr
static: doAssert foo() == "{'a', 'b'}"

block: # also from #11986
macro foo(): untyped =
var s = { 'a', 'b' }
# quote do:
# let t = `s`
# $typeof(t) # set[range 0..65535(int)]
genAst(s):
let t = s
$typeof(t)
doAssert foo() == "set[char]"

0 comments on commit a9f47ef

Please sign in to comment.