Debugging Blocks within Blocks

One potential challenge in building custom blocks that use other custom blocks is that a custom block may work fine on its own, but when it's used inside another custom block, something goes wrong.

Here is an example. A programmer intended to draw five squares in a row, like this: five squares in a row, and built this script: repeat (5) (draw square (20), move (20) steps)

Of course, it required a draw square block with an input size, so the programmer created this definition:

This draw square (size) script makes one square of size 20, as expected, when it is called with 20 as the input.
draw square (size): move (size) steps, turn right 90 degrees, move (size) steps, turn right 90 degrees, move (size) steps, turn right 90 degrees, move (size) steps

But instead of getting the desired picture of five squares in a row like five squares in a row, the repeat (5) (draw square (20), move (20) steps) script draws 4 squares around a square.

Debugging Blocks within Blocks Self-Check

What is the bug?

The repeat block code needs to be more complicated.
The draw square block draws a square of the wrong size.
The draw square block won't draw 4 sides in the shape of a square.
The draw square block actually works correctly!
The draw square block doesn't return the sprite to the correct location when it is done.
The draw square block leaves the sprite facing the wrong direction.

Consider the following block definition to draw a house; if it uses a correct draw square block, it will draw a house (with a flat roof) and a door at the lower right:

draw-house block definition using proper draw-square draw-house picture

What will be drawn if it uses the buggy draw square code shown at the top of the page?

draw-house block definition using buggy draw-square
draw-house picture correct (The correct picture)
Because draw square is buggy, there is no way to predict what the picture will look like.
draw-house picture upside down (Flipped over)
draw-house picture upside down