Comment #14 on issue 1914 by [email protected]: Capture correct line numbers for Errors thrown in an eval.
http://code.google.com/p/v8/issues/detail?id=1914

@yangguo - I'm not sure if this issue is fully solved yet. Although the Error object does contain the proper information for runtime errors, compilation/parsing errors do not reveal line/column numbers.

For example, if I run the following code (using Chrome 23.0.1271.95 m):

```
var a = 1, b = 2;
try {
        eval("var sum = a;\nsum += c;");
        console.log(sum);
} catch(e) {
        console.log(e.stack);
}
```

I get the following error, which includes the line/column number in my eval'ed string:

```
ReferenceError: c is not defined
    at eval (eval at <anonymous> (unknown source), <anonymous>:2:8)
    at <anonymous>:4:2
    at Object.InjectedScript._evaluateOn (<anonymous>:444:39)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:403:52)
    at Object.InjectedScript.evaluate (<anonymous>:339:21)
```

But, if I run this code:

```
var a = 1, b = 2;
try {
        eval("var sum = a;\nsum += c);");
        console.log(sum);
} catch(e) {
        console.log(e.stack);
}
```

I get this error, which only shows the stack trace where eval is called:

```
SyntaxError: Unexpected token )
    at <anonymous>:4:2
    at Object.InjectedScript._evaluateOn (<anonymous>:444:39)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:403:52)
    at Object.InjectedScript.evaluate (<anonymous>:339:21)
```

Why would this be?

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to