eg, this code:
    
    
    import os
    
    for p in walkDir("/tmpXXXXX"):
        echo p
    echo "Hello"
    
    
    Run

If the directory /tmpXXXXX does not exist, then control flow just passes on to 
after the loop, rather than raising an exception about "directory not found".

In the nim code os.nim, for 0.19.2, around line 866, there's a call to opendir, 
and then logic proceeds if the returned pointer is not nil (ie, there wasn't an 
error.

But there's no branch in that code that handles the nil condition, gets the C 
error, raises, etc.

It's possible to eg, make a PR which adds the C error check, and then raises an 
exception. But that would break existing systems that depend on walkDir's 
current permissiveness. Also, with Nim 1.0 being just around the corner.

I'm picking on walkDir here, but I have seen this in some other places.

Would it be more correct to eg, update documentation for walkDir to state that 
by design it's not intended to? Similar to how eg, removeDir is documented as 
not raising an exception if the directory never existed originally?

Reply via email to