Problem of having expr is Pat(binding)
is always about the scoping of those bindings (referring to [Pre-Pre-RFC] Reviving Refutable Let [Runoff] - #9 by kennytm again)
The JEP you mentioned is pretty short but skims lots of details, like how to determine the scope of y
given x instanceof Type y
. The actual implementation touches translation involving quite a number of constructs (&&
, ||
, !
, ?:
, if
, while
, do while
, for
), and contained some tests like these which I won't call them "boring" .
// Test for (!e).T = e.F
if (!(!(o1 instanceof String s) || !(o3 instanceof Integer in))){
s.length();
i.intValue();
}
// Test for (e1 ? e2 : e3).F contains intersect(e1.T, e3.F)
if (o1 instanceof String s ? true : !(o1 instanceof String s)){
} else {
s.length();
}