-
-
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
genericsOpenSym
not respecting injections across modules
#23386
Comments
The way this switch works when not enabled globally is admittedly terrible, since we want to store the information of whether a symbol should be opened so we can give a warning, caring about the switch is delayed until the instantiation context, i.e. not even in the context of the generic proc using it, but where the generic proc gets instantiated. (I'm guessing that would be the expected behavior, the switch should only matter at the generic proc declaration, when the symbols get marked as open). I hoped that making it into its own node kind |
Right, this I guess is a bit of a broader issue in nim, that it's hard to know what pragmas apply to in general (push vs top-level vs inside-proc etc). I guess it's not terrible though it does make it more difficult to provide a good out-of-the-box experience for a library like #23385 is a lower-hanging fruit perhaps where I can either warn or enforce ( |
Nooooo....... :-) |
refs #23873 (comment), fixes #23386, fixes #23385, supersedes #23572 Turns the `nfOpenSym` node flag implemented in #23091 and extended in #23102 and #23873, into a node kind `nkOpenSym` that forms a unary node containing either `nkSym` or `nkOpenSymChoice`. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switch `genericsOpenSym` is enabled, and a new node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice` when the switch is not enabled so that we can give a warning. Now that the experimental switch has more reasonable semantics, we define `nimHasGenericsOpenSym2`.
refs #23873 (comment), fixes #23386, fixes #23385, supersedes #23572 Turns the `nfOpenSym` node flag implemented in #23091 and extended in containing either `nkSym` or `nkOpenSymChoice`. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switch `genericsOpenSym` is enabled, and a new node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice` when the switch is not enabled so that we can give a warning. Now that the experimental switch has more reasonable semantics, we define `nimHasGenericsOpenSym2`. (cherry picked from commit 0c890ff)
refs #23873 (comment), fixes #23386, fixes #23385, supersedes #23572 Turns the `nfOpenSym` node flag implemented in #23091 and extended in containing either `nkSym` or `nkOpenSymChoice`. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switch `genericsOpenSym` is enabled, and a new node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice` when the switch is not enabled so that we can give a warning. Now that the experimental switch has more reasonable semantics, we define `nimHasGenericsOpenSym2`. (cherry picked from commit 0c890ff)
refs #23873 (comment), fixes #23386, fixes #23385, supersedes #23572 Turns the `nfOpenSym` node flag implemented in #23091 and extended in containing either `nkSym` or `nkOpenSymChoice`. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switch `genericsOpenSym` is enabled, and a new node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice` when the switch is not enabled so that we can give a warning. Now that the experimental switch has more reasonable semantics, we define `nimHasGenericsOpenSym2`. (cherry picked from commit 0c890ff)
Description
Followup on #23091
This is the same test as
Nim/tests/generics/tmacroinjectedsym.nim
Line 100 in 94c5996
testit.nim:
testit2.nim:
The local symbol in testit2 gets precedence over the injected symbol from testit, even though the injected symbol as a more local scope than the Xxx enum.
Nim Version
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-02-20
Copyright (c) 2006-2024 by Andreas Rumpf
git hash: 773c066
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: