[Bug] A yielded 'fn' from a component is incorrectly rendered as [object Object]
🐞 Describe the Bug
A yielded 'fn' from a component is incorrectly rendered as [object Object]
🔬 Minimal Reproduction
Inside a component I have this
{{yield
(hash
resourceExtruderCurrentTemperature=(fn ExtruderCurrentTemperature this.printerManager)
)
}}
I use the 'fn' helper to be able to add more positional arguments
😕 Actual Behavior
This renders [object Object]
<EmbeddedPrinterComponent @printer={{printer}} as |e|>
{{e.resourceExtruderCurrentTemperature true}}
</EmbeddedPrinterComponent>
🤔 Expected Behavior
Should render 3.5
<EmbeddedPrinterComponent @printer={{printer}} as |e|>
{{e.resourceExtruderCurrentTemperature true}}
</EmbeddedPrinterComponent>
🌍 Environment
ember-cli: 5.4.0 node: 18.18.0 os: darwin arm64 browser: chrome
➕ Additional Context
Using the let helper does render the expected output.
<EmbeddedPrinterComponent @printer={{printer}} as |e|>
{{#let (e.resourceExtruderCurrentTemperature true) as |value|}}{{value}}{{/let}}
</EmbeddedPrinterComponent>
@NullVoxPopuli suggested this might be a bug in 'fn', hence this report.
without digging in to fn, the reason why I think it could be a bug in fn is that these should be equiv:
{{#let (fn someFn 1) as |partiallyApplied|}}
{{ (partiallyApplied) }}
{{/let}}
and
{{ (someFn 1) }}
as long as fn goes through the helper-manager system, it doesn't matter what someFn is.
Here is a reproduction, showing that this happens with Resources... but even worse: errors with Classic Class and function helpers. With the classic constructs, we get an error saying that call isn't a function, which leads me to believe that we never implemented native helper-manager aware partial application, and only used JavaScript's built in .call behavior.
My hypothesis is that the helper and Helper from @ember/component/helper aren't compatible with fn because neither are functions.
I just remembered!!!
We have (helper) and (modifier) and (component) for partial application of those specific concepts.
So maybe the real question here is -- why do we have 4 ways to partially apply arguments? and can we get that down to 1?