#define JS_THROW_VAR_UNINITIALIZED 2
#define JS_THROW_ERROR_DELETE_SUPER 3
#define JS_THROW_ERROR_ITERATOR_THROW 4
+#define JS_THROW_ERROR_INVALID_LVALUE_CALL 5
{
JSAtom atom;
int type;
else
if (type == JS_THROW_ERROR_ITERATOR_THROW)
JS_ThrowTypeError(ctx, "iterator does not have a throw method");
+ else
+ if (type == JS_THROW_ERROR_INVALID_LVALUE_CALL)
+ JS_ThrowReferenceError(ctx, "invalid assignment left-hand side");
else
JS_ThrowInternalError(ctx, "invalid throw var type %d", type);
}
scope = 0;
name = JS_ATOM_NULL;
label = -1;
- depth = 0;
switch(opcode = get_prev_opcode(fd)) {
case OP_scope_get_var:
name = get_u32(fd->byte_code.buf + fd->last_opcode_pos + 1);
case OP_get_super_value:
depth = 3;
break;
+ case OP_call:
+ case OP_call_method:
+ /* Annex B: allow call expression as assignment target in
+ non-strict mode, but throw ReferenceError at runtime. */
+ if ((fd->js_mode & JS_MODE_STRICT) ||
+ tok == TOK_LAND_ASSIGN || tok == TOK_LOR_ASSIGN ||
+ tok == TOK_DOUBLE_QUESTION_MARK_ASSIGN ||
+ tok == '[' || tok == '{') {
+ goto invalid_lvalue;
+ }
+ emit_op(s, OP_throw_error);
+ emit_u32(s, JS_ATOM_NULL);
+ emit_u8(s, JS_THROW_ERROR_INVALID_LVALUE_CALL);
+ opcode = OP_call;
+ depth = 0;
+ break;
default:
invalid_lvalue:
if (tok == TOK_FOR) {
}
}
/* remove the last opcode */
- fd->byte_code.size = fd->last_opcode_pos;
- fd->last_opcode_pos = -1;
-
+ if (opcode != OP_call) {
+ fd->byte_code.size = fd->last_opcode_pos;
+ fd->last_opcode_pos = -1;
+ }
+
if (keep) {
/* get the value but keep the object/fields on the stack */
switch(opcode) {
emit_op(s, OP_dup3);
emit_op(s, OP_get_super_value);
break;
+ case OP_call:
+ break;
default:
abort();
}
abort();
}
break;
+ case OP_call:
default:
break;
}
case OP_get_super_value:
emit_op(s, OP_put_super_value);
break;
+ case OP_call:
+ break;
default:
abort();
}
}
break;
}
+ if (call_type == FUNC_CALL_TEMPLATE) {
+ /* annex B: syntax error if used as lvalue */
+ s->cur_func->last_opcode_pos = -1;
+ }
}
call_type = FUNC_CALL_NORMAL;
} else if (s->token.val == '.') {
-test262/test/annexB/language/expressions/assignmenttargettype/callexpression-as-for-in-lhs.js:27: SyntaxError: invalid for in/of left hand-side
-test262/test/annexB/language/expressions/assignmenttargettype/callexpression-as-for-of-lhs.js:27: SyntaxError: invalid for in/of left hand-side
-test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-compound-assignment.js:33: SyntaxError: invalid assignment left-hand side
-test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-postfix-update.js:27: SyntaxError: invalid increment/decrement operand
-test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-prefix-update.js:27: SyntaxError: invalid increment/decrement operand
-test262/test/annexB/language/expressions/assignmenttargettype/callexpression.js:33: SyntaxError: invalid assignment left-hand side
-test262/test/annexB/language/expressions/assignmenttargettype/cover-callexpression-and-asyncarrowhead.js:20: SyntaxError: invalid assignment left-hand side
test262/test/built-ins/Promise/try/avoids-wrap-for-subclass.js:10: Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true
test262/test/built-ins/Promise/try/avoids-wrap.js:10: Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true
test262/test/language/expressions/assignment/S11.13.1_A6_T1.js:23: Test262Error: #1: innerX === undefined. Actual: 1