-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quote do captures non literal local variables #9607
Comments
Error: internal error: genLiteral: ty is nil
in macro
Honestliy I hate how This code works btw: import macros
proc fun1*(info:LineInfo): string = "bar"
proc fun2*(info:int): string = "bar"
macro echoL*(args: varargs[untyped]): untyped =
let info = args.lineInfoObj
let infoLit = info.newLit
let infoLineLit = info.line.newLit
let fun1 = bindSym"fun1"
let fun2 = bindSym"fun2"
# this would work instead
# result = newCall(bindSym"fun2", info.line.newLit)
result = quote do:
# BUG1: ???(0, 0) Error: internal error: genLiteral: ty is nil
discard `fun1`(`infoLit`)
# BUG2: Error: object constructor needs an object type
discard `fun2`(`infoLineLit`)
echoL() |
Currently (Nim devel 1.1.1):
|
@narimiran I tried to verify your output. I only get this: |
that's why i usually use git hashes in bug reports; it's more precise than "devel" |
* new `macros.genAst`: fixes all issues with `quote do` * add changelog entry * add workaround for #2465 (comment) * add test for #9607 * add kNoExposeLocalInjects option * add test case for nested application of genAst * genAst: automatically call newLit when needed * allow skipping `{}`: genAst: foo * add test that shows this fixes #11986 * add examples showing mixin; add examples showing passing types, macros, templates * move to std/genasts * improve docs
…nim-lang#9607; rework quote do; `getAst` uses type info to annotate the type of quoted variables; no more type erasures for quoted variables (nim-lang#21433) * fixes nim-lang#21326; getAst uses type info to annotateType quoted variables * simplify logics; sem types first * fixes important packages * add testcases * tiny
…nim-lang#9607; rework quote do; `getAst` uses type info to annotate the type of quoted variables; no more type erasures for quoted variables (nim-lang#21433) * fixes nim-lang#21326; getAst uses type info to annotateType quoted variables * simplify logics; sem types first * fixes important packages * add testcases * tiny
uncomment line below BUG2 gives
Error: object constructor needs an object type
it works if we instead use
result = newCall(bindSym"fun2", info.line.newLit)
The text was updated successfully, but these errors were encountered: