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
{{ message }}
Repository navigation
Some(U) of an @as(undefined) case compiles to undefined when U is a constant #8954
Some(U), where U is an @as(undefined) case of an untagged variant, compiles to undefined when U is a constant argument, so it equals None.
@unboxedtypeu= | @as(undefined) U | V(string)
letx: option<u> =Some(U) // compiles to: let x = undefined;
@inline(never) letmk= (v: u): option<u> =>Some(v)
Console.log2(x==None, mk(U) ==None)
Output: true false. Through a function, Some(U) is boxed and differs from None; as a constant, it is undefined.
Expected: Some(U) differs from None in both cases. This is the example of #6222, which made option unboxing compatible with untagged variants.
A likely place is compiler/ml/lambda.ml, const_some_none_depth, which treats every Const_constructor as not none, including one whose literal is undefined. This cause is not confirmed. The rule is compiler/ml/UntaggedVariants.md rule 12, in #8952.
Activity