Skip to content
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

don't transform typed bracket exprs to [] calls in templates #23175

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Jan 6, 2024

fixes #22775

It's pre-existing that prepareOperand doesn't typecheck expressions which have types. Templates can take typed subscript expressions, transform them into calls to [], and then have this [] not be resolved later if the expression is nested inside of a call argument, which leaks an untyped expression past semantic analysis. To prevent this, don't transform any typed subscript expressions into calls to [] in templates. Ditto for curly subscripts (with {}) and assignments to subscripts and curly subscripts (with []= and {}=).

@Araq Araq merged commit 62d8ca4 into nim-lang:devel Jan 7, 2024
19 checks passed
Copy link
Contributor

github-actions bot commented Jan 7, 2024

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 62d8ca4

Hint: mm: orc; opt: speed; options: -d:release
177665 lines; 7.719s; 768.125MiB peakmem

narimiran pushed a commit that referenced this pull request Apr 19, 2024
fixes #22775

It's pre-existing that [`prepareOperand` doesn't typecheck expressions
which have
types](https://github.com/nim-lang/Nim/blob/a4f3bf374238df96f0982b7106e3702da6b485b1/compiler/sigmatch.nim#L2444).
Templates can take typed subscript expressions, transform them into
calls to `[]`, and then have this `[]` not be resolved later if the
expression is nested inside of a call argument, which leaks an untyped
expression past semantic analysis. To prevent this, don't transform any
typed subscript expressions into calls to `[]` in templates. Ditto for
curly subscripts (with `{}`) and assignments to subscripts and curly
subscripts (with `[]=` and `{}=`).

(cherry picked from commit 62d8ca4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

internal error: cannot inject destructors to node kind: nkOpenSymChoice with nested templates
2 participants