-
-
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
Segfault, when assigning quote do to compileTime var NimNode #21222
Comments
workaround (fix tbh, genast is a superior replacement for quote do): import std/[macros,genasts]
var x{.compiletime.} : NimNode =
genast():
echo "xxx" |
thanks! was growing frustrated that I can't just quote things and pass them around. at least, this gets me past that segfault. i suppose this is more of a user experience thing, but i find that putting genAst inside a tuple results in |
!nim c import std/macros
var x {.compileTime.} : NimNode =
quote do:
echo "xxx" |
@juancarlospaco (contributor) devel :-1: FAILOutput
Stats
IRASTnnkStmtList.newTree(
nnkImportStmt.newTree(
nnkInfix.newTree(
newIdentNode("/"),
newIdentNode("std"),
newIdentNode("macros")
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
nnkPragmaExpr.newTree(
newIdentNode("x"),
nnkPragma.newTree(
newIdentNode("compileTime")
)
),
newIdentNode("NimNode"),
nnkCall.newTree(
newIdentNode("quote"),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("echo"),
newLit("xxx")
)
)
)
)
)
) stable :-1: FAILOutput
Stats
IRASTnnkStmtList.newTree(
nnkImportStmt.newTree(
nnkInfix.newTree(
newIdentNode("/"),
newIdentNode("std"),
newIdentNode("macros")
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
nnkPragmaExpr.newTree(
newIdentNode("x"),
nnkPragma.newTree(
newIdentNode("compileTime")
)
),
newIdentNode("NimNode"),
nnkCall.newTree(
newIdentNode("quote"),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("echo"),
newLit("xxx")
)
)
)
)
)
) 1.6.0 :-1: FAILOutput
Stats
IRASTnnkStmtList.newTree(
nnkImportStmt.newTree(
nnkInfix.newTree(
newIdentNode("/"),
newIdentNode("std"),
newIdentNode("macros")
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
nnkPragmaExpr.newTree(
newIdentNode("x"),
nnkPragma.newTree(
newIdentNode("compileTime")
)
),
newIdentNode("NimNode"),
nnkCall.newTree(
newIdentNode("quote"),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("echo"),
newLit("xxx")
)
)
)
)
)
) 1.4.0 :-1: FAILOutput
Stats
IRASTnnkStmtList.newTree(
nnkImportStmt.newTree(
nnkInfix.newTree(
newIdentNode("/"),
newIdentNode("std"),
newIdentNode("macros")
)
),
nnkVarSection.newTree(
nnkIdentDefs.newTree(
nnkPragmaExpr.newTree(
newIdentNode("x"),
nnkPragma.newTree(
newIdentNode("compileTime")
)
),
newIdentNode("NimNode"),
nnkCall.newTree(
newIdentNode("quote"),
nnkStmtList.newTree(
nnkCommand.newTree(
newIdentNode("echo"),
newLit("xxx")
)
)
)
)
)
) 1.2.0 :+1: OKOutput
Stats
1.0.0 :+1: OKOutput
Stats
0.20.2 :+1: OKOutput
Stats
#2629d619a ➡️ 🐛DiagnosticsClyybber introduced a bug at
The bug is in the files:
The bug can be in the commits: (Diagnostics sometimes off-by-one). 46 minutes bisecting 4387 commits at 95 commits per second.
|
Similar case: #22282 (comment) import std/macros
proc f(): NimNode =
quote do:
123
var a = static f() |
import std/macros
var myNode {.compileTime.} = newStmtList()
macro test(n: static NimNode) = discard
myNode.test() This is enough to make the compiler segfault, too. |
related to #18367 |
Description
Code
The context is that I am trying to build up a compile-time list, containing data and NimNode (representing codeblocks), intended to be passed into a macro. But it seems directly assigning from quote do crashes the compiler (no compile error or warnings whatsoever).
Nim Version
Nim Compiler Version 1.6.8 [Linux: amd64]
Compiled at 2022-10-05
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: c9f46ca
active boot switches: -d:release
Current Output
Expected Output
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: