Fix a nasty bug involving variable lookups in enclosing scopes and overloads.