ReScript 11 untagged union seems to break for functions when uncurried is set to false

I noticed some code in rescript mui broke when I tried to update to rescript 11.

To reproduce, paste this code and set uncurried to false in bsconfig.json.

it will give this error:
This untagged variant definition is invalid: Case Func has a payload that is not of one of the recognized shapes (object, array, etc). Then it must be the only case with payloads.

type breakpoint =
  | Point(float)
  | Func(string => string)

let foo = (a: breakpoint) => {
  switch a {
  | Point(n) => Js.log(n)
  | Func(fn) => fn("foo")->Js.log

Is this a bug or am I doing something wrong here?

I can’t repro it in the playground, what version of rescript are you using? Functions were indeed not supported in untagged variants at first.

Edit: the playground is actually uncurried only in v11 so you can’t test this

I tested it locally and it only happens with rc4 or lower. In rc5 it is fixed already.

Oops, had uncurried set to true in my tests.

The solution would be to explicitly uncurry:

type breakpoint =
  | Point(float)
  | Func((. string) => string)

@cristianoc I guess uncurried libraries then cannot be used by curried consumers, or is this just a bug?

PR with fix: Fix issue where curried function was not supported with untagged vari… by cristianoc · Pull Request #6478 · rescript-lang/rescript-compiler · GitHub


Just migrated our project to 11, other than fixing a couple curried functions the biggest change is a removal of the Node. module. Had to go through and rewrite some some bindings.

It also looks like our bundle size dropped a few kb, which is great news for us!

index 8.73kb -> 6.85kb
main 28.31kb -> 23.59kb