Error compiling @rescript/core with Rescript 11

Hello! I was updating a project of mine to Rescript 11 and got this error:

[@jihchi/vite-plugin-rescript] rescript: [198/217] src/Core__List.cmj
FAILED: src/Core__List.cmj

  We've found a bug for you!
  /Users/matheus.ashton/dev/pessoal/pet-manager/node_modules/@rescript/core/src/Core__List.res:582:39
[@jihchi/vite-plugin-rescript]
  580 │     reduceReverseUnsafe(l, acc, f)
  581 │   } else {
  582 │     A.reduceReverseU(toArray(l), acc, f)
  583 │   }
  584 │ }

  This function is a curried function where an uncurried function is expected

Is weird because it’s complaining about the core package itself.

I’m using the following versions:
Rescript - 11.0.1
@rescript/react - 0.12.1
@rescript/core - 1.1.0

Any help?

There was a breaking change in the List API in 1.1.0. Align List api with other modules by cknitt · Pull Request #195 · rescript-association/rescript-core · GitHub. Sorry, it does not follow SemVer, it’s a bit special since it will land in the compiler itself at some point.
Maybe that led to your problem?

1 Like

But I’m not sure what do I have to do to be compliant with that breaking change, because versions above 1.0 should be compatible with Rescript 11 right? Should I downgrade it?

Or, even it shows the List module in the stack trace, the problem is actually in my code, on how I’m using the List module, and the fix should update those calls?

Well, can you create a minimal repro? I just created a dummy project with ReScript 11.0.1 and Core 1.1.0 and tried using List.reduceReverse but everything works fine. Both in curried and uncurried mode.

Did you try rescript clean and build again?

Given GitHub - jihchi/rescript-core-reducereversedu-uncurried: A minimal reproducible example illustrating the issue: https://forum.rescript-lang.org/t/error-compiling-rescript-core-with-rescript-11, the issue could be curried mode (uncurried is false in rescript.json)

Your example can be fixed by explicitly uncurrying:

Console.log("Hello, world!")

-Console.log(List.make(~length=1001, 1)->List.reduceReverse(0, (acc, item) => acc + item))
+Console.log(List.make(~length=1001, 1)->List.reduceReverse(0, (. acc, item) => acc + item))
1 Like