Narrowing assertion lost outside try block
Closed this issue · 2 comments
xkr47 commented
This example fails on the String y = x;
line with the error that x is String?
:
value x = "" of String?;
try {
assert (exists x);
} catch(e) {
throw Exception("Noo", e);
}
String y = x;
print(y);
Since the catch
block never exits normally, I would have thought the code block below should inherit the narrowing actions of the try block?
gavinking commented
Nono, the effect of narrowing is always limited to the block to which the assert
statement belongs. And I definitely don't want to change that.
xkr47 commented
🙇♂️