rescript-compiler
rescript-compiler copied to clipboard
`String.length` not inlined in v10
This:
let stringLengthNoSideEffects = String.length("sdkdl")
now produces
var stringLengthNoSideEffects = "sdkdl".length;
while it used to be
var stringLengthNoSideEffects = 5;
This is because the parser now sends strings as unicode, and the compiler does not have a length function that matches the one of JS (utf16 code units).
Otherwise it could compute it at compile time in string_length inside js_exp_make.ml.
The parser might already have such a function and if so one could hook it up to the compiler.