LambdaS5 icon indicating copy to clipboard operation
LambdaS5 copied to clipboard

Failed to conform to ES5.1, Section 10.2.1.1.3 SetMutableBinding (N,V,S), Step 4

Open daejunpark opened this issue 10 years ago • 2 comments

It seems to me that S5 does not conform to ES5.1, Section 10.2.1.1.3 SetMutableBinding (N,V,S), Step 4, if-condition is true.

For the following test program:

// 10.2.1.1.3 SetMutableBinding (N,V,S), Step 4, if-condition is true

// 4. Else this must be an attempt to change the value of an immutable binding so if S if true throw a TypeError exception.

// In a strict mode, assigning an immutable binding throws TypeError.

// There are only two ways to create an immutable binding:
//   1. 'arguments' is an immutable binding in a strict mode function.
//   2. name of a recursive function expression (it should be a function 'expression', not a function 'declaration') is an immutable binding of the function body's environment.
// In the first case, assigning such binding raises a syntax error, in advance, in a strict mode code, thus it cannot reach here.
// Thus, assigning the second kind of binding is the only case that can reach here, and the below example represents this case.

// In the example below, 'g' is a name of recursive function expression, thus inside the function body, 'g' is a immutable binding.
// Note that 'g' is not visible outside of the function body, that is, it is not visible in a global scope.

"use strict";
var f = function g() {
  g = 0;
};
try {
  f(); // TypeError
  throw "Not here!";
} catch (e) {
  if (!(e instanceof TypeError)) {
    $ERROR('"use strict"; var f = function g() { g = 0; }; f(); throws TypeError. Actual: ' + e);
  }
}

S5 throws an exception, while it should have succeeded:

$ ./s5-test262 /tmp/09.js 
../envs/es5.env:6:0-5029:0
<unknown>:20:-1--4
<unknown>:20:-1--4
<unknown>:20:-1--4
<unknown>:24:-3-25:-98
<unknown>:25:-5--97
<unknown>:25:-5--11
../envs/es5.env:977:28-983:3
../envs/es5.env:980:11-982:5
../envs/es5.env:287:28-293:1
Uncaught exception: {[#proto: @9, #class: "Object", #extensible: true,]
 'message' : {#value "Unbound identifier: $ERROR" ,
              #writable true ,
              #configurable false}}

Fatal error: exception Failure("Runtime error")

Is there anything that I'm missing?

daejunpark avatar Apr 07 '15 00:04 daejunpark

The same bug was reported for v8 and Webkit: https://code.google.com/p/v8/issues/detail?id=2243 https://bugs.webkit.org/show_bug.cgi?id=138858

daejunpark avatar Apr 07 '15 06:04 daejunpark

In this example, I think that some support code is missing. S5 is reporting that $ERROR is unbound, so maybe this was part of the test infrastructure that's missing?

The program on the WebKit page

(function f() { f = 123; })()

does indeed produce undefined rather than an error though, so I think there's something to investigate in S5 here. Thanks!

jpolitz avatar Apr 15 '15 17:04 jpolitz