QMLJS: Have ScanFunctions iterate over ArrayPattern nodes

Like Codegen, have ScanFunctions iterate over the elements in an
ArrayPattern, instead of recursing over the tail of the element list.

This prevents running out of (native) stack, or hitting the recursion
check limiter.

Change-Id: I8203af3119ad50f19000a215af42649d9bcb3784
Fixes: QTBUG-73425
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Erik Verbruggen 2019-02-04 12:02:01 +01:00
parent d27d896d8c
commit 5de48ee56a
2 changed files with 9 additions and 0 deletions

View File

@ -481,6 +481,14 @@ bool ScanFunctions::visit(FieldMemberExpression *ast)
return true; return true;
} }
bool ScanFunctions::visit(ArrayPattern *ast)
{
for (PatternElementList *it = ast->elements; it; it = it->next)
Node::accept(it->element, this);
return false;
}
bool ScanFunctions::enterFunction(FunctionExpression *ast, bool enterName) bool ScanFunctions::enterFunction(FunctionExpression *ast, bool enterName)
{ {
if (_context->isStrict && (ast->name == QLatin1String("eval") || ast->name == QLatin1String("arguments"))) if (_context->isStrict && (ast->name == QLatin1String("eval") || ast->name == QLatin1String("arguments")))

View File

@ -120,6 +120,7 @@ protected:
bool visit(AST::TemplateLiteral *ast) override; bool visit(AST::TemplateLiteral *ast) override;
bool visit(AST::SuperLiteral *) override; bool visit(AST::SuperLiteral *) override;
bool visit(AST::FieldMemberExpression *) override; bool visit(AST::FieldMemberExpression *) override;
bool visit(AST::ArrayPattern *) override;
bool enterFunction(AST::FunctionExpression *ast, bool enterName); bool enterFunction(AST::FunctionExpression *ast, bool enterName);