B–Blunder

B.variable

An easy and common mistake is using the wrong variable name. For example, the author meant to write

i = 5;

but instead wrote

j = 5;

In many languages, this generates an error unless j is defined and is the same type as i, but the existence of two variables of the same type and similar names can be the cause of the B.variable error (because the programmer is thinking about both variables), so this is more common than you might expect. Often, when first typing in code, there will be typos. For example, your finger might slip off the I key and hit the adjacent key to wind up with:

io = 5;

Whether this is caught quickly might depend on how the language specifies that undeclared variables should be treated.

One source of ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.