glimmerjs / glimmer-experimental

A set of experimental high-level APIs built on Glimmer.js
https://glimmerjs.github.io/glimmer-experimental/
58 stars 26 forks source link

Inconsistency between function and non-function scope binding #74

Open chriskrycho opened 4 years ago

chriskrycho commented 4 years ago

Expected: any value in scope is accessible in templates.

Actual: functions in scope are accessible (as modifiers or helpers), but other values are not.

Here's a minimal reproduction playground.

chiragpat commented 4 years ago

Hey Chris,

The expectation is only invokable's i.e. Components and helpers are retrieved from scope. We can potentially add some docs clarifying this. The VM currently only lets us resolve invokable's and not necessarily any free variables in scope.

Chirag

chriskrycho commented 4 years ago

Thanks for the quick reply! I think adding docs would help a bunch, and I can author a PR to that effect early next week if you like.

I also think we should look at making tweaks to the VM, though, because the behavior here is quite surprising—and I expect it will be particularly surprising for anyone coming from e.g. React.