Skip to content

Commit

Permalink
[php7] Save stack of a caught exception only if CallStack.exceptionSt…
Browse files Browse the repository at this point in the history
…ack() is used somewhere (fixes #6046)
  • Loading branch information
RealyUniqueName committed Feb 20, 2017
1 parent d3d2588 commit 2b619a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/generators/genphp7.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions std/php7/_std/haxe/CallStack.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ enum StackItem {
LocalFunction( ?v : Int );
}

@:dox(hide)
@:noCompletion
class CallStack {
@:ifFeature("haxe.CallStack.exceptionStack")
static var lastExceptionTrace : NativeTrace;

/**
Expand Down Expand Up @@ -73,7 +72,7 @@ class CallStack {
}
}

@:keep
@:ifFeature("haxe.CallStack.exceptionStack")
static function saveExceptionTrace( e:Throwable ) : Void {
lastExceptionTrace = e.getTrace();

Expand Down

0 comments on commit 2b619a7

Please sign in to comment.