Thanks for trying to reproduce the error, though it is genuine.

I just literally created a fresh Visual Studio Project on Windows with the copied text. Here is the unmodified code running, with writelns.


```
DirScan

Compiler: Digital Mars D v2.110
-----
PATH: C:\
C:\$Recycle.Bin
.
-----
PATH: C:\$Recycle.Bin
C:\$Recycle.Bin\S-1-5-18
.
-----
PATH: C:\$Recycle.Bin\S-1-5-18
File Exception: std.file.FileException@std\file.d(4683): C:\$Recycle.Bin\S-1-5-18: Access is denied.
----------------
0x00007FF77A617997 in d_throwc
0x00007FF77A630B75 in @safe bool std.file.cenforce!(bool).cenforce(bool, scope lazy const(char)[], immutable(char)[], ulong) 0x00007FF77A61E506 in @safe bool std.file.DirIteratorImpl.stepIn(immutable(char)[]) 0x00007FF77A6105EC in std.file.DirIteratorImpl.__ctor!string.this at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\file.d(4809) 0x00007FF77A610ACB in core.internal.lifetime.emplaceRef!(std.file.DirIteratorImpl, std.file.DirIteratorImpl, string, std.file.SpanMode, bool).emplaceRef.S.__ctor!().this at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\internal\lifetime.d(38) 0x00007FF77A6102BC in core.internal.lifetime.emplaceRef!(std.file.DirIteratorImpl, std.file.DirIteratorImpl, string, std.file.SpanMode, bool).emplaceRef at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\internal\lifetime.d(57) 0x00007FF77A61024D in core.lifetime.emplace!(std.file.DirIteratorImpl, string, std.file.SpanMode, bool).emplace at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\lifetime.d(64) 0x00007FF77A610137 in std.typecons.SafeRefCounted!(std.file.DirIteratorImpl, RefCountedAutoInitialize.no).SafeRefCounted.RefCountedStore.initialize!(string, std.file.SpanMode, bool).initialize at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\typecons.d(7686) 0x00007FF77A610088 in std.typecons.SafeRefCounted!(std.file.DirIteratorImpl, RefCountedAutoInitialize.no).SafeRefCounted.__ctor!(string, std.file.SpanMode, bool).this at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\typecons.d(7789) 0x00007FF77A60F679 in std.file._DirIterator!false._DirIterator.this at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\file.d(4889) 0x00007FF77A60F613 in std.file.dirEntries!false.dirEntries at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\file.d(5011) 0x00007FF77A5F11AE in DirScan.scan at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(30) 0x00007FF77A5F127C in DirScan.scan at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(38) 0x00007FF77A5F127C in DirScan.scan at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(38) 0x00007FF77A5F10A0 in D main at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(18) 0x00007FF77A624223 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll().__lambda_L515_C29() 0x00007FF77A6240B4 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate()) 0x00007FF77A62417F in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() 0x00007FF77A6240B4 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate())
0x00007FF77A623F8A in d_run_main2
0x00007FF77A6181A9 in d_run_main
0x00007FF77A5F23B2 in DirScan._d_cmain!().main at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\internal\entrypoint.d(29) 0x00007FF77A6A95C9 in invoke_main at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79) 0x00007FF77A6A94E2 in __scrt_common_main_seh at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288) 0x00007FF77A6A939E in __scrt_common_main at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331) 0x00007FF77A6A963E in mainCRTStartup at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17)
0x00007FF98393E8D7 in BaseThreadInitThunk
0x00007FF985C0C3FC in RtlUserThreadStart
```

Then I comment out the 2 writelns ...

```
DirScan

Compiler: Digital Mars D v2.110
-----
PATH: C:\
-----
PATH: C:\$Recycle.Bin
-----
PATH: C:\$Recycle.Bin\S-1-5-18
Throwable: std.file.FileException@std\file.d(4683): C:\$Recycle.Bin\S-1-5-18: Access is denied.
----------------
0x00007FF60B7475F7 in d_throwc
0x00007FF60B7609E5 in @safe bool std.file.cenforce!(bool).cenforce(bool, scope lazy const(char)[], immutable(char)[], ulong) 0x00007FF60B74E166 in @safe bool std.file.DirIteratorImpl.stepIn(immutable(char)[]) 0x00007FF60B74050C in std.file.DirIteratorImpl.__ctor!string.this at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\file.d(4809) 0x00007FF60B7409EB in core.internal.lifetime.emplaceRef!(std.file.DirIteratorImpl, std.file.DirIteratorImpl, string, std.file.SpanMode, bool).emplaceRef.S.__ctor!().this at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\internal\lifetime.d(38) 0x00007FF60B7401DC in core.internal.lifetime.emplaceRef!(std.file.DirIteratorImpl, std.file.DirIteratorImpl, string, std.file.SpanMode, bool).emplaceRef at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\internal\lifetime.d(57) 0x00007FF60B74016D in core.lifetime.emplace!(std.file.DirIteratorImpl, string, std.file.SpanMode, bool).emplace at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\lifetime.d(64) 0x00007FF60B740057 in std.typecons.SafeRefCounted!(std.file.DirIteratorImpl, RefCountedAutoInitialize.no).SafeRefCounted.RefCountedStore.initialize!(string, std.file.SpanMode, bool).initialize at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\typecons.d(7686) 0x00007FF60B73FFA8 in std.typecons.SafeRefCounted!(std.file.DirIteratorImpl, RefCountedAutoInitialize.no).SafeRefCounted.__ctor!(string, std.file.SpanMode, bool).this at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\typecons.d(7789) 0x00007FF60B73F599 in std.file._DirIterator!false._DirIterator.this at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\file.d(4889) 0x00007FF60B73F533 in std.file.dirEntries!false.dirEntries at C:\D\dmd-2.110.0\windows\bin\..\..\src\phobos\std\file.d(5011) 0x00007FF60B7211AE in DirScan.scan at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(30) 0x00007FF60B721221 in DirScan.scan at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(38) 0x00007FF60B721221 in DirScan.scan at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(38) 0x00007FF60B7210A0 in D main at C:\Users\alexf\source\repos\DirScan2\DirScan2.d(18) 0x00007FF60B754093 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll().__lambda_L515_C29() 0x00007FF60B753F24 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate()) 0x00007FF60B753FEF in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() 0x00007FF60B753F24 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate())
0x00007FF60B753DFA in d_run_main2
0x00007FF60B747E09 in d_run_main
0x00007FF60B7222D2 in DirScan._d_cmain!().main at C:\D\dmd-2.110.0\windows\bin\..\..\src\druntime\import\core\internal\entrypoint.d(29) 0x00007FF60B7D94E9 in invoke_main at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79) 0x00007FF60B7D9402 in __scrt_common_main_seh at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288) 0x00007FF60B7D92BE in __scrt_common_main at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331) 0x00007FF60B7D955E in mainCRTStartup at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17)
0x00007FF98393E8D7 in BaseThreadInitThunk
0x00007FF985C0C3FC in RtlUserThreadStart
```

I may be new to D, but not programming in general. This inconsisitency bemuses me too.

This may be an issue specific to Windows perhaps, rather than your Mac etc. I tried the LDC Windows compiler with same results. GDC Windows didn't want to compile.

Putting a try{} around the dirEntries() too seems to resolve this to a proper FileException rather than Throwable, but still a bit surprised at this.

Reply via email to