Browse Source

test double set_stack

see #12213
Simon Krajewski 3 months ago
parent
commit
88bb6af34d
2 changed files with 3 additions and 1 deletions
  1. 1 1
      std/js/_std/haxe/Exception.hx
  2. 2 0
      tests/unit/src/unit/issues/Issue12213.hx

+ 1 - 1
std/js/_std/haxe/Exception.hx

@@ -113,7 +113,7 @@ class Exception extends NativeException {
 	@:noCompletion
 	@:noCompletion
 	function setProperty(name:String, value:Any):Void {
 	function setProperty(name:String, value:Any):Void {
 		try {
 		try {
-			js.lib.Object.defineProperty(this, name, {value:value});
+			js.lib.Object.defineProperty(this, name, {value:value, writable: true});
 		} catch(e:Exception) {
 		} catch(e:Exception) {
 			js.Syntax.code('{0}[{1}] = {2}', this, name, value);
 			js.Syntax.code('{0}[{1}] = {2}', this, name, value);
 		}
 		}

+ 2 - 0
tests/unit/src/unit/issues/Issue12213.hx

@@ -15,6 +15,8 @@ class Issue12213 extends Test {
 				Method("Class", "method"),
 				Method("Class", "method"),
 				LocalFunction(0)
 				LocalFunction(0)
 			];
 			];
+			e.stack = [];
+			// test if we can set again because that might be a special case
 			e.stack = stack;
 			e.stack = stack;
 			utest.Assert.same(stack, e.stack);
 			utest.Assert.same(stack, e.stack);
 		}
 		}