diff options
author | metagn <metagngn@gmail.com> | 2024-08-25 23:24:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 22:24:20 +0200 |
commit | 09dcff71c82147b28059c6470bd921afab9c825e (patch) | |
tree | b513a7a55fa5eea14b139685da7c547ba969b770 /changelog.md | |
parent | 0d53b6e027a66bc60ca853d57c019338bb73ba0b (diff) | |
download | Nim-09dcff71c82147b28059c6470bd921afab9c825e.tar.gz |
generate symchoice for ambiguous types in templates & generics + handle types in symchoices (#23997)
fixes #23898, supersedes #23966 and #23990 Since #20631 ambiguous type symbols in templates are rejected outright, now we generate a symchoice for type nodes if they're ambiguous, a generalization of what was done in #22375. This is done for generics as well. Symchoices also handle type symbols better now, ensuring their type is a `typedesc` type; this probably isn't necessary for everything to work but it makes the logic more robust. Similar to #23989, we have to prepare for the fact that ambiguous type symbols behave differently than normal type symbols and either error normally or relegate to other routine symbols if the symbol is being called. Generating a symchoice emulates this behavior, `semExpr` will find the type symbol first, but since the symchoice has other symbols, it will count as an ambiguous type symbol. I know it seems spammy to carry around an ambiguity flag everywhere, but in the future when we have something like #23104 we could just always generate a symchoice, and the symchoice itself would carry the info of whether the first symbol was ambiguous. But this could harm compiler performance/memory use, it might be better to generate it only when we have to, which in the case of type symbols is only when they're ambiguous.
Diffstat (limited to 'changelog.md')
-rw-r--r-- | changelog.md | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md index 5056d7b3d..d98c34474 100644 --- a/changelog.md +++ b/changelog.md @@ -21,6 +21,13 @@ - `owner` in `std/macros` is deprecated. +- Ambiguous type symbols in generic procs and templates now generate symchoice nodes. + Previously; in templates they would error immediately at the template definition, + and in generic procs a type symbol would arbitrarily be captured, losing the + information of the other symbols. This means that generic code can now give + errors for ambiguous type symbols, and macros operating on generic proc AST + may encounter symchoice nodes instead of the arbitrarily resolved type symbol nodes. + ## Standard library additions and changes [//]: # "Changes:" |