Skip to content
Snippets Groups Projects
  • André Bargull's avatar
    c5e18d56
    Assignment with left-hand side property accessor · c5e18d56
    André Bargull authored
    The assignment operator evaluates its operands from left to right. When
    the left-hand side expression is a property accessor, RequireObjectCoercible
    and ToPropertyKey are called on the property accessor before the right-hand
    side expression is evaluated.
    c5e18d56
    History
    Assignment with left-hand side property accessor
    André Bargull authored
    The assignment operator evaluates its operands from left to right. When
    the left-hand side expression is a property accessor, RequireObjectCoercible
    and ToPropertyKey are called on the property accessor before the right-hand
    side expression is evaluated.
S11.13.1_A7_T1.js 913 B
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: Assignment Operator evaluates its operands from left to right.
description: >
    The left-hand side expression is evaluated before the right-hand side.
    Left-hand side expression is MemberExpression: base[prop]. base is the
    null value.
---*/

function DummyError() { }

assert.throws(DummyError, function() {
  var base = null;
  var prop = function() {
    throw new DummyError();
  };
  var expr = function() {
    $ERROR("right-hand side expression evaluated");
  };

  base[prop()] = expr();
});

assert.throws(TypeError, function() {
  var base = null;
  var prop = {
    toString: function() {
      $ERROR("property key evaluated");
    }
  };
  var expr = function() {
    $ERROR("right-hand side expression evaluated");
  };

  base[prop] = expr();
});