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

[Bug] A yielded 'fn' from a component is incorrectly rendered as [object Object] #20589

Open
basz opened this issue Dec 8, 2023 · 4 comments

Comments

@basz
Copy link

basz commented Dec 8, 2023

🐞 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.

@NullVoxPopuli
Copy link
Sponsor Contributor

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.

@NullVoxPopuli
Copy link
Sponsor Contributor

NullVoxPopuli commented Dec 8, 2023

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.

@NullVoxPopuli
Copy link
Sponsor Contributor

I just remembered!!!

We have (helper) and (modifier) and (component) for partial application of those specific concepts.

Here is the above reproduction, fixed, by using (helper)

@NullVoxPopuli
Copy link
Sponsor Contributor

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?

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

No branches or pull requests

2 participants