rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

js_dump.ml build error when using `String(string)` variant in untagged union with other tag

Open ryyppy opened this issue 2 years ago • 2 comments

Version: 11.0.0-rc.6

Create a file Foo.res with the following content:

@unboxed
type href = String(string) | Number(int)

// This works
let href = Number(1);

/**
This doesn't compile.

Fatal error: exception File "jscomp/core/js_dump.ml", line 828, characters 29-35: Assertion failed
FAILED: cannot make progress due to previous errors.
*/
let href2 = String("test");

Some observations:

  • The issue doesn't appear to be coupled to String(). If I define a type Number(int) | Object({foo: string}), the same issue is observed
  • The example above will actually compile correctly in the playground.

ryyppy avatar Nov 27 '23 07:11 ryyppy

I can't seem to reproduce this, trying with both rc6 and current master.

zth avatar Nov 27 '23 08:11 zth

I noticed this issue only occurs when the following configuration is set in rescript.json:

{
  "bsc-flags": ["-bs-g"],
}

For what I know, the bs-g flag has been superfluous for quite some time now... is there still any reason we need that one?

UPDATE: After internal discussions, it is indeed a flag that's worth deprecating, so created #6496 to keep track of this.

ryyppy avatar Nov 27 '23 08:11 ryyppy