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

Syntax: E notation check is missing

Open cometkim opened this issue 1 year ago • 5 comments

let v = 1e

emits

var v = 1e;

export {
  v ,
}

which is invalid in JS.

cometkim avatar Aug 28 '24 14:08 cometkim

Same for

let v = 1e_

(or similar with any number of underscores)

cknitt avatar Sep 05 '24 18:09 cknitt

BTW, also a bit weird (but all valid JS):

ReScript      JS
let v = 1     let v = 1;
let v = 1.    let v = 1;
let v = 1._   let v = 1.;
let v = 1.0   let v = 1.0;

cknitt avatar Sep 05 '24 18:09 cknitt

BTW, also a bit weird (but all valid JS):

ReScript      JS
let v = 1     let v = 1;
let v = 1.    let v = 1;
let v = 1._   let v = 1.;
let v = 1.0   let v = 1.0;

I think the correct resolution is

let v = 1
let v = 1.0
// syntax error
let v = 1.0

cometkim avatar Sep 05 '24 19:09 cometkim

Agreed!

Also, at the moment, you can basically do whatever you want underscore-wise, e.g.

let x = 1_________0_______.____2_____3

compiles to

let x = 10.23;

(FWIW this seems to be the case in OCaml, too.)

cknitt avatar Sep 06 '24 13:09 cknitt

Lol, that's how we supported (superset of?) JS numeric separators

cometkim avatar Sep 06 '24 14:09 cometkim