Skip to content

Commit

Permalink
Remove superfluous assert when traversing IR
Browse files Browse the repository at this point in the history
When accessing/calling a property on an object, it is possible (and
perfectly fine) for that object to be a constant value. I.e. Undefined.
All code handling such a call do handle constants correctly.

Note: this is a 5.9 specific change, because 5.11 got rid of this code.

Task-number: QTBUG-66027
Change-Id: Ied9d0c9c8f8bf958f8634f7be196900b3ea64861
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
  • Loading branch information
Erik Verbruggen committed Feb 22, 2018
1 parent 8fdf466 commit b6d1e97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/qml/compiler/qv4isel_p.cpp
Expand Up @@ -259,7 +259,6 @@ void IRDecoder::visitExp(IR::Exp *s)
} else if (c->base->asTemp() || c->base->asArgLocal() || c->base->asConst()) {
callValue(c->base, c->args, 0);
} else if (Member *member = c->base->asMember()) {
Q_ASSERT(member->base->asTemp() || member->base->asArgLocal());
#ifndef V4_BOOTSTRAP
Q_ASSERT(member->kind != IR::Member::MemberOfIdObjectsArray);
if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) {
Expand Down
13 changes: 13 additions & 0 deletions tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
Expand Up @@ -339,6 +339,7 @@ private slots:
void singleBlockLoops();
void qtbug_60547();
void anotherNaN();
void callPropertyOnUndefined();

private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
Expand Down Expand Up @@ -8281,6 +8282,18 @@ void tst_qqmlecmascript::anotherNaN()
object->setProperty("prop", d); // don't crash
}

void tst_qqmlecmascript::callPropertyOnUndefined()
{
QJSEngine engine;
QJSValue v = engine.evaluate(QString::fromLatin1(
"function f() {\n"
" var base;\n"
" base.push(1);"
"}\n"
));
QVERIFY(!v.isError()); // well, more importantly: this shouldn't fail on an assert.
}

QTEST_MAIN(tst_qqmlecmascript)

#include "tst_qqmlecmascript.moc"

0 comments on commit b6d1e97

Please sign in to comment.