Safety and Runtime ModelDebugging and Diagnostics
Blorp by Example

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.brp
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.

missing-case.brp
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))
	print(no_io_here())

Try It

terminal
blorp check diagnostics.brp
blorp run --debug diagnostics.brp