Debugging and Diagnostics
Use the compiler as a fast feedback loop before you run the program.
Check
blorp check file.brp parses imports, infers types, checks purity, and reports errors without running the program.
terminal
blorp check src
Formatting
blorp format file.brp normalizes source layout; --check is useful in CI.
terminal
blorp format file.brp
blorp format --check file.brp
Debug:
debug: blocks are erased from normal builds and can call debug-only helpers such as debug.log and debug_string.
debug:
dbg.log("value " + dbg.debug_string(value))
Reading Compiler Errors
Most errors point at the missing case, impure call, or incompatible type that needs the smallest source change.
match status:
Ready: "ready"
-- compiler asks for the other variants
Example
diagnostics.brp
import:
debug as dbg
union Status:
Ready
Failed(String)
pure func describe(status: Status) -> String:
match status:
Ready: "ready"
Failed(message): "failed: " + message
pure func no_io_here() -> String:
-- print("not allowed in pure code")
debug:
dbg.log("status " + dbg.debug_string(Ready))
"keep effects in main"
func main(args: List[String]) -> Void:
print(describe(Ready)) -- prints: ready
print(no_io_here()) -- prints: keep effects in main
Try it
terminal
blorp check diagnostics.brp
blorp run --debug diagnostics.brp