Come up to current draft behavior for attempting to set a property that has
a getter but not a setter: throw a TypeError. git-svn-id: svn://10.0.0.236/trunk@256178 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
2deef7733e
commit
6c0e05102e
@ -2076,9 +2076,11 @@ public abstract class ScriptableObject implements Scriptable, Serializable,
|
||||
if (slot instanceof GetterSlot) {
|
||||
Object setterObj = ((GetterSlot)slot).setter;
|
||||
if (setterObj == null) {
|
||||
// Odd case: Assignment to a property with only a getter
|
||||
// defined. The assignment cancels out the getter.
|
||||
((GetterSlot)slot).getter = null;
|
||||
if (((GetterSlot)slot).getter != null) {
|
||||
// Based on TC39 ES3.1 Draft of 9-Feb-2009, 8.12.4, step 2,
|
||||
// we should throw a TypeError in this case.
|
||||
throw ScriptRuntime.typeError1("msg.set.prop.no.setter", name);
|
||||
}
|
||||
} else {
|
||||
Context cx = Context.getContext();
|
||||
if (setterObj instanceof MemberBox) {
|
||||
|
||||
@ -528,6 +528,9 @@ msg.ref.undefined.prop =\
|
||||
msg.prop.not.found =\
|
||||
Property {0} not found.
|
||||
|
||||
msg.set.prop.no.setter =\
|
||||
Cannot set property {0} that has only a getter.
|
||||
|
||||
msg.invalid.type =\
|
||||
Invalid JavaScript value of type {0}
|
||||
|
||||
|
||||
@ -4,6 +4,9 @@
|
||||
# test has yet to be fixed, or because the test is not applicable to Rhino.
|
||||
#
|
||||
|
||||
# bad test: cannot write a property that has only a getter defined
|
||||
js1_5/extensions/regress-341956-01.js
|
||||
|
||||
# timer resolution test
|
||||
js1_5/extensions/regress-363258.js
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user