Comment #4 on issue 733690 by
jgr...@chromium.org: Exception in module inline script is reported at the wrong location
https://bugs.chromium.org/p/chromium/issues/detail?id=733690#c4Looks like V8 reports the correct location:
<html>
<script> // Or <script type="module">
let a;
let b;
let c;
let d;
let a;
</script>
</html>
In both cases, the parser reports the SyntaxError at position 33.
Note that this bug only affects exceptions thrown during parsing, normal runtime exceptions have the correct location:
<html>
<script> // Or <script type="module">
let a;
let b;
let c;
let d;
throw new SyntaxError(); // Correct in both cases.
</script>
</html>
The bug happens sometime between Isolate::Throw (offset reported correctly) and V8ConsoleMessage::createForException (wrong line/column nr). We end up sending the following to inspector:
global:
{
"method": "Runtime.exceptionThrown",
"params": {
"exceptionDetails": {
"columnNumber": 4,
"exception": {
"className": "SyntaxError",
"description": "SyntaxError: Identifier 'a' has already been declared",
"objectId": "{\"injectedScriptId\":3,\"id\":1}",
"preview": {
"description": "SyntaxError: Identifier 'a' has already been declared",
"overflow": false,
"properties": [
{
"name": "stack",
"type": "string",
"value": "SyntaxError: Identifier 'a' has already been declared"
},
{
"name": "message",
"type": "string",
"value": "Identifier 'a' has already been declared"
}
],
"subtype": "error",
"type": "object"
},
"subtype": "error",
"type": "object"
},
"exceptionId": 2,
"executionContextId": 3,
"lineNumber": 6,
"scriptId": "67",
"text": "Uncaught",
"url": "file:///usr/local/google/home/jgruber/html/global-syntax-error.html"
},
"timestamp": 1498035411249.1719
}
}
module:
{
"method": "Runtime.exceptionThrown",
"params": {
"exceptionDetails": {
"columnNumber": 32,
"exception": {
"className": "SyntaxError",
"description": "SyntaxError: Identifier 'a' has already been declared",
"objectId": "{\"injectedScriptId\":1,\"id\":1}",
"preview": {
"description": "SyntaxError: Identifier 'a' has already been declared",
"overflow": false,
"properties": [
{
"name": "stack",
"type": "string",
"value": "SyntaxError: Identifier 'a' has already been declared"
},
{
"name": "message",
"type": "string",
"value": "Identifier 'a' has already been declared"
}
],
"subtype": "error",
"type": "object"
},
"subtype": "error",
"type": "object"
},
"exceptionId": 1,
"executionContextId": 1,
"lineNumber": 1,
"scriptId": "33",
"text": "Uncaught",
"url": "file:///usr/local/google/home/jgruber/html/module-syntax-error.html"
},
"timestamp": 1498035256046.3418
}
}
The line: 1, column: 32 sent for modules doesn't make any sense (line 1 is only 8 chars long, including \n).