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
{.compileTime.} tuple destructuring - crash on 0.20, bad codegen on 0.19 #11634
Comments
Here is the compiler stacktrace on current devel
|
Minimal repro code shows that it's the tuple destructuring of {.compileTime.} variables that causes the issues:
type Foo = ref object
val: int
proc divmod(a, b: Foo): (Foo, Foo) =
(
Foo(val: a.val div b.val),
Foo(val: a.val mod b.val)
)
block:
let a {.compileTime.} = Foo(val: 2)
let b {.compileTime.} = Foo(val: 3)
let (c {.compileTime.}, d {.compileTime.}) = divmod(a, b) |
…esn't happen at the right time
Tagging low-priority as we can always assign and then destructure one by one as a workaround. let cd {.compileTime.} = divmod(a, b)
let c = cd.c
let d = cd.d |
Once I'm done with my PR mixing |
BTW, not sure if it's exactly the same error but I'm running into compileTime tuple unpacking error
Allow or disallow, the important thing is that a programmer can determine "Tuple unpacking is not allowed in compile time context" from error message IMO |
I'm encountering a couple of issues when experimenting with a deep learning compiler proof of concept in Nim.
Unfortunately the repro code is about 1000 lines but for my experiments purposes everything his kept in a single file so is reproducible with a simple nim c foo.nim.Edit: Found a minimal repro code, see my 3rd comment
The following code works (e11), the only caveat is the API I highlighted which uses global {.compileTime.} variables.
So in another experiment (e12) I kept the backend procs but added a couple of procs to try another API, the extra
generate
macro generates a block with compile-time function evaluation that should be equivalent to e11.The strange thing is that:
The C code also includes the code for my AstNode variant type even though it is supposed to only exist at compile-time.
The text was updated successfully, but these errors were encountered: