ref: 9e9f168cbb71002806e760f270a1e783210aa9b1
parent: aa18ef32a67e03aea52890628ce530f73fe0564c
author: Tor Andersson <tor.andersson@gmail.com>
date: Mon Apr 17 10:09:24 EDT 2017
Add strictness check when setting a property that only has a getter.
--- a/jsrun.c
+++ b/jsrun.c
@@ -580,13 +580,19 @@
/* First try to find a setter in prototype chain */
ref = jsV_getpropertyx(J, obj, name, &own);
- if (ref && ref->setter) {
- js_pushobject(J, ref->setter);
- js_pushobject(J, obj);
- js_pushvalue(J, *value);
- js_call(J, 1);
- js_pop(J, 1);
- return;
+ if (ref) {
+ if (ref->setter) {
+ js_pushobject(J, ref->setter);
+ js_pushobject(J, obj);
+ js_pushvalue(J, *value);
+ js_call(J, 1);
+ js_pop(J, 1);
+ return;
+ } else {
+ if (J->strict)
+ if (ref->getter)
+ js_typeerror(J, "setting property '%s' that only has a getter", name);
+ }
}
/* Property not found on this object, so create one */