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
Fable unable to resolve function parameter passed into another function that returns Async<unit> #1900
Comments
Hmm, I tried your code in the REPL and it's working 😕 Can you please delete node_modules just in case and install again to make sure you are using latest fable-compiler version? |
I did a fresh build and run from the repo and another from the local one after removing git clone https://github.com/Zaid-Ajaj/AsyncUnitBug.git
cd AsyncUnitBug
fake build -t run |
Wow, it does fail indeed. First something something works in the REPL but not with fable-compiler ;) |
I know right?! at first I was guessing it has something to do with the fact the project has multiple files and the fact that we are using nested modules (i.e. the let doSomething = fun (n: int) -> async {
do! Async.Sleep 1000
printf "%s" (n.ToString())
return ()
}
let update (msg : Msg) (model : Model) : Model * Cmd<Msg> =
match msg with
| DoSomething x ->
{ Message = "Doing something..." },
Cmd.OfAsync.either doSomething 3000 (fun _ -> DidSomething) Error
| DidSomething ->
{ Message = "Success!"}, Cmd.none
| Error e->
{ Message = sprintf "Error: %O" e}, Cmd.none |
Description
Here I have got a really weird issue in an Elmish application used in SAFE stack, I broke it down to the following repro:
When the message
DoSomething
is dispatched from the user interface, you would expect to see "3000" printed in the console but instead the valuenull
is passed toServer.api.doSomething
, this is determined in compile time, if I usefable-splitter
to compile the code, I get the following:You can see the error that occurs in the UI:
Now make the simple change by changing the return type of
Server.api.doSomething
to anything else such asAsync<string>
:Now the application works as expected and does not throw:
It must be something that has to do with
Async<unit>
as the return type, hence the name of the issueRepro code
See this repo
This was originally a bug in Fable.Remoting/#135 but it seems to be a Fable specific bug
Related information
Latest of everything
fable-compiler version: 2.3.24
fable-loader: 2.1.8
Fable splitter: 2.1.11
Operating system: Windows 10
The text was updated successfully, but these errors were encountered: