Here are two programs. They are identical except for the first line.
// Goal: print the sum of each row of a 3 x 3 table whose rows are 1 2 3 total = 0 repeat row from 1 to 3 { repeat col from 1 to 3 { total = total + col } print total } total = 0 repeat row from 1 to 3 { repeat col from 1 to 3 { total = total + col } print total } Both 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.
The compiler fixed the bug. The comment told it what the student wanted, and it obliged.
Why this matters here
I 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.
For 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.
The test
I wrote six deliberately wrong programs, each with a comment stating the intended result:
| Case | Mistake |
|---|---|
| f1 | loop from 1 to 4 to "add 1 to 5" |
| f2 | while i less than 5, stops one step early |
| f3 | running total never reset (the program above) |
| f4 | inverted test: under 18 prints "adult" |
| f5 | return inside the loop |
| f6 | operator precedence: a + b / 2 |
Each 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.
The model kept the mistake in five of the six. In f3, it added total = 0; at the start of the outer loop:
for (row = 1; row <= 3; row++) { total = 0; // not in the student's program for (col = 1; col <= 3; col++) { total = (total + col); } Console.WriteLine(total); } To 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.
What did not work
I 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.
Bigger and smaller models
Same tests (f1 to f6 plus the control f3b, before f7 existed), same model family, one run each:
| Model | Size | Fidelity (7) | AP CSP-style (10) | Divisibility phrasings (6) |
|---|---|---|---|---|
| qwen2.5-coder:7b (default) | 4.7 GB | 6 | 5 | 6 |
| qwen2.5-coder:14b | 9 GB | 7 | 6 | 5 |
| qwen2.5-coder:3b | 1.9 GB | 3 | 1 | 0 |
| qwen2.5-coder:1.5b | 1 GB | 2 | 0 | 0 |
The 14b model kept every mistake, f3 included. The small models mostly failed for another reason: their code did not compile.
We were doing it too
To 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:
define sign(x) { if x > 0 then return 1 if x < 0 then return -1 } 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.
Since 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.
What I take from it
- A compiler built on an LLM has an obligation that coding assistants do not: it must not be helpful. The useful question is not "does the program work?" but "does the wrong program stay wrong?"
- For debugging exercises, I now advise teachers not to write the expected result in a comment, and to read the generated C# when the output surprises them.
- Silent repair is not only a model problem. It was in my own code too.
Limits
One 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.
Try it
The 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
For teachers, what Pseudo.NET does and does not do, with these results: https://pseudonet-lang.github.io/educators/
