FS-6030: --resolve fix variable scoping issue for more aggressive optimizer