e99d4e77be
This CL fixes a parser crash in REPL mode. Some SyntaxErrors can cause the AST to contain NULL nodes, resulting in a crash when we want to rewrite the AST after parsing. Instead of re-writing a broken AST we bail early. R=leszeks@chromium.org Bug: chromium:1040034, chromium:1045758 Change-Id: I9c559f6de5969c8db17833ccbdb1608627b46311 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2023547 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/master@{#66008}
29 lines
823 B
JavaScript
29 lines
823 B
JavaScript
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
let {Protocol} = InspectorTest.start(
|
|
"Tests that Runtime.evaluate works with REPL mode.");
|
|
|
|
Protocol.Runtime.enable();
|
|
(async function() {
|
|
InspectorTest.log("Test 'let' re-declaration");
|
|
evaluateRepl('let x = 21;');
|
|
evaluateRepl('x;');
|
|
evaluateRepl('let x = 42;');
|
|
evaluateRepl('x;');
|
|
|
|
// Regression test for crbug.com/1040034.
|
|
InspectorTest.log("SyntaxError in REPL mode does not crash the parser");
|
|
evaluateRepl('if (true) const x');
|
|
|
|
InspectorTest.completeTest();
|
|
})();
|
|
|
|
async function evaluateRepl(expression) {
|
|
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
|
|
expression: expression,
|
|
replMode: true,
|
|
}));
|
|
}
|