Skip to content

Commit

Permalink
Stop codegen after error
Browse files Browse the repository at this point in the history
We won't use the bytecode anyway, and it prevents consistency checks
that come after the error from failing. Specifically: there might be
jumps that have no label defined.

Fixes: QTBUG-71738
Change-Id: I62a7e943b0156d42caccfa40507853de79e3b1ce
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit c4f82e5)
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
  • Loading branch information
Erik Verbruggen committed Nov 16, 2018
1 parent f92c48a commit 0d3eccd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/qml/compiler/qv4codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2206,15 +2206,17 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
bytecodeGenerator->addInstruction(Instruction::Ret());
}

bytecodeGenerator->finalize(_context);
_context->registerCount = bytecodeGenerator->registerCount();
static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
if (showCode) {
qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
<< "register count" << _context->registerCount;
QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
_context->line, _context->lineNumberMapping);
qDebug();
if (!hasError) {
bytecodeGenerator->finalize(_context);
_context->registerCount = bytecodeGenerator->registerCount();
static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
if (showCode) {
qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
<< "register count" << _context->registerCount;
QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
_context->line, _context->lineNumberMapping);
qDebug();
}
}

qSwap(_returnAddress, returnAddress);
Expand Down
1 change: 1 addition & 0 deletions tests/auto/qml/v4misc/tst_v4misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ void tst_v4misc::parserMisc_data()
QTest::addColumn<QString>("error");

QTest::newRow("8[++i][+++i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
QTest::newRow("T||9[---L6i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
}

void tst_v4misc::parserMisc()
Expand Down

0 comments on commit 0d3eccd

Please sign in to comment.