Open
Description
Given an unboxed variant like this, Primary
has the same runtime representation as Color("primary")
@unboxed
type color =
| @as("primary") Primary
| @as("secondary") Secondary
| Color(string)
This means that a function like
let f = x =>
switch x {
| Color(x) => x
| _ => "not Color"
}
somewhat surprisingly produces "not Color"
when called on Color("primary")
.
However, the optimizer treats this like a regular variant and so constant folding f(Color("primary"))
produces "primary"
, which differs from the result of the generated JS.
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog