-
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
Promote broken values instead of ignoring them #11777
Conversation
...ion-tests/src/test/java/org/enso/interpreter/test/semantic/DataflowErrorPropagationTest.java
Show resolved
Hide resolved
for (ExpressionNode statement : statements) { | ||
statement.executeGeneric(frame); | ||
var result = statement.executeGeneric(frame); | ||
if (result != nothing) { |
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.
Why not get rid of this if statement and use simply just if (result instanceof DataflowError err)
. If it is an instance of DataflowError
, it cannot be nothing.
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.
Indeed this seems redundant, can we remove it, or is there some reason that we don't see here?
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 reason is the other part of #5430:
- what should happen when the value is not
Nothing
- and it is not
DataflowError
(which is immediately returned) - Avoid discarded (error) values in runtime #5430 talks about such values, but
- I don't know what to do with them (they are not as simple as
DataflowError
) - related is Unexpected block behaviour with multiline operators #9944
We don't need to solve it in this PR. Just my 2 Kč explanation of the != Nothing
check. In any case, that's for another PR.
There are two failed tests in standard libraries: This is the kind of errors we can expect if we enable this Btw. this change makes the diff --git test/Base_Tests/src/Data/Decimal_Spec.enso test/Base_Tests/src/Data/Decimal_Spec.enso
index 3465ce9cd8..6e3a463b82 100644
--- test/Base_Tests/src/Data/Decimal_Spec.enso
+++ test/Base_Tests/src/Data/Decimal_Spec.enso
@@ -487,7 +487,7 @@ add_specs suite_builder =
(Decimal.from_integer 7297927982888383 . multiply (Decimal.from_integer 828737) (Math_Context.new 6)) . should_equal (Decimal.from_integer 6048060000000000000000 )
(Decimal.new "893872388.3535345" . multiply (Decimal.new "72374727737.23434535") (Math_Context.new 14)) . should_equal (Decimal.new "64693770738918000000")
- (Decimal.new "909678645268840" . divide (Decimal.new "28029830") (Math_Context.new 6)) . should_equal (Decimal.new "32453900 ")
+ _ = (Decimal.new "909678645268840" . divide (Decimal.new "28029830") (Math_Context.new 6)) . should_equal (Decimal.new "32453900 ")
(Decimal.new "384456406.7860325392609633764" . divide (Decimal.new "24556.125563546") (Math_Context.new 7)) . should_equal (Decimal.new "15656.23")
(Decimal.from_integer 3948539458034580838458034803485 . add (Decimal.from_integer 237957498573948579387495837459837) (Math_Context.new 20)) . should_equal (Decimal.from_integer 241906038031983160230000000000000) e.g. exactly as expected it is enough to add a dummy assignment and the problem goes away. I assume you want to do a better fix @GregoryTravis - please integrate it into my branch, so it gets green. diff --git test/Base_Tests/src/Data/Time/Date_Range_Spec.enso test/Base_Tests/src/Data/Time/Date_Range_Spec.enso
index b2b469ae1c..22843aa6cb 100644
--- test/Base_Tests/src/Data/Time/Date_Range_Spec.enso
+++ test/Base_Tests/src/Data/Time/Date_Range_Spec.enso
@@ -157,7 +157,7 @@ add_specs suite_builder =
r.partition p . should_equal (r.to_vector.partition p)
r.all p . should_equal (r.to_vector.all p)
r.any p . should_equal (r.to_vector.any p)
- r.find p . should_equal (r.to_vector.find p)
+ _ = r.find p . should_equal (r.to_vector.find p)
r.index_of p . should_equal (r.to_vector.index_of p)
r.last_index_of p . should_equal (r.to_vector.last_index_of p)
count_mondays acc date =
@@ -170,7 +170,7 @@ add_specs suite_builder =
r.partition fc . should_equal (r.to_vector.partition fc)
r.all fc . should_equal (r.to_vector.all fc)
r.any fc . should_equal (r.to_vector.any fc)
- r.find fc . should_equal (r.to_vector.find fc)
+ _ = r.find fc . should_equal (r.to_vector.find fc)
r.index_of fc . should_equal (r.to_vector.index_of fc)
r.last_index_of fc . should_equal (r.to_vector.last_index_of fc) same for |
…wrongly written test
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.
Santa came early this year! 🎄
I'm so happy to finally see this change - deep down I knew we may be losing something due to the unhandled errors disappearing into the void. And you confirmed my suspicions. Thankfully that isn't that many errors and they look relatively harmless. But I'm happy that from now on I can keep writing code with the peace of mind that errors will go on unnoticed.
Also we can now remove most instances of if_not_error
- yay! 🎉 It was basically a workaround for ensuring error propagation. I guess we want to keep the function because it is still useful when we want to control the propagation with 'more precision'. But in numerous cases it should be no longer needed and we can remove a lot of unnecessary indentation from the code.
I submitted commits that fix should_equal
silently breaking if expected value provided is dataflow error (in that case should_fail_with
is expected). I will add a commit fixing the Date_Range_Spec
tests in a moment.
... we already published first customer releases and we are dedicated to backward compatibility, right? |
Engine benchmarks run is fine - looks like nobody writes benchmarks for errors ;-) I also glanced StdLib benchmarks run and found nothing suspicious. |
@radeusgd, @GregoryTravis there are still failures in stdlib tests: Can you fix them? |
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.
Approving the libs bits.
…ateDataflowError5429
Except these two errors: There seem to be additional ones: |
I will look at these, after the release. |
engine/runtime/src/main/java/org/enso/interpreter/node/callable/function/BlockNode.java
Show resolved
Hide resolved
I think I have fixed all the test failures in stdlib, let's see what the CI says. I also scheduled a run of the nightly CI: https://github.com/enso-org/enso/actions/runs/12378958829 - not sure if Snowflake will run as it has failing tests on develop but we can at least see if there are no more failures than expected.
|
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.
Thank you guys for fixing the test failures. Radek, I don't like the rhs_error_check
"friend API situation". We shouldn't be cheating like this (at least not in my PR ;-).
p.first != p.second | ||
"; first difference at index " + diff.to_text + " " | ||
False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") " | ||
Any.should_equal self that frames_to_skip=0 = rhs_error_check that <| |
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.
Finally I see it. This wraps the original code in rhs_error_check
helper function. It doesn't change API of Any.should_equal
(it is not easy to see that when argument definition is mixed with code on the same line). As a result of the additional function call, the frames shift and thus 4+frame_to_skip
. The rest remains unchanged.
@@ -294,15 +297,20 @@ Error.should_equal self that frames_to_skip=0 = | |||
1.00000001 . should_equal 1.00000002 epsilon=0.0001 | |||
Number.should_equal : Float -> Float -> Integer -> Spec_Result | |||
Number.should_equal self that epsilon=0 frames_to_skip=0 = | |||
matches = case that of |
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.
This change is way easier of parse, we the function signature clearly stays unaffected.
…ateDataflowError5430
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).
Pull Request Description
Partially fixes #5430 by propagating
DataflowError
s found during statement execution out of the method.Important Notes
This change may affect behavior of existing methods that ignore
DataflowError
as discussed here.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,