Expand description
Which is tests an expression proves. #1654 (runtime-semantics track S5,
Decision A): the one structural rule the resolver, the checker and the
emitter all read, so their views of an is binding’s scope cannot drift.
An e is P test with bindings brings those bindings into scope wherever the
test is known to have matched. Given a Boolean expression and whether it
evaluated to true or false, matched_is_tests returns the is tests
that must then have matched:
| expression | when true | when false |
|---|---|---|
e is P | the test | — |
a && b | a when true, b when true | — (either may have failed) |
a || b | — (either may have held) | a when false, b when false |
!e | e when false | e when true |
a implies b | — (!a || b) | a when true, b when false |
(e) | e | e |
The consumers apply it at these scopes:
- an
if’s then-branch: its condition when true; - an
if’s else-branch: its condition when false (if !(o is Some(v)) { … } else { v }, type-system §2.3.6); - the right operand of
&&andimplies: the left operand when true, since the right is evaluated only then.
The right operand of || (the left operand when false) is not scoped in
this slice: nothing lowers it with bindings yet, and a scope the checker
accepts must be one the emitter lowers.
Functions§
- matched_
is_ tests - The
istests (ExprKind::Isnodes) thatexprproves matched when it evaluates towhen_true, in source order.