fable-compiler / Fable

F# to JavaScript, TypeScript, Python, Rust and Dart Compiler
http://fable.io/
MIT License
2.85k stars 296 forks source link

FSharpPlus trySscanf throws #3291

Open hesxenon opened 1 year ago

hesxenon commented 1 year ago

Description

When using FSharpPlus.Parsing.trySscanf with a string that does not match an error is thrown.

I'm opening this issue here and not in the FSharpPlus Project because the error is thrown deep down in FSharp.Core.js and the behaviour goes strictly against the documentation of trySscanf which is why I currently think it's more of a combination between Fable and FSharpPlus that leads to wrong generated JS code.

Repro code

"test" |> FSharpPlus.Parsing.trySscanf "test/%d" |> Fable.Core.JS.console.log

Expected and actual results

Should log a None but instead throws

FSharp.Core.js:48 Uncaught Error: source
    at Operators_NullArg (FSharp.Core.js:48:12)
    at checkNonNull (Seq.js:326:9)
    at ofSeq2 (Seq.js:335:5)
    at Enumerator_Seq.f (Seq.js:1187:19)
    at Enumerator_Seq.GetEnumerator (Seq.js:65:18)
    at getEnumerator (Util.js:56:13)
    at ofSeq2 (Seq.js:336:12)
    at Seq.js:919:27
    at Enumerator_generateWhileSome (Seq.js:234:22)
    at Enumerator_Seq.f (Seq.js:389:24)

Related information

hesxenon commented 1 year ago

I think it might be related to fsprojects/FSharpPlus#395?

gusty commented 1 year ago

I don't think it's related to that one, actually we already addressed most of that issue and we'll close it.

This seems to be another oddity with Fable type resolution which is unfortunate but I don't know if it's easy to solve as fable depends on the F# compiler which seems to have some bugs.