-
Notifications
You must be signed in to change notification settings - Fork 323
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
Print values even if their to_text
returns a non-text method, to aid with debugging.
#6154
Conversation
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode, | ||
@Cached ExpectStringNode expectStringNode) { | ||
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode) { | ||
var str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message}); | ||
EnsoContext ctx = EnsoContext.get(this); | ||
print(ctx.getOut(), expectStringNode.execute(str)); | ||
print(ctx.getOut(), str); |
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.
The ExpectStringNode
was also dealing with stripping warnings from this value.
Now, if I understand it correctly, the warnings will be printed if present. Although tbh I did not test it yet - probably worth doing first.
Still, I know there were different opinions on this - are we ok with printing warnings, do we want to keep dropping them or do we want to print them to stderr?
cc: @jdunkerley @JaroslavTulach
I like printing them like currently, we can always clear them if we do not want them in the output.
I'm not a fan of the stderr
idea, because it may be unexpected (we should have a separate method to print to stderr) and it may be hard to keep track which warnings were associated with which value if many values are printed.
Maybe the best solution will be to duplicate println
into a IO.debug_print
node?
Then we could have println
keep the existing behaviour, always expecting text returned from to_text
and failing with type error if that invariant is broken. And debug_print
would be more lenient about types and also would print warnings?
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.
Based on Rust print vs. debug print:
Maybe the best solution will be to duplicate println into a IO.debug_print node?
IO.println warnings=True "Hi with warnings"
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.
I think having the control to print warnings would be good - my feeling is we should print the value without warnings by default ad then have the option to show warnings.
This would be consistent with our visualizations in the IDE as well.
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.
Ok, that sounds good. I guess we need to add an IO.println_builtin
to be able to add a default argument (since a builtin cannot directly have default arguments, right? cc: @JaroslavTulach or was this limitation lifted?) and I will make warnings=False
by default.
I'll update this PR once I have some more free time, probably after I finish the full join PR.
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.
we need to add an
IO.println_builtin
to be able to add a default argument (since a builtin cannot directly have default arguments, right? cc: @JaroslavTulach or was this limitation lifted?)
Yes, separate builtin method is needed. The limitation is still there:
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.
We certainly want to print something every time for every value and avoid throwing errors.
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode, | ||
@Cached ExpectStringNode expectStringNode) { | ||
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode) { | ||
var str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message}); | ||
EnsoContext ctx = EnsoContext.get(this); | ||
print(ctx.getOut(), expectStringNode.execute(str)); | ||
print(ctx.getOut(), str); |
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.
Based on Rust print vs. debug print:
Maybe the best solution will be to duplicate println into a IO.debug_print node?
IO.println warnings=True "Hi with warnings"
8e2b8c9
to
a25523e
Compare
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode, | ||
@Cached ExpectStringNode expectStringNode) { | ||
@Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode) { | ||
var str = invokeCallableNode.execute(symbol, frame, state, new Object[] {message}); | ||
EnsoContext ctx = EnsoContext.get(this); | ||
print(ctx.getOut(), expectStringNode.execute(str)); | ||
print(ctx.getOut(), str); |
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.
I think having the control to print warnings would be good - my feeling is we should print the value without warnings by default ad then have the option to show warnings.
This would be consistent with our visualizations in the IDE as well.
…debugging easier. Also print if warnings are attached.
a25523e
to
fddb05c
Compare
I got piled up in a bit of a rabbit hole trying to add a Regardless - the handling of warnings makes the I'm not sure what format do we expect either? I tried to do If we add the warnings as a non-default, I don't think it makes as much sense and we can always implement it as something like following in Enso stdlib:
If you think the warnings should be handled by the builtin, I can reopen this, but IMO it's not as needed. Instead I opened a PR that just handles the fix for #5961: |
Pull Request Description
Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.