-
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
Avoid discarded (error) values in runtime #5430
Comments
I've found yet another place where this could save issues. The cloud Index: test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso
--- a/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso (revision 527a9c221a2583352f46aee8264a31b80f3acabb)
+++ b/test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso (date 1708002992169)
@@ -192,6 +192,7 @@
nested_file.exists . should_be_false
main =
+ setup = Cloud_Tests_Setup.prepare
suite = Test.build suite_builder->
- add_specs suite_builder
+ add_specs suite_builder setup
suite.run_with_filter If not any value other than |
I have no idea what runtime pass may mean? There are no passes in runtime. |
I imagine it's a metaphor. It would have to be implemented by creating e.g.
the result of |
Afterthought: I probably meant a static pass that inserts a runtime check. |
Partially fixes #5430 by propagating `DataflowError`s found during statement execution out of the method. # Important Notes This change [may affect behavior](https://github.com/enso-org/enso/pull/11673/files#r1871128327) of existing methods that ignore `DataflowError` as [discussed here](https://github.com/enso-org/enso/pull/11673/files#r1871128327).
This task is automatically imported from the old Task Issue Board and it was originally created by Radosław Waśko.
Original issue is here.
Whenever a function result is discarded (not assigned to a variable, passed as an argument or returned from the function) but it is different from
Nothing
, it likely indicates a programming error.For example, if we have:
The first
foo
call withinmain
will only print hello and bye, but the call tofun
will not proceed because it expects more arguments. We can detect that a statement that was supposed to be side-effectful returned something else than aNothing
and thus know that likely a mistake has happened. The secondfoo
call withinmain
will indeed print20
alongside hello and bye.Of course in some situations it may make sense to discard a non-Nothing result of some action, but if this is intended behaviour, it can always be marked by assigning it to an unused variable name, like so:
In such case the intent to discard the value is clearly marked. In other cases, discarding values is most likely a programming error and so it may be worth to warn about such cases.
A runtime linter pass could check values of statements which discard the result and if the value is different from
Nothing
it can report a "runtime warning".There are a few considerations to such runtime lints though:
Comments:
To be reviewed as to whether this is the correct path forward. (James Dunkerley - Feb 3, 2023)
The text was updated successfully, but these errors were encountered: