| name | fix-bug |
| description | Use when diagnosing and fixing a bug in the Brainrot interpreter — crashes, wrong output, memory errors (ASan/UBSan/Valgrind), or a failing test_cases fixture. Covers root-causing across the lexer/parser/AST/semantic-analyzer/interpreter pipeline. |
When to Use
The user reports incorrect output, a crash, a compiler warning, a sanitizer
error, a Valgrind leak, or a failing pytest case for a .brainrot program.
Step-by-Step Instructions
- Reproduce minimally. Write or reduce a
.brainrot snippet that triggers
the bug; run it directly: ./brainrot repro.brainrot. Compare against a
git stash-clean build if unsure whether it's a regression.
- Reproduce under sanitizers/Valgrind first if the symptom is a
crash/garbage output — the project's
CFLAGS already build with
-fsanitize=address,undefined, so a plain make && ./brainrot repro.brainrot
often surfaces the exact line. For leaks specifically, use
valgrind --leak-check=full --track-origins=yes ./brainrot repro.brainrot.
- Locate the layer: use the error/stack trace to figure out whether the
bug is in lexing (
lang.l), grammar (lang.y), AST construction (ast.c),
semantic checks (semantic_analyzer.c), or execution
(interpreter.c/visitor.c/stdrot/*.c). Add fprintf(stderr, ...) trace
points if the sanitizer trace isn't enough — don't leave them in the fix.
- Fix at the root cause, not the symptom. Check
TRUTH.md-adjacent
history: git log -p -- <file> for the surrounding function to see if this
area has had prior memory-safety fixes (it has — see commit
for the pattern to follow:
ownership/lifetime bugs around /pointer handling).