function isLocalVariableWithoutEscape(variable, isMemberAccess) {
	if (!variable) {
		return false; // A global variable which was not defined.
	}

	// If the reference is a property access and the variable is a parameter, it handles the variable is not local.
	if (isMemberAccess && variable.defs.some(d => d.type === "Parameter")) {
		return false;
	}

	const functionScope = variable.scope.variableScope;

	return variable.references.every(
		reference => reference.from.variableScope === functionScope,
	);
}
Checks if an expression is a variable that can only be observed within the given function.
@param {Variable|null} variable The variable to check
@param {boolean} isMemberAccess If `true` then this is a member access.
@returns {boolean} `true` if the variable is local to the given function, and is never referenced in a closure.