creating variables using eval does not work in a class context
Reported by
mwhitfie...@gmail.com,
Jul 17 2017
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Steps to reproduce the problem:
1. eval('var a = 123;'); console.log('a');
2. paste above code outside class context, runs fine
3. paste code inside class context (static), throws error
What is the expected behavior?
eval
Should allow new variables to be set in class context.
What went wrong?
"[Variable] is not defined." error thrown.
Did this work before? No
Chrome version: 59.0.3071.115 Channel: stable
OS Version: 10.0
Flash Version:
/**
* Bug report: eval has difficulty binding inside a class context. This
* occurs for static and non-static methods. This may or may not indicate
* further work required for completely implementing ES6 classes in the browser.
* @foundby Mike Whitfield (http://mikewhitfield.org | github.com/mgwhitfield)
*/
fn = function() {
eval('var b = 234;');
console.log(b);
}
arrowFn = () => {
eval('var c = 345;');
console.log(c);
}
class err {
constructor() {
try {
eval('var a = 123;');
console.log(a);
} catch(e) {
console.log('test1 fails', e);
}
try {
fn();
} catch(e) {
console.log('test2 fails', e);
}
try {
arrowFn();
} catch(e) {
console.log('test3 fails', e);
}
try {
err.fn();
} catch(e) {
console.log('test4 fails', e);
}
var e = 567;
try {
eval('e = 678;');
console.assert(e == 678);
} catch(e) {
console.log('test5 fails', e);
}
try {
eval('this.f = 789;');
console.log(this.f);
} catch(e) {
console.log('test6 fails', e);
}
try {
eval('let g = 890;');
console.log(g);
} catch(e) {
console.log('test7 fails', e);
}
try {
eval('const h = 901;');
console.log(h);
} catch(e) {
console.log('test8 fails', e);
}
}
static fn() {
eval('var d = 456');
console.log(d);
}
}
,
Jul 18 2017
@mwhitfield347: Thanks for the report. Could you please provide us a sample test file to check the issue from our end? Thanks!!
,
Jul 18 2017
,
Jul 18 2017
Assigning to Blink>Javascript but I expect this can be closed as per comment #1.
,
Jul 19 2017
,
Jul 19 2017
Thank you for providing more feedback. Adding requester "sandeepkumars@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jul 24 2017
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by huglovef...@gmail.com
, Jul 18 2017