Should masked exceptions be an error?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Tue Nov 24 01:38:47 PST 2009


Andrei Alexandrescu wrote:
> Consider:
> 
> try {
>    ...
> } catch (Exception) {
>    ...
> } catch (StdioException) {
>    ...
> }
> 
> The second handler never matches because StdioException is a subclass of 
> Exception, so the first handler will always match whatever the second 
> matches.
> 
> Should that be a compile-time error? I think so.
> 
> 
> Andrei


Definitely. I think the spec should state as a general rule that 
unreachable code is an error. Then more such checks can be added to DMD 
even after D2 is declared stable.

-Lars



More information about the Digitalmars-d mailing list