Selaa lähdekoodia

[js] fixed `haxe.CallStack.exceptionStack` (#9968)

Aleksandr Kuzmenko 4 vuotta sitten
vanhempi
commit
db0fa9524e

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

@@ -97,6 +97,7 @@ class Exception extends NativeException {
 		return __nativeException;
 	}
 
+	@:ifFeature('haxe.NativeStackTrace.exceptionStack')
 	function get_stack():CallStack {
 		return switch __exceptionStack {
 			case null:

+ 17 - 0
tests/misc/projects/Issue9968/Main.hx

@@ -0,0 +1,17 @@
+class Main {
+	static function main() {
+		try {
+			test();
+		}
+		catch (e:Dynamic) {
+			var stack = haxe.CallStack.exceptionStack();
+			if(stack.length == 0) {
+				throw 'haxe.CallStack.exceptionStack() returned empty array';
+			}
+		}
+	}
+
+	static public function test() {
+		throw 'sdffsd';
+	}
+}

+ 5 - 0
tests/misc/projects/Issue9968/compile.hxml

@@ -0,0 +1,5 @@
+--main Main
+--dce full
+--js bin/test.js
+
+--cmd node bin/test.js