if (IS_NULL(obj)) return 'null';
if (IS_FUNCTION(obj)) return %_CallFunction(obj, FunctionToString);
if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") === ObjectToString) {
- var constructor = obj.constructor;
+ var constructor = %GetDataProperty(obj, "constructor");
if (typeof constructor == "function") {
var constructorName = constructor.name;
if (IS_STRING(constructorName) && constructorName !== "") {
assertEquals(["null: e2",[1,2,3,4]], testErrorToString(null, "e2"));
assertEquals(["e2",[1,2,3,4]], testErrorToString("", "e2"));
assertEquals(["e1: e2",[1,2,3,4]], testErrorToString("e1", "e2"));
+
+var obj = {
+ get constructor () {
+ assertUnreachable();
+ }
+};
+
+assertThrows(function() { obj.x(); });