I'm brand-new to Nim, so this may be way off-base. If I have a package with 
ModuleA and submodule ModuleB, and an error occurs in the top-level statements 
initializing ModuleB, the error is not reported, and it seems to mess up 
subsequent error-handling in ModuleA.

Consider
    
    
    # ModuleA
    import Test/ModuleB
    echo "ModuleA about to have exception"
    echo high(int) + 1
    
    
    Run

If ModuleB is
    
    
    # ModuleB
    echo "First top-level statement of ModuleB"
    echo high(int)
    echo "ModuleB last statement"
    
    
    Run

this produces
    
    
    nimtest>bin\test
    First top-level statement of ModuleB
    9223372036854775807
    ModuleB last statement
    ModuleA about to have exception
    d:\nimtest\src\Test.nim(3) Test
    C:\Program Files\nim-2.0.0\lib\system\fatal.nim(53) sysFatal
    Error: unhandled exception: over- or underflow [OverflowDefect]
    
    nimtest>

as expected. But if ModuleB is modified to cause an error:
    
    
    # ModuleB
    echo "First top-level statement of ModuleB"
    echo high(int) + 1
    echo "ModuleB last statement"
    
    
    
    Run

the result is:
    
    
    nimtest>bin\test
    First top-level statement of ModuleB
    ModuleA about to have exceptionTraceback (most recent call last)
    d:\nimtest\src\Test.nim(3) Test
    C:\Program Files\nim-2.0.0\lib\system\fatal.nim sysFatal
    C:\Program Files\nim-2.0.0\lib\system\arc.nim(81) nimNewObj
    SIGSEGV: Illegal storage access. (Attempt to read from nil?)
    
    nimtest>

The error is not reported in ModuleB, but the statement after the error is not 
executed, and the subsequent error in ModuleA results in an illegal storage 
access.

I first noticed this, because assert failures in the submodule were not getting 
reported. Am I missing something here? If there's any complexity to the 
submodule's initialization code, this makes it harder to debug.

Reply via email to