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

mutable alias to function generates invalid curried application #3853

Open
joprice opened this issue Jun 16, 2024 · 0 comments
Open

mutable alias to function generates invalid curried application #3853

joprice opened this issue Jun 16, 2024 · 0 comments

Comments

@joprice
Copy link
Contributor

joprice commented Jun 16, 2024

Description

When calling a function via a mutable alias, the compiler incorrectly generates a curried application. The only workaround I found is to use an anonymous function with tupled arguments (see mutX4).

Repro code

let x a b c = a + b + c

let y = x
let mutable mutX1 = x
let mutable mutX2 = fun a b c -> x a b c
let mutable mutX3 = fun a b c -> y a b c
let mutable mutX4 = fun (a, b, c) -> y a b c
y 1 2 3 |> ignore
mutX1 1 2 3
mutX2 1 2 3
// this is the only version that produces valid code
mutX4 (1,2, 3)

Fable repl

Expected and actual results

The generated code is invalid, attempting to call functions with more arguments than they accept. The compiler should either fail and require the user to write out a tupled forwarding function (as is the case for attempting to define an explicit mutable function Mutable function values should be written 'let mutable f = (fun args -> ...)'), or ideally, the correct forwarding arguments are generated and no special handling is needed.

Related information

  • Fable version: 4.19.2
  • Operating system: OSX
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

1 participant