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

Fix nested calls to helpers in dynamic helpers #1293

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

pzuraq
Copy link
Member

@pzuraq pzuraq commented Apr 1, 2021

Currently, nested calls to helpers in dynamic helpers cause problems
because the nested helper overwrites the register that we were using to
pass along the helper definition. This is actually a worse way of doing
something that the Dup opcode is designed to do anyways, so I updated
to do that, following the same pattern in DynamicModifiers. Added tests
for both dynamic helpers and modifiers with nested helpers.

Original issue: tracked-tools/ember-could-get-used-to-this#41

Currently, nested calls to helpers in dynamic helpers cause problems
because the nested helper overwrites the register that we were using to
pass along the helper definition. This is actually a worse way of doing
something that the `Dup` opcode is designed to do anyways, so I updated
to do that, following the same pattern in DynamicModifiers. Added tests
for both dynamic helpers and modifiers with nested helpers.
@rwjblue rwjblue added the bug label Apr 1, 2021
@chancancode chancancode merged commit a3091ee into master Apr 15, 2021
@chancancode chancancode deleted the bugfix/nested-dynamic-helper-calls branch April 15, 2021 07:36
chancancode added a commit to emberjs/ember.js that referenced this pull request Apr 20, 2021
Per [RFC 496](https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#3-no-implicit-invocation-of-argument-less-helpers),
this commit deprecates the implicit invocation of argument-less
helpers and requires explicit parenthesis if:

1. Non-strict mode, AND
2. `helper` is a free variable (not `this.helper`, `@helper` or
   a local variable), AND
3. No arguments are provided to the helper, AND
4. It's in a component invocation's named argument position (not
   `<div id={{helper}}>` or `<Foo bar={{helper}}>`), AND
5. Not parenthesized (not `@foo={{(helper)}}`), AND
6. Not interpolated (not `@foo="{{helper}}"`).

The cases in real apps where all of the above are true should be
quite rare, as most helpers take at least one argument.

This is probably not the most efficient/minimal changes to the
compiler infrastructure, but I chose to optimize for making the
change easier to remove/rollback (i.e. adding new nodes instead
of changing existing ones) as we won't be needing this for very
long.

This also bumps `@glimmer/*` to latest which also brings in the
bugfix commit glimmerjs/glimmer-vm#1293.
chancancode added a commit to emberjs/ember.js that referenced this pull request Apr 21, 2021
Per [RFC 496](https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#3-no-implicit-invocation-of-argument-less-helpers),
this commit deprecates the implicit invocation of argument-less
helpers and requires explicit parenthesis if:

1. Non-strict mode, AND
2. `helper` is a free variable (not `this.helper`, `@helper` or
   a local variable), AND
3. No arguments are provided to the helper, AND
4. It's in a component invocation's named argument position (not
   `<div id={{helper}}>` or `<Foo bar={{helper}}>`), AND
5. Not parenthesized (not `@foo={{(helper)}}`), AND
6. Not interpolated (not `@foo="{{helper}}"`).

The cases in real apps where all of the above are true should be
quite rare, as most helpers take at least one argument.

This is probably not the most efficient/minimal changes to the
compiler infrastructure, but I chose to optimize for making the
change easier to remove/rollback (i.e. adding new nodes instead
of changing existing ones) as we won't be needing this for very
long.

This also bumps `@glimmer/*` to latest which also brings in the
bugfix commit glimmerjs/glimmer-vm#1293.
chancancode added a commit to emberjs/ember.js that referenced this pull request Apr 21, 2021
Per [RFC 496](https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#3-no-implicit-invocation-of-argument-less-helpers),
this commit deprecates the implicit invocation of argument-less
helpers and requires explicit parenthesis if:

1. Non-strict mode, AND
2. `helper` is a free variable (not `this.helper`, `@helper` or
   a local variable), AND
3. No arguments are provided to the helper, AND
4. It's in a component invocation's named argument position (not
   `<div id={{helper}}>` or `<Foo bar={{helper}}>`), AND
5. Not parenthesized (not `@foo={{(helper)}}`), AND
6. Not interpolated (not `@foo="{{helper}}"`).

The cases in real apps where all of the above are true should be
quite rare, as most helpers take at least one argument.

This is probably not the most efficient/minimal changes to the
compiler infrastructure, but I chose to optimize for making the
change easier to remove/rollback (i.e. adding new nodes instead
of changing existing ones) as we won't be needing this for very
long.

This also bumps `@glimmer/*` to latest which also brings in the
bugfix commit glimmerjs/glimmer-vm#1293.
chancancode added a commit that referenced this pull request Apr 22, 2021
Before #1293, the `Load` operation would have popped the helper
definition off of the evalution stack. After the #1293, nothing is
popping it off anymore and that creates problem downstream.

This balances things out by inserting a `Pop(1)` in the original
frame.

I couldn't think of a good way to test this, and this is blocking
Ember beta, so we will merge this now (Ember has a test confirming
this works) and @pzuraq will add a test later.
chancancode added a commit that referenced this pull request Apr 22, 2021
Fix evaluation stack off-by-one error introduced in #1293
chancancode added a commit to emberjs/ember.js that referenced this pull request Apr 22, 2021
Per [RFC 496](https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#3-no-implicit-invocation-of-argument-less-helpers),
this commit deprecates the implicit invocation of argument-less
helpers and requires explicit parenthesis if:

1. Non-strict mode, AND
2. `helper` is a free variable (not `this.helper`, `@helper` or
   a local variable), AND
3. No arguments are provided to the helper, AND
4. It's in a component invocation's named argument position (not
   `<div id={{helper}}>` or `<Foo bar={{helper}}>`), AND
5. Not parenthesized (not `@foo={{(helper)}}`), AND
6. Not interpolated (not `@foo="{{helper}}"`).

The cases in real apps where all of the above are true should be
quite rare, as most helpers take at least one argument.

This is probably not the most efficient/minimal changes to the
compiler infrastructure, but I chose to optimize for making the
change easier to remove/rollback (i.e. adding new nodes instead
of changing existing ones) as we won't be needing this for very
long.

This also bumps `@glimmer/*` to latest which also brings in the
bugfix commit glimmerjs/glimmer-vm#1293.
chancancode added a commit to emberjs/ember.js that referenced this pull request Apr 22, 2021
Per [RFC 496](https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#3-no-implicit-invocation-of-argument-less-helpers),
this commit deprecates the implicit invocation of argument-less
helpers and requires explicit parenthesis if:

1. Non-strict mode, AND
2. `helper` is a free variable (not `this.helper`, `@helper` or
   a local variable), AND
3. No arguments are provided to the helper, AND
4. It's in a component invocation's named argument position (not
   `<div id={{helper}}>` or `<Foo bar={{helper}}>`), AND
5. Not parenthesized (not `@foo={{(helper)}}`), AND
6. Not interpolated (not `@foo="{{helper}}"`).

The cases in real apps where all of the above are true should be
quite rare, as most helpers take at least one argument.

This is probably not the most efficient/minimal changes to the
compiler infrastructure, but I chose to optimize for making the
change easier to remove/rollback (i.e. adding new nodes instead
of changing existing ones) as we won't be needing this for very
long.

This also bumps `@glimmer/*` to latest which also brings in the
bugfix commit glimmerjs/glimmer-vm#1293.

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

Successfully merging this pull request may close these issues.

4 participants