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

Raising exceptions can generate invalid JavaScript

Open mxthevs opened this issue 2 years ago • 4 comments

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.

mxthevs avatar Jan 02 '23 19:01 mxthevs

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

cristianoc avatar Jan 05 '23 10:01 cristianoc

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.

github-actions[bot] avatar Sep 26 '24 02:09 github-actions[bot]

Still reproducible in 11.1.4 and 12.0.0-alpha.3

glennsl avatar Sep 26 '24 11:09 glennsl

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.

github-actions[bot] avatar Sep 22 '25 02:09 github-actions[bot]