compile: fix namespace leak related to submodules and compilation

A reference intended to be temporary from a submodule to its enclosing
module wasn't NULLed out.