Threadon / Debug

Debug

runtime checks while you develop

What debug mode does

Debug mode adds runtime checks that normally aren't there, because the compiler trusts you. Turn it on with --debug:

python3 -m compiler.main --run --debug file.th

Two kinds of checks get added:

What a runtime error looks like

When a check fires, the program prints to stderr and exits with code 1.

Enter a number: 0
[RUNTIME ERROR]
│ Error: Division by zero
├─> Location: (null)
└─> Process terminated with exit code 1

A bad conversion reports which cast failed:

[RUNTIME ERROR]
│ Error: Invalid integer conversion
├─> Location: String → Integer cast
└─> Process terminated with exit code 1

The box-drawing lines and colors render on a terminal; if you pipe the output, the raw ANSI escapes show through.

Without debug mode

No checks, no safety net. Dividing by zero and invalid conversions are undefined behavior, straight from the generated LLVM. In practice you get whatever the runtime does, and it won't be a friendly message. Debug mode is for development; leave it off for performance.

What debug mode does not catch

The 09_zero_division example in the repo demonstrates a caught division by zero. See Examples.