rescript-lang / rescript

ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript.
https://rescript-lang.org
Other
6.76k stars 453 forks source link

Raising exceptions can generate invalid JavaScript #5924

Open mxthevs opened 1 year ago

mxthevs commented 1 year ago

The following code:

let x = raise(Not_found)

Compiles to the following JavaScript:

// Generated by ReScript, PLEASE EDIT WITH CARE

throw {
      RE_EXN_ID: "Not_found",
      Error: new Error()
    };

export {
  x ,
}
/* x Not a pure module */

Which exports a variable x that does not exist on the final output.

cristianoc commented 1 year ago

This happens for toplevel code that raises exceptions. The export part of the code is not reached.

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

glennsl commented 2 months ago

Still reproducible in 11.1.4 and 12.0.0-alpha.3