-
-
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
Macros: quasiquoting + dot or bracket syntax: dot and brackets are ignored #7726
Comments
Brackets are also ignored: import macros
macro foo(): untyped =
let a = @[1, 2, 3, 4, 5]
result = quote do:
`a.len`
macro foo2(): untyped =
let a = @[1, 2, 3, 4, 5]
let len = a.len
result = quote do:
`len`
macro foo3(): untyped =
let a = @[1, 2, 3, 4, 5]
let len = a.len
result = quote do:
`a[2]`
echo foo() # Outputs @[1, 2, 3, 4, 5] instead of 5
echo foo2() # Outputs 5
echo foo3() # Outputs @[1, 2, 3, 4, 5] instead of 3 |
Yeah, and idents aren't handled correctly. I have to write |
Yes, the backticks on expressions should, when not supported, at least come with a sane error message. @dom96 sorry, this is a very late reply, but your comment is on an entirely different issue. And I am aware of it. |
is the fix in works? Ability to call functions in unquote parts help to keep code clean, like in scheme/racket, for instance, the following doesn't compile: import macros
macro fun(): untyped =
let a = @[1, 2, 3, 4, 5]
result = quote do:
`len(a)`
echo fun |
there is this branch from me: #11823 |
The quasiquoting interpolation ignores dot call/fields. Test case:
The text was updated successfully, but these errors were encountered: