Errors

BrainRot Lang uses error recovery — the parser collects all errors instead of stopping at the first one. All errors follow a consistent [SKILL ISSUE] branded format.

Error Format

Every error in BrainRot Lang follows the same structure — a [SKILL ISSUE] header, followed by the error phase and the line number with a descriptive message.

error-format
# Every error follows this format: [SKILL ISSUE] [Runtime Error] Line 3 → variable 'x' is ghosted (not defined) # Parser errors use the same structure: [SKILL ISSUE] [Parser Error] Line 5 → expected '}' but got 'EOF'

Error Categories

CategoryWhenSource
Parser errorsToken stream violates grammar rulesparser/parser.go
Runtime errorsValid syntax but invalid executioninterpreter/
CLI errorsMissing file argument or unknown commandmain.go

The lexer does not produce error messages directly — it emits ILLEGAL tokens for unrecognized characters, which the parser then reports as syntax errors.

Parser Errors

Parser errors occur when the token stream does not match the expected grammar. The parser uses error recovery — it continues parsing after an error to find additional issues in a single run.

missing-brace.brt
# Missing closing brace let_him_cook main() { say_my_name("hello") # Output: # [SKILL ISSUE] # [Parser Error] # Line 4 → expected '}' but got 'EOF'
bad-for-init.brt
# Bad for-loop initializer let_him_cook main() { run_it_back ("hello"; i < 10; i += 1) { say_my_name(i) } } # Output: # [SKILL ISSUE] # [Parser Error] # Line 2 → expected variable declaration or assignment but got '"hello"'

Runtime Errors

Runtime errors occur during AST interpretation — when the program is syntactically valid but semantically incorrect.

Undefined variable

undefined-var.brt
let_him_cook main() { say_my_name(x) } # Output: # [SKILL ISSUE] # [Runtime Error] # Line 2 → variable 'x' is ghosted (not defined)

Variable redeclaration

redeclare.brt
let_him_cook main() { trust_me_bro x = 10 trust_me_bro x = 20 } # Output: # [SKILL ISSUE] # [Runtime Error] # Line 3 → variable 'x' already declared in this scope # — you can't declare it twice

Missing main function

no-main.brt
# No main function defined trust_me_bro x = 42 say_my_name(x) # Output: # [SKILL ISSUE] # [Runtime Error] # Line 0 → no main() found — BrainRot Lang needs # 'let_him_cook main() { ... }'

Argument count mismatch

arg-mismatch.brt
let_him_cook add(a, b) { take_this a + b } let_him_cook main() { say_my_name(add(1, 2, 3)) } # Output: # [SKILL ISSUE] # [Runtime Error] # Line 6 → function expects 2 args but got 3

Calling a non-function

not-a-function.brt
let_him_cook main() { trust_me_bro x = 42 x(1, 2) } # Output: # [SKILL ISSUE] # [Runtime Error] # Line 3 → '42' is not a function bro

Array out of bounds

array-bounds.brt
let_him_cook main() { trust_me_bro arr = [1, 2, 3] say_my_name(arr[10]) } # Output: # [SKILL ISSUE] # [Runtime Error] # Line 3 → index 10 out of bounds (array length 3)

CLI Errors

CLI-level errors are printed in red and use a distinctive meme message when no file argument is provided.

cli-errors
# No file argument provided: $ brainrot run # Output (in red): # File nahi bhejega ke Meh kya ladle meow ghop ghop ghop # Unknown command: $ brainrot yeet # Output: # Unknown command: yeet

All Runtime Messages

Complete list of runtime error messages from the interpreter:

ErrorCause
variable 'x' is ghosted (not defined)Using an undeclared variable
variable 'x' already declared in this scopeRedeclaring a variable in the same scope
++ / -- can only be used on variablesPostfix operator on a non-identifier
++ / -- can only be used on integersPostfix operator on a non-integer value
index operator used on non-array valueUsing [] on a non-array
array index must be an integerNon-integer array index
index N out of bounds (array length M)Index exceeds array size
no main() foundProgram has no let_him_cook main()
'value' is not a function broCalling a non-function value
function expects N args but got MWrong number of arguments
function 'f' already defined at line NDuplicate function definition
not allowed outside main()Statement outside a function or variable declaration

Error Recovery

The parser implements error recovery by synchronizing on statement boundaries. When it encounters an unexpected token, it records the error and advances to the next statement start token (typically trust_me_bro, let_him_cook, chat_is_this_real, etc.) to continue parsing.

This means the parser reports all syntax errors in your program in a single run — you don't need to fix one error and re-run to discover the next one. Multiple errors are printed under a [PARSER ERRORS] header in red.