Make accessing undefined variables an error (instead of a warning).

Fixes #5809