October 11, 2026•4 min read

Every Receipt in This Café Lists the Same Order

Every table's receipt holds the same items, and the total is Rp0 — even though each table ordered exactly one thing. Guess why, then make make check green. A Python scope and mutation lab.

Read in Indonesian

Lab repo

The lab lives in folder 0004.mutation-and-scope

The deliberately broken code, the dataset, and the target live in a public repo. Everything runs in Docker. make check

A busy night in a small café. The barista opens three tables, and each table orders exactly one thing: table 1 orders coffee, table 3 orders tea, table 5 orders bread. That simple.

Until the barista prints the receipts. Every table's receipt holds the same items — coffee, tea, bread, all three of them. Even though each table ordered one thing. And every receipt says the total is Rp0. The daily till at the end of the night is Rp0 too, despite a full night of sales.

Not one error message on screen. Nothing stops running. The application runs to completion, and if you open the functions one by one and read from the top, each one looks sensible. There are comments explaining the original author's intent, and the intent was good: one function says the order starts empty, another says the total is computed from the items already added. Good intent, wrong result — the most annoying combination there is.

Key takeaways

  • Three tables order one item each, yet every receipt holds the same items and the total is Rp0.
  • There is no error, and each function looks correct when read on its own.
  • Six make check checks are red, split into three groups that fail in different ways.
  • Fixing one place is not enough: there is more than one cause.
  • The question is not "where is the bug", it is which object is actually being changed.

The numbers as they actually come out now

what happens
three tables (1, 3, 5), each ordering one item every receipt holds the same 3 items: kopi x2, teh x1, roti x1
each receipt's total Rp0 (table 1 should be Rp30,000, table 3 Rp8,000, table 5 Rp12,000)
daily till after three tables of sales Rp0 (should be Rp50,000)
make check, 6 checks 6 of 6 red

The first row is the deceptive one. The orders are clearly different: table 1 coffee, table 3 tea, table 5 bread. But once they reach a receipt, all three become one shared list. Not a single table has a receipt holding its own order.

make check splits those six checks into three groups, and each group fails in its own way. The first two are about receipt contents: a table that has not ordered yet still gets filled in (tables 3 and 5), and two tables with different orders (7 and 9) end up with identical contents. The next two are about totals: one receipt should be Rp38,000 but reads Rp0, another should be Rp45,000 with the same result. The last two are about the till: one table's sale should raise the till by Rp32,000, and instead it rises by Rp0. Six symptoms, three groups, and each group points somewhere different.

Your mission

Make make check green. The six checks (A1, A2, B1, B2, C1, C2) fall into three groups, each testing one condition:

  1. Each receipt holds only its own table's order. A table that has not ordered yet keeps an empty receipt, and two tables with different orders must not swap contents.
  2. Each total is computed from its items. Item count and qty multiply, instead of staying at Rp0.
  3. The daily till rises by what was actually sold. Sell Rp32,000, the till rises Rp32,000.

You may change anything in that one file, as long as the three functions can still be called the way they are called now. And before you open the editor, there is one thing that makes this lab different from the previous three.

Why this lab needs no Docker

The previous three labs in this repo run on FastAPI, Postgres and Docker. This one does not. All the code is standard Python 3, one file, no pip install and no database. The reason is simple: if you have to set up Docker before you can start learning, you stop at step zero. Here the only thing you need is python3, which is on almost every machine. So your preparation is one step: open a terminal.

Where to start

Two commands, and one file to read:

BASH
make demo    # the story, not the numbers
make check   # see for yourself which checks are red

Then open kasir.py and read from the top. Every function has a comment explaining its author's intent. Your job is not to find the line that looks ugly — your job is to find why good intent still produces the wrong receipt.

Why this exists

Most people learn "functions" from examples that get called once. Write it once, call it once, print, done — and the program looks like it works. In reality, functions are called over and over: one table, then another, then tomorrow again. There are two things that only show up when a function is used more than once, and both are rarely taught alongside your first example. That is why this lab exists.

The limits of this lab

  • This is not a lesson about classes. All the state here is a plain dict and ordinary values. In the real world, problems of this shape are often solved with a class — but a class is not a magic cure. It is just another way to answer the same question: which object are you holding, and which one are you changing?
  • Everything broken here breaks without a single error message. If you have been waiting for a red screen to tell you something is wrong, this lab trains the opposite: suspecting code that runs smoothly.

The questions

Before you touch kasir.py, answer this first: why does a table that has not ordered anything still get another table's order? It is not the same table, it is not the same receipt, yet the contents are identical.

Second question: if each function looks correct when read on its own, where exactly is one table "leaving" its data with another? And the last one, the decisive one: if you only fix one place, is that enough? There is more than one cause behind these three symptoms, and each has a different cure. The long answer is in the answer article.

Get better at shipping code.

Join the other developers getting tech updates, tips, and relaxed tutorials in their inbox every week.

Stay in the loop

Tech updates, coding tips, and relaxed insights straight to your inbox every week.

No spam. Unsubscribe anytime.

Read next

See all

For developers who learn by struggling

© 2026 Inva.dev.