Appearance
| 1 | namespace Syntax.Process is | |
| 2 | use Semantic.Types.Type | |
| 3 | ||
| 4 | // Rules for a statement used where a value is wanted whose only exits | |
| 5 | // diverge — `throw`, or an `if`/`case`/`val` whose every arm diverges. | |
| 6 | // Such a statement produces no value, but the continuation after it is | |
| 7 | // unreachable and needs none, so a value-requiring context must not | |
| 8 | // treat the absent value as an error. | |
| 9 | class DIVERGING_VALUE_POSITION is | |
| 10 | // True when a value-wanting position should report its statement | |
| 11 | // having produced no value: it wants one, none was produced, and | |
| 12 | // control actually reaches the continuation. A diverging statement | |
| 13 | // makes that continuation unreachable, so the value is legitimately | |
| 14 | // absent and nothing should be reported. | |
| 15 | is_missing_value_reportable(want_value: bool, has_value: bool, is_unreachable: bool) -> bool static => | |
| 16 | want_value /\ !has_value /\ !is_unreachable | |
| 17 | ||
| 18 | // True when a diverging expression body (`=> throw E`, or an | |
| 19 | // `=> if/case` whose arms all diverge) should adopt void as its | |
| 20 | // return type. A return type the user declared — any settled type — | |
| 21 | // is kept; only an unsettled one (absent, or still carrying an | |
| 22 | // inference placeholder) is replaced, since the body yields nothing | |
| 23 | // to infer from. A type parameter (`-> T`) is settled, not wild: | |
| 24 | // `is_wild` answers true for one, but that is its overload-resolution | |
| 25 | // soft-match meaning, not "unsettled". | |
| 26 | settles_inferred_return_to_void(return_type: Type?) -> bool static => | |
| 27 | !return_type? \/ return_type.contains_inferred | |
| 28 | si | |
| 29 | si |