Propagate Warnings and Errors from ignored return values #7754
GregoryTravis
started this conversation in
Ideas and feedback
Replies: 2 comments 3 replies
-
@JaroslavTulach @jdunkerley Thoughts? |
Beta Was this translation helpful? Give feedback.
2 replies
-
What would be the effect on |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The big goal here is to make sure that Enso warnings and errors are never lost, even if they are the result of sloppy programming.
To this end, @radeusgd suggests that we add special handling to ignored return values, if they are errors, or have warnings attached.
Currently, if no return values are ignored, and there are no
Unused variable
warnings, I believe we can be confident[1] that the dataflow-based propagation of warnings/errors will ensure that these are never lost, and always propagated to the user.However, some end users will choose to ignore
Unused variable
warnings. And, even worse, forgetting to handle a function's return value is easy to do accidentally.The proposal is that for any ignored return value, if there is a warning/error, we propagate/attach it to the return value of the block containing the ignored value line.
For example:
Warnings/errors coming from
f1
andf3
are fine, since they propagate properly to the return value, and then up the call chain.Warnings/errors from
f2
are lost, however.It seems possible to find such code statically, and insert code to propagate errors, and attach warnings to the value returned from the containing block:
Viewing warning/error propagation monadically, this is the same as automatically handling the failure case at every step, even when the result is ignored by the steps coming after it.
[1] It's possible there are other ways to lose warnings/errors that I am not aware of.
Beta Was this translation helpful? Give feedback.
All reactions