On Monday, 30 January 2012 at 19:25:03 UTC, Jesse Phillips wrote:
On Monday, 30 January 2012 at 18:23:56 UTC, Era Scarecrow wrote:
try {
} catch (Throwable t) {

} catch {Exception e) { //never executed

} catch (StreamException st) { //never executed

} //and the list can go on forever.

See the problem?

No?

Error: catch at test.d(3) hides catch at test.d(4)

The compiler does not reorder the exceptions because it enforces order in the written code. As you say the compiler knows the relationship, the one reading it may not.

So long as it errors from the hiding (as it appears it does) then it's fine, and the previous example shown was wrong.

try {}
catch (Exception e) {} // most throwable objects derive from Exception catch (SpecialException e) {} // never used, because Exception matches it all

Reply via email to