Emit better error message about writable properties
Section 8.10.5 9a specifies that a property descriptor cannot both have accessors and specify the writability of the property. The previous error message was misleading because it referred to writable rather than specifying the writability (which includes writable: false). BUG=v8:2536 LOG=N Review URL: https://codereview.chromium.org/1399693003 Cr-Commit-Position: refs/heads/master@{#31273}
This commit is contained in:
parent
8f8457d2a4
commit
8ed0454332
1
AUTHORS
1
AUTHORS
@ -54,6 +54,7 @@ Erich Ocean <erich.ocean@me.com>
|
||||
Fedor Indutny <fedor@indutny.com>
|
||||
Felix Geisendörfer <haimuiba@gmail.com>
|
||||
Filipe David Manana <fdmanana@gmail.com>
|
||||
Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
|
||||
Geoffrey Garside <ggarside@gmail.com>
|
||||
Han Choongwoo <cwhan.tunz@gmail.com>
|
||||
Hirofumi Mako <mkhrfm@gmail.com>
|
||||
|
@ -237,8 +237,8 @@ class CallSite {
|
||||
T(SimdToNumber, "Cannot convert a SIMD value to a number") \
|
||||
T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \
|
||||
T(ValueAndAccessor, \
|
||||
"Invalid property. A property cannot both have accessors and be " \
|
||||
"writable or have a value, %") \
|
||||
"Invalid property descriptor. Cannot both specify accessors and a value " \
|
||||
"or writable attribute, %") \
|
||||
T(VarRedeclaration, "Identifier '%' has already been declared") \
|
||||
T(WithExpression, "% has no properties") \
|
||||
T(WrongArgs, "%: Arguments list has wrong type") \
|
||||
|
@ -332,8 +332,8 @@ test(function() {
|
||||
// kValueAndAccessor
|
||||
test(function() {
|
||||
Object.defineProperty({}, "x", { get: function(){}, value: 1});
|
||||
}, "Invalid property. A property cannot both have accessors and be " +
|
||||
"writable or have a value, #<Object>", TypeError);
|
||||
}, "Invalid property descriptor. Cannot both specify accessors " +
|
||||
"and a value or writable attribute, #<Object>", TypeError);
|
||||
|
||||
// kWithExpression
|
||||
test(function() {
|
||||
|
@ -34,7 +34,7 @@ PASS JSON.stringify(Object.defineProperties({},{property:{value:'foo'}, property
|
||||
PASS JSON.stringify(Object.defineProperties({property:'foo'},{property:{value:'foo', enumerable:true}, property2:{value:'foo', enumerable:true}})) is '{"property":"foo","property2":"foo"}'
|
||||
PASS JSON.stringify(Object.defineProperties({property:'foo'},{property:{value:'foo', enumerable:false}, property2:{value:'foo', enumerable:true}})) is '{"property2":"foo"}'
|
||||
PASS JSON.stringify(Object.defineProperties({property:'foo'},{property:{value:'foo'}, property2:{value:'foo', enumerable:true}})) is '{"property":"foo","property2":"foo"}'
|
||||
PASS Object.defineProperties(emptyObject, {foo:{value: true}, bar:{get:function(){}, writable:true}}) threw exception TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>.
|
||||
PASS Object.defineProperties(emptyObject, {foo:{value: true}, bar:{get:function(){}, writable:true}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
|
||||
PASS 'foo' in emptyObject is false
|
||||
PASS successfullyParsed is true
|
||||
|
||||
|
@ -45,17 +45,17 @@ PASS Object.defineProperty(null) threw exception TypeError: Object.definePropert
|
||||
PASS Object.defineProperty('foo') threw exception TypeError: Object.defineProperty called on non-object.
|
||||
PASS Object.defineProperty({}) threw exception TypeError: Property description must be an object: undefined.
|
||||
PASS Object.defineProperty({}, 'foo') threw exception TypeError: Property description must be an object: undefined.
|
||||
PASS Object.defineProperty({}, 'foo', {get:undefined, value:true}).foo threw exception TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {get:undefined, value:true}).foo threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
|
||||
PASS Object.defineProperty({get foo() { return true; } }, 'foo', {configurable:false}).foo is true
|
||||
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {configurable: true}) threw exception TypeError: Cannot redefine property: foo.
|
||||
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {writable: true}) threw exception TypeError: Cannot redefine property: foo.
|
||||
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {enumerable: true}) threw exception TypeError: Cannot redefine property: foo.
|
||||
PASS Object.defineProperty(createUnconfigurableProperty({}, 'foo', false, true), 'foo', {enumerable: false}), 'foo' threw exception TypeError: Cannot redefine property: foo.
|
||||
PASS JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty(createUnconfigurableProperty({}, 'foo', true), 'foo', {writable: false}), 'foo')) is JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})
|
||||
PASS Object.defineProperty({}, 'foo', {value:1, get: function(){}}) threw exception TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {value:1, set: function(){}}) threw exception TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {writable:true, get: function(){}}) threw exception TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {writable:true, set: function(){}}) threw exception TypeError: Invalid property. A property cannot both have accessors and be writable or have a value, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {value:1, get: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {value:1, set: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {writable:true, get: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {writable:true, set: function(){}}) threw exception TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>.
|
||||
PASS Object.defineProperty({}, 'foo', {get: null}) threw exception TypeError: Getter must be a function: null.
|
||||
PASS Object.defineProperty({}, 'foo', {set: null}) threw exception TypeError: Setter must be a function: null.
|
||||
PASS Object.defineProperty({}, 'foo', {set: setter}).foo='test' threw exception called setter.
|
||||
|
Loading…
Reference in New Issue
Block a user