From 2b619a717364da505a8a49de36508b6856015065 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenko Date: Mon, 20 Feb 2017 10:48:20 +0300 Subject: [PATCH] [php7] Save stack of a caught exception only if CallStack.exceptionStack() is used somewhere (fixes #6046) --- src/generators/genphp7.ml | 2 +- std/php7/_std/haxe/CallStack.hx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/generators/genphp7.ml b/src/generators/genphp7.ml index 12732c5015e..4b62f3c1981 100644 --- a/src/generators/genphp7.ml +++ b/src/generators/genphp7.ml @@ -2113,7 +2113,7 @@ class virtual type_builder ctx wrapper = self#write_as_block try_expr; self#write " catch (\\Throwable $__hx__caught_e) {\n"; self#indent_more; - if ctx.debug then + if has_feature ctx "haxe.CallStack.exceptionStack" then self#write_statement ((self#use (["haxe"], "CallStack")) ^ "::saveExceptionTrace($__hx__caught_e)"); self#write_statement ("$__hx__real_e = ($__hx__caught_e instanceof " ^ haxe_exception ^ " ? $__hx__caught_e->e : $__hx__caught_e)"); self#write_indentation; diff --git a/std/php7/_std/haxe/CallStack.hx b/std/php7/_std/haxe/CallStack.hx index 5decfe17956..56a2209928e 100644 --- a/std/php7/_std/haxe/CallStack.hx +++ b/std/php7/_std/haxe/CallStack.hx @@ -15,9 +15,8 @@ enum StackItem { LocalFunction( ?v : Int ); } -@:dox(hide) -@:noCompletion class CallStack { + @:ifFeature("haxe.CallStack.exceptionStack") static var lastExceptionTrace : NativeTrace; /** @@ -73,7 +72,7 @@ class CallStack { } } - @:keep + @:ifFeature("haxe.CallStack.exceptionStack") static function saveExceptionTrace( e:Throwable ) : Void { lastExceptionTrace = e.getTrace();