-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
refactor dbg for if #14075
base: main
Are you sure you want to change the base?
refactor dbg for if #14075
Conversation
@@ -803,7 +803,8 @@ defmodule MacroTest do | |||
true | |||
else | |||
:error -> false | |||
end | |||
end, | |||
print_location: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses the dbg function and prints the header now in the test output before it crashes, so it has to be muted.
Before the changes any crash was silent.
unquote(__MODULE__).__print_dbg_header__(unquote(header), options) | ||
options = unquote(__MODULE__).__update_options__(options) | ||
to_debug = unquote(dbg_ast_to_debuggable(code, env, options)) | ||
unquote(__MODULE__).__dbg__(to_debug, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not great.
I read the discussion in the other issue, but chiming in only now. So, are we sure the best approach here is to print along the way just in case something raises? Right now the
Maybe a good approach here would be to |
We discussed try/catch it and I would like to avoid that if possible. My concern is about changing the execution semantics too much and then the debugger starts affecting the system itself. |
@dkuku I think there is probably a cleaner solution here which is to break |
👍🏻 ok, got it |
@josevalim I’m just concerned about turning this into a pure operation (AST → AST with output as well) into an impure one, where we write to stdout as we go. I’m a bit out of touch with this, we might already have something callback-based and whatnot, but just wanted to make sure to call it out. |
@whatyouhide my proposal is to keep it as is, we just offer a bit more of granularity. For example, |
@josevalim yeah I guess that's a good and not-very-invasive option to go for for the time being. 🙃 |
@josevalim This is what I came up.
It requires calling the macro module where we have defined the functions that print the data.
It looks a bit confusing calling
Macro.write
so I think it makes sense to move all the logic tomacro/dbg.ex
then the implementation would callDbg.write
or similar. In case it will show up in traces it will look less confusing.