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

Fixes Ember keyword shadowing #20782

Merged
merged 2 commits into from
Oct 23, 2024
Merged

Fixes Ember keyword shadowing #20782

merged 2 commits into from
Oct 23, 2024

Conversation

wycats
Copy link
Member

@wycats wycats commented Oct 22, 2024

This commit consistently fixes the interaction between keywords and lexical variables (JS or Handlebars) to match the specified behavior: keywords are always superseded by in-scope lexical variables.

Ember keywords are implemented as AST transformations, and there were two sources of bugs that made implementation of these keywords inconsistent with the specified behavior:

  1. In some cases, AST transforms applied to situations where the keyword in question was shadowed by a Handlebars block param. This means that the variable would be silently overridden by the AST transform.
  2. In all cases, AST transforms applied when the keyword was shadowed by a lexical variable (i.e. in-scope JS variable) of the same name. This isn't supposed to happen, as lexical JS variables are supposed to have the same rules as variables bound via JS block params.

This commit has tests for many of these cases. Some additional tests are forthcoming, mostly in cases where the transform in question wasn't tested at all before this change.

This commit consistently fixes the interaction between keywords and
lexical variables (JS or Handlebars) to match the specified behavior:
keywords are **always** superseded by in-scope lexical variables.

Ember keywords are implemented as AST transformations, and there were
two sources of bugs that made implementation of these keywords
inconsistent with the specified behavior:

1. In some cases, AST transforms applied to situations where the keyword
   in question was shadowed by a Handlebars block param. This means that
   the variable would be silently overridden by the AST transform.
2. In all cases, AST transforms applied when the keyword was shadowed by
   a lexical variable (i.e. in-scope JS variable) of the same name. This
   isn't supposed to happen, as lexical JS variables are supposed to
   have the same rules as variables bound via JS block params.

This commit has tests for many of these cases. Some additional tests are
forthcoming, mostly in cases where the transform in question wasn't
tested at all before this change.
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :shipit:

@ef4 ef4 merged commit 5557b11 into main Oct 23, 2024
24 checks passed
@ef4 ef4 deleted the bugfix/keyword-shadowing branch October 23, 2024 14:28
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.

3 participants