-
-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[eval] Don't choke on env_parent = None #11679
Conversation
As I've said on Slack this isn't the right fix, and the problem suggests that there's something wrong with the exception management. |
Note that something wrong might be happening somewhere for this to happen...
This reverts commit dbba36c.
dbba36c
to
ec58537
Compare
ec58537
to
16312f8
Compare
So this comes from exceptions in build macros triggered by another build macro. Hopefully the included repro helps (along with the change in Note: should check eval debugger behavior here; will try to setup that... |
I think this is a decent change, but I worry that it fixes the issue only incidentally... Either way I'm fine with going ahead with this. |
With this, I can get the stack displayed with compiler too; but not sure we actually want that diff --git a/src/macro/eval/evalExceptions.ml b/src/macro/eval/evalExceptions.ml
index b3954e206..7140610ca 100644
--- a/src/macro/eval/evalExceptions.ml
+++ b/src/macro/eval/evalExceptions.ml
@@ -139,7 +139,15 @@ let catch_exceptions ctx ?(final=(fun() -> ())) f p =
end else
Error.raise_typing_error (Printf.sprintf "Unexpected value where haxe.macro.Error was expected: %s" (s_value 0 v).sstring) null_pos
) (EvalArray.to_list sub)
- | _ -> []
+ | _ ->
+ (* Careful: We have to get the message before resetting the context because toString() might access it. *)
+ let stack = match eval_stack with
+ | [] -> []
+ | l when p' = null_pos -> l (* If the exception position is null_pos, we're "probably" in a built-in function. *)
+ | _ :: l -> l (* Otherwise, ignore topmost frame position. *)
+ in
+ let stack = get_exc_error_stack ctx stack in
+ List.map (fun p -> (Error.Custom "Called from here", p)) (List.rev stack)
in
reset_ctx();
final();
Edit: surprisingly, this doesn't have a big impact on our misc tests:
Which actually sounds like a nice change to me, adding the position from where that macro was called:
|
Usual random windows/macro failure is unrelated |
Still not sure exactly how things go wrong here. Broke with 6e4fd96