From: Simon Hausmann Date: Fri, 11 Oct 2013 12:56:15 +0000 (+0200) Subject: Fix failing assertion (index != -1) when trying to re-declare a function parameter X-Git-Tag: upstream/5.2.1~242 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74a02a83809f6942732ec18125403e8ee32c574f;p=platform%2Fupstream%2Fqtdeclarative.git Fix failing assertion (index != -1) when trying to re-declare a function parameter Testcase: (covered in parserstress) function foo(x) { var x = 42; } In variableDeclaration, the lookup for "x" with findMember will return -1, and instead code for checking against arguments using indexOfArgument is needed. The easiest fix is to simply use identifier(), which handles this accordingly. Change-Id: I6a738d6196d4bff1fc987f111aebbaa83ed8f88f Reviewed-by: Lars Knoll --- diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 1f1ed42..c5f841b 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -804,14 +804,9 @@ void Codegen::variableDeclaration(VariableDeclaration *ast) assert(expr.code); initializer = *expr; - if (! _env->parent || _function->insideWithOrCatch || _env->compilationMode == QmlBinding) { - // it's global code. - move(_block->NAME(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), initializer); - } else { - const int index = _env->findMember(ast->name.toString()); - assert(index != -1); - move(_block->LOCAL(index, 0), initializer); - } + int initialized = _block->newTemp(); + move(_block->TEMP(initialized), initializer); + move(identifier(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), _block->TEMP(initialized)); } void Codegen::variableDeclarationList(VariableDeclarationList *ast)