FileException Inconsistency?

Steven Schveighoffer schveiguy at gmail.com
Wed May 13 01:44:22 UTC 2026


On Wednesday, 13 May 2026 at 01:23:38 UTC, Alex wrote:

> If the writelns are uncommented out, get a FileException 
> correctly as before.

So what I've been using is a feature of the compiler that prints 
out a string representation of the AST. This is the `-vcg-ast` 
switch.

Looking at that, the catch clauses for `FileException` and 
`Exception` are missing when `writeln` is in the loop.

I have also discovered that it's not specific to writeln, and 
that *any* throwing (or possibly throwing) function will do.

For example:

```d
void foo() {} // not nothrow
void fooNothrow() nothrow {}

// this will catch the FileException:
         try
         {
             foo();
             if (entry.isDir)
                 scan(entry.name);
         }

// this will catch the Throwable:
         try
         {
             fooNothrow();
             if (entry.isDir)
                 scan(entry.name);
         }

```

Clearly, the compiler is misjudging this code as nothrow.

I think I can get a small reproducible example that does not need 
all the extra complication. But need some time to narrow it down.

-Steve


More information about the Digitalmars-d-learn mailing list