Fable: System.Char.MinValue .. System.Char.MaxValue range

Created on 16 Dec 2020  路  7Comments  路  Source: fable-compiler/Fable

https://github.com/lfr/fable-compiler-validation-blocks

Expected and actual results

This is a slightly modified Fable new project app, but it never finishes loading

Related information

  • Fable version: 2.13.0
  • Framework: net5.0
  • Windows

Most helpful comment

Got a fix at #2319.

All 7 comments

Turns out this was the problem:

[System.Char.MinValue .. System.Char.MaxValue]

And this was the fix:

[int System.Char.MinValue .. int System.Char.MaxValue]

Hmm, char ranges should be supported, but it seems System.Char.MinValue / System.Char.MaxValue don't compile correctly. I'll reopen the issue :+1:

For me it would be more important to understand how I can debug these issues as I literally had to dismantle the code chunk by chunk until it worked again, which was quite laborious. Is there a quicker way to pinpoint such issues?

System.Char.{Min|Max}Value do compile, but it seems that creating a range from them needs a large amount of memory. Firefox shows a warning about the website slowing down the browser with this snippet in the REPL:

let chars = [System.Char.MinValue..System.Char.MaxValue]
chars |> List.length |> System.Console.WriteLine

Got a fix at #2319.

Awesome @inosik, thanks a lot for this!

@lfr Yes, unfortunately _unexpected_ issues may be hard to debug. If it's something expected usually we try to emit a warning/error from Fable or at runtime in JS, but if it's something unforeseen it can be tricky. I usually first take a look at the generated JS to see if there's anything strange and then stop the debugger at points to see if the in-memory values are what you would expect (in F# code I usually add assert false for that, but you can also add breakpoints in the generated JS), or try to isolate the part of the code that misbehaves and run it in the REP (or in Quicktest.fs within this repository). But it's true that sometimes it may take a while until identifying the problem 馃槙

Ok, the main problem here is that I'm not a web dev so I just lack the experience to do advanced debugging, in any case even if it took me longer than it would've taken someone more familiar with the browser's dev tools, I'm glad I was still able to pinpoint the root cause to help you weed out this one.

Was this page helpful?
0 / 5 - 0 ratings