-
-
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
Cannot access static object field after passing it to macro #13252
Labels
Comments
For some reason the error message changes when you add a single line import macros
type
FooBar = object
a: seq[int]
macro genFoobar(fb: static FooBar): untyped =
result = newStmtList()
for b in fb.a:
result.add(newCall(bindSym"echo", newLit b))
proc foobar(fb: static FooBar) =
genFoobar(fb)
echo fb.type # added line, same error when wrapped in static:
for b in fb.a:
echo "foo" & $b
proc main() =
const a: seq[int] = @[1, 2, 3]
# Error: type mismatch: got <array[0..2, int]> but expected 'seq[int]'
const fb = Foobar(a: a)
foobar(fb)
main() So this is some ownership/GC problem? |
Works in devel now. However, @hlaaftana code fails with: |
Second example also works now probably since #24224 |
metagn
added a commit
to metagn/Nim
that referenced
this issue
Dec 8, 2024
closes nim-lang#6013, closes nim-lang#7009, closes nim-lang#9190, closes nim-lang#12487, closes nim-lang#12831, closes nim-lang#13184, closes nim-lang#13252, closes nim-lang#14860, closes nim-lang#14877, closes nim-lang#14894, closes nim-lang#14917, closes nim-lang#16153, closes nim-lang#16439, closes nim-lang#17779, closes nim-lang#18074, closes nim-lang#18202, closes nim-lang#18314, closes nim-lang#18648, closes nim-lang#19063, closes nim-lang#19446, closes nim-lang#20065, closes nim-lang#20367, closes nim-lang#22126, closes nim-lang#22820, closes nim-lang#22888, closes nim-lang#23020, closes nim-lang#23287, closes nim-lang#23510
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get "Error: undeclared field: 'a'" when trying to access a static object field after passing it to a macro.
Example
Current Output
Expected Output
Additional Information
The text was updated successfully, but these errors were encountered: