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

So there indeed issues with ReScript 11.0.1 and Core 1.1.0? Is really needed to modify the file in node_modules?

I’m having this issue in 2 different projects that were using rescript 10.1.4 and I upgrade them to rescript 11.1.0 :frowning: don’t know what is going on

@jihchi I’m using your starter template and your vite plugin, the uncurried is false like here: vitejs-template-react-rescript/rescript.json at 24450dea0f8752d5f828f918f0b8b9f5e644775c · jihchi/vitejs-template-react-rescript · GitHub

@fham the issue is that I don’t have this call directly in my code, is something with the Core or some other library that may be using this function.

@ashton As @fham suggested, it would be helpful for troubleshooting if you can create a minimal repo.

1 Like

Same Issue happened here: ReScript 11.1 uncurried issue with core package?
In that case it was rescript-classnames.

This situation isn’t great obviously. v12 will have Core inside of the compiler itself so the problem will go away, but we should do what we can to clear up the situation before too. Suggestions welcome.

1 Like

@jihchi oh sorry, I misunderstood, I thought that the repo you posted was exactly the minimal example. The main point is, with a fresh installation, I can’t reproduce the issue, so it’s something related to my code or one of the libraries I’m using, what makes difficult to create something “minimal”

Based on this post I tried to figure out if some other library was using some old version of rescript core, but it doesn’t be the case:

⋯/rsus on  main [✘!?] via  v18.20.2 took 836ms
❯ npm ls --all | grep "rescript/core"
├─┬ @rescript/core@1.3.0
│ ├─┬ @rescript/core@1.3.0
⋯/rsus on  main [✘!?] via  v18.20.2 took 921ms
❯ npm ls --all | grep "rescript"
vite-react-rescript-starter@1.0.0 /Users/matheus.ashton/dev/pessoal/rsus
├── @glennsl/rescript-fetch@0.2.0
├─┬ @jihchi/vite-plugin-rescript@6.0.0
│ ├── rescript@11.1.0 deduped
├─┬ @rescript/core@1.3.0
│ └── rescript@11.1.0 deduped
├─┬ @rescript/react@0.12.1
├─┬ rescript-auth0-react@1.0.0 -> ./../rescript-auth0-react
│ ├─┬ @rescript/core@1.3.0
│ │ └── rescript@11.1.0 deduped
│ ├─┬ @rescript/react@0.12.1
│ └── rescript@11.1.0
├─┬ rescript-vitest@1.4.0
│ ├── rescript@11.1.0 deduped
├── rescript-webapi@0.9.1
├── rescript@11.1.0

Everything seems to be using Rescript 11.1 and @rescript/core 1.3.0

Is v12 close to release?

No, it will take some time until v12 releases. There will probably be a alpha version in the first half of the year though.

What do you get from npm explain @rescript/core ?

@rescript/core@1.3.0
node_modules/@rescript/core
  @rescript/core@"^1.3.0" from the root project

@rescript/core@1.3.0
../rescript-auth0-react/node_modules/@rescript/core
  @rescript/core@"1.3.0" from rescript-auth0-react@1.0.0
  ../rescript-auth0-react
    rescript-auth0-react@1.0.0
    node_modules/rescript-auth0-react
      rescript-auth0-react@"^1.0.0" from the root project

that’s your own library that you link locally or something? Because I only see older versions of it published on npm.

1 Like

Yes, is my own library, I’m installing locally it with npm link