{"slug": "my-llm-compiler-fixed-a-student-s-bug-nobody-asked-it-to", "title": "My LLM compiler fixed a student's bug. Nobody asked it to", "summary": "A developer building Pseudo.NET, a compiler for free-form pseudocode that uses a local qwen2.5-coder:7b model via Ollama to produce a JSON syntax tree and a deterministic C# backend, found that the compiler silently repaired a student's bug when a comment stated the intended goal. In a six-case fidelity test, the 7B model preserved the mistake in five of six programs, but inserted a missing `total = 0;` reset in the running-total case; removing the goal comment (control f3b) restored faithful transcription, and the 14B model kept every mistake. The developer also disclosed that a hand-written backend fallback (`return default;`) had masked a missing-return bug in a `sign` function, fixed in version 0.4.6 to halt with an error instead.", "body_md": "Here are two programs. They are identical except for the first line.\n\n```\n// Goal: print the sum of each row of a 3 x 3 table whose rows are 1 2 3\ntotal = 0\nrepeat row from 1 to 3 {\n  repeat col from 1 to 3 {\n    total = total + col\n  }\n  print total\n}\ntotal = 0\nrepeat row from 1 to 3 {\n  repeat col from 1 to 3 {\n    total = total + col\n  }\n  print total\n}\n```\n\nBoth contain the same mistake: `total` is never reset, so the program prints 6, 12, 18 instead of 6, 6, 6. Compiled with the same compiler, the same model and the same settings, the second program prints 6, 12, 18. The first one prints 6, 6, 6.\n\nThe compiler fixed the bug. The comment told it what the student wanted, and it obliged.\n\nI build Pseudo.NET, a compiler for free-form pseudocode. A local model (qwen2.5-coder:7b through Ollama) reads whatever the student wrote and produces a JSON syntax tree; a deterministic backend then writes C#, and the program runs.\n\nFor a teacher, one property matters more than any other: the compiler must transcribe the student's logic, mistakes included. A student learns from seeing their program fail. A compiler that quietly repairs the program teaches them that it was right.\n\nI wrote six deliberately wrong programs, each with a comment stating the intended result:\n\n| Case | Mistake | \n|---|---|\n| f1 | loop from 1 to 4 to \"add 1 to 5\" | \n| f2 | `while i less than 5` , stops one step early | \n| f3 | running total never reset (the program above) | \n| f4 | inverted test: under 18 prints \"adult\" | \n| f5 | `return` inside the loop | \n| f6 | operator precedence: `a + b / 2` | \n\nEach one goes through the real compiler and the real model, with an empty cache, and runs. The expected output is what the code really does, not what the comment says.\n\nThe model kept the mistake in five of the six. In f3, it added `total = 0;` at the start of the outer loop:\n\n```\nfor (row = 1; row <= 3; row++)\n{\n    total = 0;            // not in the student's program\n    for (col = 1; col <= 3; col++)\n    {\n        total = (total + col);\n    }\n    Console.WriteLine(total);\n}\n```\n\nTo find out why, I added a control, f3b: the same program without the comment. It was transcribed faithfully. The trigger is the comment that states the goal.\n\nI added two short instructions to the system prompt, asking the model to transcribe exactly, mistakes included. Neither changed anything on f3. My reading, which I have not proven: for a 7-billion-parameter model, a concrete sentence about the goal weighs more than a general rule.\n\nSame tests (f1 to f6 plus the control f3b, before f7 existed), same model family, one run each:\n\n| Model | Size | Fidelity (7) | AP CSP-style (10) | Divisibility phrasings (6) | \n|---|---|---|---|---|\n| qwen2.5-coder:7b (default) | 4.7 GB | 6 | 5 | 6 | \n| qwen2.5-coder:14b | 9 GB | 7 | 6 | 5 | \n| qwen2.5-coder:3b | 1.9 GB | 3 | 1 | 0 | \n| qwen2.5-coder:1.5b | 1 GB | 2 | 0 | 0 | \n\nThe 14b model kept every mistake, f3 included. The small models mostly failed for another reason: their code did not compile.\n\nTo make f5 compile, I had added a line to the deterministic backend: when a function does not return a value on every path, end it with `return default;`. A review pointed out what that does to a function like this one, which forgets zero:\n\n```\ndefine sign(x) {\n  if x > 0 then return 1\n  if x < 0 then return -1\n}\n```\n\n`sign(0)` returned 0. A plausible value, no error, and the mistake was hidden. The same repair I was testing the model for, written by hand, in the part of the compiler with no AI in it.\n\nSince version 0.4.6, the program stops at that point instead: \"The function sign ended without returning a value.\" That case is now f7 in the test, and it passes.\n\nOne run per case. At temperature 0 the output is close to deterministic, not strictly. One model family. No remote model measured. And the bugs tested are all local, one line each. The next cases I want to try are well-known algorithms slightly wrong, such as a bubble sort that reads past the end or a binary search that never stops, because that is where a model is most likely to recognise the algorithm and rewrite it.\n\nThe programs (f1 to f7, plus the control f3b), their expected outputs, the generated C# and the script are in the repository: [https://github.com/pseudonet-lang/pseudonet/tree/main/docs/examples/faithfulness](https://github.com/pseudonet-lang/pseudonet/tree/main/docs/examples/faithfulness)\n\nFor teachers, what Pseudo.NET does and does not do, with these results: [https://pseudonet-lang.github.io/educators/](https://pseudonet-lang.github.io/educators/)", "url": "https://wpnews.pro/news/my-llm-compiler-fixed-a-student-s-bug-nobody-asked-it-to", "canonical_source": "https://dev.to/malek_aitouaret_f026758c/my-llm-compiler-fixed-a-students-bug-nobody-asked-it-to-1oab", "published_at": "2026-11-27 16:38:10+00:00", "updated_at": "2026-11-27 16:42:16.496677+00:00", "lang": "en", "topics": ["large-language-models", "ai-tools", "developer-tools", "ai-agents"], "entities": ["Pseudo.NET", "Ollama", "qwen2.5-coder"], "also_reported_by": [], "takeaway": "In a six-case fidelity test, qwen2.5-coder:7b preserved a student's bug in five of six programs but silently inserted a missing `total = 0;` reset when a comment stated the goal; the 14B model preserved all six, while 3B and 1.5B models mostly produced code that did not compile.", "recommendation": {"advice": "Test transcription fidelity with paired programs that differ only by a goal comment, and prefer a 14B model over 7B when exact reproduction of flawed logic matters.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/my-llm-compiler-fixed-a-student-s-bug-nobody-asked-it-to", "markdown": "https://wpnews.pro/news/my-llm-compiler-fixed-a-student-s-bug-nobody-asked-it-to.md", "text": "https://wpnews.pro/news/my-llm-compiler-fixed-a-student-s-bug-nobody-asked-it-to.txt", "jsonld": "https://wpnews.pro/news/my-llm-compiler-fixed-a-student-s-bug-nobody-asked-it-to.jsonld"}}