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

Compiler crashes when a module is named Js

Open shulhi opened this issue 1 year ago • 4 comments

It crashes with Not_found error.

To reproduce,

module Js = {
  let f = () => 1
}

let x = Js.f()

Playground, https://rescript-lang.org/try?version=v11.1.3&code=LYewJgrgNgpgBAKQM5wLxwN4Cg51gFzgDM04AKASjQD44BGLAXyywLgA9TkA6IyrIA

Instead of crashing, we should probably throw a better error that a module can't be named Js or something (since we already have Js module).

shulhi avatar Sep 04 '24 12:09 shulhi

a module can't be named Js or something (since we already have Js module).

Can't we...?

cometkim avatar Sep 05 '24 19:09 cometkim

a module can't be named Js or something (since we already have Js module).

Can't we...?

If I have a module named Map inside a module named A, doing open A will throw a warning that Map shadows the Map from Core. Maybe we should follow the same behavior?

shulhi avatar Sep 05 '24 23:09 shulhi

If I have a module named Map inside a module named A, doing open A will throw a warning that Map shadows the Map from Core. Maybe we should follow the same behavior?

Yes, I think so. And it should allow users to have their own Js bindings with/without opening Core in the future releases.

cometkim avatar Sep 06 '24 15:09 cometkim

This is fixed in V12.

shulhi avatar Sep 29 '25 11:09 shulhi