-
-
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
opensym as node kind + fixed experimental switch #23892
Conversation
Seems to work, but until packages can handle it (macros just need simple skips AFAIK) or until regressions not detected in CI are fixed the node probably shouldn't be generated without the experimental switch enabled. So for the warning we probably need something like #23572, swapping out the existing node flag with one that only exists for a warning and is temporary. I'll do it in this PR if there are no objections, the other PR is out of date already. |
Fine with me. |
Please rebase. |
…nder experimental
Done |
compiler/condsyms.nim
Outdated
@@ -166,4 +166,5 @@ proc initDefines*(symbols: StringTableRef) = | |||
defineSymbol("nimHasWarnStdPrefix") | |||
|
|||
defineSymbol("nimHasVtables") | |||
defineSymbol("nimHasGenericsOpenSym") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be defined only when the experimental is on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nimHas defines usually signal that the experimental switch is available, checking if it's enabled is trickier since it can change depending on the context with push experimental
etc. #23933 was opened recently related to this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turns out nimHasGenericsOpenSym
is already declared, but for the broken version shipped in 2.0.8:
- https://github.com/nim-lang/Nim/blob/v2.0.8/compiler/condsyms.nim#L103
- https://github.com/nim-lang/Nim/blob/v2.0.8/compiler/options.nim#L224
will need a new name for this new, working version 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nimHasGenericsOpenSym2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to nimHasGenericsOpenSym2
not sure it's intended, but compiling this branch (3fe15eb) results in lots of warnings:
|
testing this, the semantics of Neither of these two work at top-level - the when condition:
{.experimental: "genericsOpenSym".}
{.push experimental: "genericsOpenSym".} However, in a situation analogous to the following, the push covers both a and b, even though the push is only inside a: template a =
when condition:
{.push experimental: "genericsOpenSym".}
template b =
template injector = discard # this works now It's kind of weird that inside a template scope, pushing extends to other unrelated templates but not outside.. |
Definitely not, my bad, I moved the warnings to the wrong spot in the code |
arnetheduck/nim-results#35 updated to work with this branch - also includes an ugly emulation hack for Nim versions that don't have this feature.. |
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
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)
…penSym` (#24111) alternative to #24101 #23892 changed the opensym experimental switch so that it has to be enabled in the context of the generic/template declarations capturing the symbols, not the context of the instantiation of the generics/templates. This was to be in line with where the compiler gives the warnings and changes behavior in a potentially breaking way. However `results` [depends on the old behavior](https://github.com/arnetheduck/nim-results/blob/71d404b314479a6205bfd050f4fe5fe49cdafc69/results.nim#L1428), so that the callers of the macros provided by results always take advantage of the opensym behavior. To accomodate this, we change the behavior of the old experimental option that `results` uses, `genericsOpenSym`, so that ignores the information of whether or not symbols are intentionally opened and always gives the opensym behavior as long as it's enabled at instantiation time. This should keep `results` working as is. However this differs from the normal opensym switch in that it doesn't generate `nnkOpenSym`. Before it was just a generics-only version of `openSym` along with `templateOpenSym` which was only for templates. So `templateOpenSym` is removed along with this change, but no one appears to have used it.
…penSym` (nim-lang#24111) alternative to nim-lang#24101 nim-lang#23892 changed the opensym experimental switch so that it has to be enabled in the context of the generic/template declarations capturing the symbols, not the context of the instantiation of the generics/templates. This was to be in line with where the compiler gives the warnings and changes behavior in a potentially breaking way. However `results` [depends on the old behavior](https://github.com/arnetheduck/nim-results/blob/71d404b314479a6205bfd050f4fe5fe49cdafc69/results.nim#L1428), so that the callers of the macros provided by results always take advantage of the opensym behavior. To accomodate this, we change the behavior of the old experimental option that `results` uses, `genericsOpenSym`, so that ignores the information of whether or not symbols are intentionally opened and always gives the opensym behavior as long as it's enabled at instantiation time. This should keep `results` working as is. However this differs from the normal opensym switch in that it doesn't generate `nnkOpenSym`. Before it was just a generics-only version of `openSym` along with `templateOpenSym` which was only for templates. So `templateOpenSym` is removed along with this change, but no one appears to have used it.
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 kindnkOpenSym
that forms a unary node containing eithernkSym
ornkOpenSymChoice
. Since this affects macros working on generic proc AST, the node kind is now only generated when the experimental switchgenericsOpenSym
is enabled, and a new node flagnfDisabledOpenSym
is set to thenkSym
ornkOpenSymChoice
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
.