diff options
author | metagn <metagngn@gmail.com> | 2024-08-28 21:51:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-28 20:51:13 +0200 |
commit | 770f8d551372893ed480550062a89e76c60ff4a8 (patch) | |
tree | 87f6e049aea09dfcd9bbed2fccb67f84d3172445 /tests/generics | |
parent | d3af51e3ce968076bb3331087806312c0faba054 (diff) | |
download | Nim-770f8d551372893ed480550062a89e76c60ff4a8.tar.gz |
opensym for templates + move behavior of opensymchoice to itself (#24007)
fixes #15314, fixes #24002 The OpenSym behavior first added to generics in #23091 now also applies to templates, since templates can also capture symbols that are meant to be replaced by local symbols if the context imports symbols with the same name, as in the issue #24002. The experimental switch `templateOpenSym` is added to enable this behavior for templates only, and the experimental switch `openSym` is added to enable it for both templates and generics, and the documentation now mainly mentions this switch. Additionally the logic for `nkOpenSymChoice` nodes that were previously wrapped in `nkOpenSym` now apply to all `nkOpenSymChoice` nodes, and so these nodes aren't wrapped in `nkOpenSym` anymore. This means `nkOpenSym` can only have children of kind `nkSym` again, so it is more in line with the structure of symchoice nodes. As for why they aren't merged with `nkOpenSymChoice` nodes yet, we need some way to signal that the node shouldn't become ambiguous if other options exist at instantiation time, we already captured a symbol at the beginning and another symbol can only replace it if it's closer in scope and unambiguous.
Diffstat (limited to 'tests/generics')
-rw-r--r-- | tests/generics/tmacroinjectedsymwarning.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/generics/tmacroinjectedsymwarning.nim b/tests/generics/tmacroinjectedsymwarning.nim index 4b2ae4f7e..77119004b 100644 --- a/tests/generics/tmacroinjectedsymwarning.nim +++ b/tests/generics/tmacroinjectedsymwarning.nim @@ -46,13 +46,13 @@ proc f(): Result[int, cstring] = proc g(T: type): string = let x = f().valueOr: - {.push warningAsError[GenericsIgnoredInjection]: on.} + {.push warningAsError[IgnoredSymbolInjection]: on.} # test spurious error discard true let _ = f {.pop.} return $error #[tt.Warning - ^ a new symbol 'error' has been injected during instantiation of g, however 'error' [enumField declared in tmacroinjectedsymwarning.nim(6, 3)] captured at the proc declaration will be used instead; either enable --experimental:genericsOpenSym to use the injected symbol or `bind` this captured symbol explicitly [GenericsIgnoredInjection]]# + ^ a new symbol 'error' has been injected during template or generic instantiation, however 'error' [enumField declared in tmacroinjectedsymwarning.nim(6, 3)] captured at the proc declaration will be used instead; either enable --experimental:openSym to use the injected symbol, or `bind` this captured symbol explicitly [IgnoredSymbolInjection]]# "ok" |