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

Delegate parameter is invoked when it shouldn't be #3862

Closed
Preston159 opened this issue Jul 8, 2024 · 7 comments
Closed

Delegate parameter is invoked when it shouldn't be #3862

Preston159 opened this issue Jul 8, 2024 · 7 comments

Comments

@Preston159
Copy link

Description

When a function takes another function as a parameter, which in turn takes a function as a parameter, and attempts to call that function by passing in a function, Fable incorrectly calls the innermost function and passes in its return value rather than passing the function itself.

Repro code

REPL

Expected and actual results

Expected console output

  • del is a function
  • testFunc called

Actual console output

  • testFunc called
  • del is undefined
  • Uncaught TypeError: del is not a function

Related information

  • Fable version: 4.19.3
  • Operating system: Windows 11 Pro 22631.3737
@ncave
Copy link
Collaborator

ncave commented Jul 8, 2024

@Preston159 This seems to only affect delegates, as changing the type from

type DelegateType = delegate of unit -> unit

to

type DelegateType = unit -> unit

, and the call site from del.Invoke () to del () works as expected.

Not a fix, obviously, just a workaround if using delegates is not critical.

@ncave ncave changed the title Function parameter is invoked when it shouldn't be Delegate parameter is invoked when it shouldn't be Jul 8, 2024
ncave added a commit to ncave/Fable that referenced this issue Jul 10, 2024
ncave added a commit to ncave/Fable that referenced this issue Jul 10, 2024
@ncave ncave mentioned this issue Jul 10, 2024
@ncave ncave closed this as completed in 3b30f5b Jul 10, 2024
@ncave
Copy link
Collaborator

ncave commented Jul 10, 2024

@Preston159 Thanks for reporting the issue, should be resolved in the next release.

@Preston159
Copy link
Author

@ncave Happy to help. Thanks for the quick resolution, both the workaround and the fix!

@OnurGumus
Copy link

I think this change caused some regressions. Trying to come up with a repro case.

@OnurGumus
Copy link

@ncave

@ncave
Copy link
Collaborator

ncave commented Oct 1, 2024

@OnurGumus Perhaps, let me know if you can find an example. The original code was done to resolve #2400.

@OnurGumus
Copy link

@ncave Hi,
I reproduced the problem with minimal example and created issue. It's not related to this bug I think.

#3915

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

3 participants