Restore the old behavior of parsing "quote do:"

close #5845
This commit is contained in:
Zahary Karadjov 2017-07-18 11:50:06 +03:00 • committed by Andreas Rumpf
commit 7ad115f530
6 changed files with 260 additions and 215 deletions

View file

@ -408,20 +408,19 @@ macro `{}`*(typ: typedesc, xs: varargs[untyped]): auto =
kString = quote do:
when compiles($`k`): $`k` else: "invalid"
v = x[1]
body.add(quote do:
body.add quote do:
when compiles(`a`.`k`):
`a`.`k` = `v`
elif compiles(`a`[`k`]):
`a`[`k`] = `v`
else:
`a`[`kString`] = `v`
)
else:
error("Expression `" & $x.toStrLit & "` not allowed in `{}` macro")
body.add(quote do:
body.add quote do:
return `a`
)
result = quote do:
proc inner(): `typ` {.gensym.} =