소스 검색

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

Aleksandr Kuzmenko 4 년 전
부모
커밋
e6276d20db
4개의 변경된 파일24개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      extra/CHANGES.txt
  2. 1 0
      std/js/_std/haxe/Exception.hx
  3. 17 0
      tests/misc/projects/Issue9968/Main.hx
  4. 5 0
      tests/misc/projects/Issue9968/compile.hxml

+ 1 - 0
extra/CHANGES.txt

@@ -13,6 +13,7 @@
 	macro : added return type hint to haxe.macro.MacroStringTools.formatString (#9928)
 	cs : fixed catching exceptions from static closures (#9957)
 	eval : fixed `Std.random(arg)` for `arg` values of more than 30 bits (#9974)
+	js : fixed `haxe.CallStack.exceptionStack` (#9968)
 
 2020-09-11 4.1.4:
 

+ 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