You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
514 B

/*
* 'with' statement is a SyntaxError in strict mode.
*/
/*===
non-strict with bar
SyntaxError
===*/
function test() {
try {
eval("(function() { var obj={foo:'bar'}; with(obj) { print('non-strict with', obj.foo); } })();");
} catch (e) {
print(e.name);
}
try {
eval("(function() { 'use strict'; var obj={foo:'bar'}; with(obj) { print('strict with', obj.foo); } })();");
} catch (e) {
print(e.name);
}
}
try {
test();
} catch (e) {
print(e);
}