From: Simon Hausmann Date: Fri, 25 Jan 2013 14:52:42 +0000 (+0100) Subject: Fix remaining issues with the delete operator X-Git-Tag: upstream/5.2.1~669^2~659^2~375 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3935a84333f9e367b6f23fff4135f3cd5652d0e5;p=platform%2Fupstream%2Fqtdeclarative.git Fix remaining issues with the delete operator Delete on known temps should return true and false on known local variables. Change-Id: I71be8361306eb825b975a3aee294665eb8561366 Reviewed-by: Lars Knoll --- diff --git a/qmljs_environment.cpp b/qmljs_environment.cpp index a4db06a..8b2be30 100644 --- a/qmljs_environment.cpp +++ b/qmljs_environment.cpp @@ -251,14 +251,26 @@ void ExecutionContext::destroy() bool ExecutionContext::deleteProperty(String *name) { + bool hasWith = false; for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { if (ctx->withObject) { + hasWith = true; if (ctx->withObject->__hasProperty__(this, name)) return ctx->withObject->__delete__(this, name); } else { if (ctx->activation && ctx->activation->__hasProperty__(this, name)) return ctx->activation->__delete__(this, name); } + if (FunctionObject *f = ctx->function) { + if (f->needsActivation || hasWith) { + for (unsigned int i = 0; i < f->varCount; ++i) + if (f->varList[i]->isEqualTo(name)) + return false; + for (int i = (int)f->formalParameterCount - 1; i >= 0; --i) + if (f->formalParameterList[i]->isEqualTo(name)) + return false; + } + } } if (strictMode) throwSyntaxError(0); diff --git a/qv4codegen.cpp b/qv4codegen.cpp index 9575bc1..e5d9994 100644 --- a/qv4codegen.cpp +++ b/qv4codegen.cpp @@ -1322,6 +1322,10 @@ bool Codegen::visit(DeleteExpression *ast) _expr.code = _block->CONST(IR::BoolType, 1); return false; } + if (expr->asTemp() && expr->asTemp()->index >= _env->members.size()) { + _expr.code = _block->CONST(IR::BoolType, 1); + return false; + } IR::ExprList *args = _function->New(); args->init(reference(expr)); diff --git a/tests/TestExpectations b/tests/TestExpectations index b04ad1d..8fffc99 100644 --- a/tests/TestExpectations +++ b/tests/TestExpectations @@ -32,9 +32,6 @@ S11.3.2_A4_T1 failing S11.3.2_A4_T2 failing S11.3.2_A4_T3 failing S11.3.2_A4_T4 failing -11.4.1-2-5 failing -11.4.1-4.a-5 failing -S11.4.1_A2.1 failing S11.5.3_A4_T2 failing S11.8.6_A3 failing S11.8.6_A5_T2 failing @@ -95,4 +92,6 @@ Sbp_A3_T1 failing Sbp_A4_T1 failing Sbp_A4_T2 failing S12.4_A1 failing -S15.2.4.4_A14 failing \ No newline at end of file +S15.2.4.4_A14 failing +# Try/catch scoping issue +S12.14_A4 failing \ No newline at end of file