emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.45k stars 4.21k forks source link

[Bug beta] angle bracket invocation incorrectly shadowed by local variable with different case #19334

Closed chancancode closed 3 years ago

chancancode commented 3 years ago
<div class="rentals">
  <ul class="results">
    {{#each @model as |rental|}}
      <li><Rental @rental={{rental}} /></li>
    {{/each}}
  </ul>
</div>

This template gives the following error:

Expected a dynamic component definition, but received an object or function that did not have a component manager associated with it. The dynamic invocation was `<(result of a `unknown` helper)>` or `{{(result of a `unknown` helper)}}`, and the incorrect definition is the value at the path `(result of a `unknown` helper)`, which was: Object

The issue is that <Rental ...> got incorrectly compiled into a symbol lookup with the same symbol ID as |rental|. In other words, the compiler treated the template as if it was this:

<div class="rentals">
  <ul class="results">
    {{#each @model as |rental|}}
      <li><rental @rental={{rental}} /></li>
    {{/each}}
  </ul>
</div>

Naming the local variable something else that doesn't "conflict" with a component name inside the block fixes the issue. For example, this works:

<div class="rentals">
  <ul class="results">
    {{#each @model as |property|}}
      <li><Rental @rental={{property}} /></li>
    {{/each}}
  </ul>
</div>
chancancode commented 3 years ago

This blocks 3.25.0 release cc @kategengler @rwjblue

pzuraq commented 3 years ago

Fix in the VM: https://github.com/glimmerjs/glimmer-vm/pull/1253

pzuraq commented 3 years ago

Reopening until the VM update is merged.