Skip to content
This repository has been archived by the owner on Dec 9, 2017. It is now read-only.

shadowing of undefined #89

Open
thisisadiyoga opened this issue Jan 26, 2015 · 1 comment
Open

shadowing of undefined #89

thisisadiyoga opened this issue Jan 26, 2015 · 1 comment

Comments

@thisisadiyoga
Copy link

undefined is not a reserved keyword in JavaScript and can be shadowed by a local variable of the same name.
the following simplified test case shows the error:

function foo() {
var undefined = 2;
return b + 2;
}
console.log(foo());

in the above test case, undefined is redefined to be 2.
var b is undefined (in a sense that it is not yet declared).
foo() should report error on undeclared variable b but in Jalangi instrumentation, it returns 4 as undefined is equal to 2.

also related is the following case:

function undef() { return; }
var undefined = 2;
console.log(undef() == undefined);

it should return false as undefined is already redefined, but in Jalangi, it returns true as the outer undefined is not redefined.

use either void operator to create a true undefined value (e.g. void 0) or declare a function to generate the undefined value (e.g. function undef() { return; }, then undef() will always return undefined).

@msridhar
Copy link
Contributor

FYI, we are unlikely to fix this jalangi issue, as ongoing work is focused on jalangi2: https://github.com/Samsung/jalangi2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants