Browse Source

Fixed getOwnPropStr() for mapped argument values when they are redefined. See #266.

Dmitry Panov 4 years ago
parent
commit
7e3a2f1901
2 changed files with 9 additions and 19 deletions
  1. 9 13
      object_args.go
  2. 0 6
      tc39_test.go

+ 9 - 13
object_args.go

@@ -18,7 +18,15 @@ func (a *argumentsObject) getStr(name unistring.String, receiver Value) Value {
 
 func (a *argumentsObject) getOwnPropStr(name unistring.String) Value {
 	if mapped, ok := a.values[name].(*mappedProperty); ok {
-		return *mapped.v
+		if mapped.writable && mapped.enumerable && mapped.configurable {
+			return *mapped.v
+		}
+		return &valueProperty{
+			value:        *mapped.v,
+			writable:     mapped.writable,
+			configurable: mapped.configurable,
+			enumerable:   mapped.enumerable,
+		}
 	}
 
 	return a.baseObject.getOwnPropStr(name)
@@ -45,18 +53,6 @@ func (a *argumentsObject) setForeignStr(name unistring.String, val, receiver Val
 	return a._setForeignStr(name, a.getOwnPropStr(name), val, receiver, throw)
 }
 
-/*func (a *argumentsObject) putStr(name string, val Value, throw bool) {
-	if prop, ok := a.values[name].(*mappedProperty); ok {
-		if !prop.writable {
-			a.val.runtime.typeErrorResult(throw, "Property is not writable: %s", name)
-			return
-		}
-		*prop.v = val
-		return
-	}
-	a.baseObject.putStr(name, val, throw)
-}*/
-
 func (a *argumentsObject) deleteStr(name unistring.String, throw bool) bool {
 	if prop, ok := a.values[name].(*mappedProperty); ok {
 		if !a.checkDeleteProp(name, &prop.valueProperty, throw) {

+ 0 - 6
tc39_test.go

@@ -268,12 +268,6 @@ var (
 		"test/language/statements/for-in/head-var-bound-names-dup.js": true,
 		"test/language/statements/for/head-let-destructuring.js":      true,
 		"test/language/statements/for-in/head-let-destructuring.js":   true,
-
-		// arguments exotic-object specifics
-		"test/language/arguments-object/mapped/nonconfigurable-descriptors-with-param-assign.js":              true,
-		"test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-with-define-property.js": true,
-		"test/language/arguments-object/mapped/nonconfigurable-descriptors-basic.js":                          true,
-		"test/language/arguments-object/mapped/nonconfigurable-descriptors-set-value-by-arguments.js":         true,
 	}
 
 	featuresBlackList = []string{