You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a simple function with an unused variable that creates a list (playground link):
let f xs =
let unused =
match xs with
| Some (l) -> [l; l]
| None -> [1; 2]
in
Js.log2 "nothing to see here" xs
In the generated JS, the variable is removed completely:
function f(xs) {
console.log("nothing to see here", xs);
}
However, if this unused variable has a side effect, the list is created but never assigned to a variable. JS arrays are allowed on lines by themselves (a weird edge case of the syntax, I guess) but objects are not.
Here's a simple function with an unused variable that creates a list (playground link):
In the generated JS, the variable is removed completely:
However, if this unused variable has a side effect, the list is created but never assigned to a variable. JS arrays are allowed on lines by themselves (a weird edge case of the syntax, I guess) but objects are not.
Function with a side effect (playground link):
v7 generates:
Which is weird, but valid and works.
v8 generates:
Which triggers
SyntaxError: Unexpected token
on thetl: {
line.The text was updated successfully, but these errors were encountered: