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

Cannot compose type conversion functions like int, double, etc via >> operator #798

Closed
johlrich opened this issue Apr 4, 2017 · 1 comment

Comments

@johlrich
Copy link
Contributor

johlrich commented Apr 4, 2017

Description

When using the >> operator you cannot compose functions such as int, double, etc. When you do this, fable will not generate the js Number.parseInt call. This causes a string to be passed to the next function.

As a workaround you can compose functions together without the >> operator to generate the parse call properly.

Repro code

Probably quickest to demonstrate this via the REPL. You'll notice apply does not have Number.parseInt call, but the others do.

http://fable.io/repl.html#?code=let%20apply%20%3A%20string%20-%3E%20Choice%3Cint%2C%20obj%3E%20%3D%20int%20%3E%3E%20Choice1Of2%0D%0Alet%20apply2%20%3A%20string%20-%3E%20Choice%3Cint%2C%20obj%3E%20%3D%20System.Int32.Parse%20%3E%3E%20Choice1Of2%0D%0Alet%20apply3%20%3A%20string%20-%3E%20Choice%3Cint%2C%20obj%3E%20%3D%20fun%20s%20-%3E%20int%20s%20%7C%3E%20Choice1Of2%0D%0A%0D%0A%0D%0A

Expected and actual results

Expected the string to be parsed into a number before being handed to the next function.

Actually passed the string, causing downstream fn errors at runtime.

Related information

  • fable-compiler version: 908
  • fable-core version: 908
  • Operating system: Windows
@johlrich
Copy link
Contributor Author

johlrich commented Apr 4, 2017

Failing test here: #799

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