eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
398 stars 62 forks source link

Narrowing assertion lost outside try block #7419

Closed xkr47 closed 6 years ago

xkr47 commented 6 years ago

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 6 years ago

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 6 years ago

:bowing_man: