-
-
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
mixin + block expression: works in Generics, not in "normal" proc #7385
Comments
Tested in playground, no longer seems to be an issue. |
It still doesn't work when uncomment import std/macros
type CustomSeq*[T] = object
data*: seq[T]
macro `[]`*[T](s: CustomSeq[T], args: varargs[untyped]): untyped =
## The end goal is to replace the joker "_" by something else
result = newIntLitNode(10)
proc foo1(): CustomSeq[int] =
result.data.newSeq(10)
# Doesn't work
echo ((block:
mixin _ # invalid expression
result[_]
))
echo foo1() |
You're not supposed to be able to use |
this appears to be fixed in devel but it needs a test case |
Araq
pushed a commit
that referenced
this issue
Aug 30, 2024
closes #1969, closes #7547, closes #7737, closes #11838, closes #12283, closes #12714, closes #12720, closes #14053, closes #16118, closes #19670, closes #22645 I was going to wait on these but regression tests even for recent PRs are turning out to be important in wide reaching PRs like #24010. The other issues with the working label felt either finnicky (#7385, #9156, #12732, #15247), excessive to test (#12405, #12424, #17527), or I just don't know what fixed them/what the issue was (#16128: the PR link gives a server error by Github, #12457, #12487).
metagn
added a commit
to metagn/Nim
that referenced
this issue
Sep 16, 2024
closes nim-lang#4774, closes nim-lang#7385, closes nim-lang#10019, closes nim-lang#12405, closes nim-lang#12732, closes nim-lang#13270, closes nim-lang#13799, closes nim-lang#15247, closes nim-lang#16128, closes nim-lang#16175, closes nim-lang#16774, closes nim-lang#17527, closes nim-lang#20880, closes nim-lang#21346
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While trying to find an alternative to be able to slice with
_
likea[1, _, 0]
without having to define my own_
I stumbled upon the following:History:
_
identifier except for tuple destructuring It's possible to use a single underscore as an enum value identifier (0.17.3) #7171So I tried to inject
mixin _
in a block expression before the identifier resolution happen.Unfortunately this works in generic procs but not in normal proc.
Test case:
cc @krux02, @GULPF
The text was updated successfully, but these errors were encountered: