resolve `set` to the outer-most scope that has the variable defined (if exists)