From 39abd061fa5a14f4607505ca89515ba168bfab9b Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 27 Mar 2024 12:58:55 +0100 Subject: [PATCH 1/4] Add failing tests to Equals_Spec --- test/Base_Tests/src/Semantic/Equals_Spec.enso | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/Base_Tests/src/Semantic/Equals_Spec.enso b/test/Base_Tests/src/Semantic/Equals_Spec.enso index ac6b7f2fd688..fd68009445c7 100644 --- a/test/Base_Tests/src/Semantic/Equals_Spec.enso +++ b/test/Base_Tests/src/Semantic/Equals_Spec.enso @@ -1,4 +1,5 @@ from Standard.Base import all +import Standard.Base.Errors.Illegal_State.Illegal_State from Standard.Test import all @@ -229,6 +230,13 @@ add_specs suite_builder = f2 = CustomEqType.C2 10 f1==f2 . should_be_false + group_builder.specify "should propagate errors" <| + ((Error.throw (Illegal_State.Error "foo" )) == 42) . should_fail_with Illegal_State + ((Error.throw (Illegal_State.Error "foo" )) != 42) . should_fail_with Illegal_State + (42 == (Error.throw (Illegal_State.Error "foo" ))) . should_fail_with Illegal_State + (42 != (Error.throw (Illegal_State.Error "foo" ))) . should_fail_with Illegal_State + + suite_builder.group "Polyglot Operator ==" group_builder-> group_builder.specify "should not try to compare members" <| x = IntHolder.new 5 From 15f0098e524495204907ff0defbee35172d408dc Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 27 Mar 2024 12:59:09 +0100 Subject: [PATCH 2/4] Add more tests for comparison operators --- test/Base_Tests/src/Data/Ordering_Spec.enso | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/Base_Tests/src/Data/Ordering_Spec.enso b/test/Base_Tests/src/Data/Ordering_Spec.enso index 8f8956fb1e5e..b1d3bba6a884 100644 --- a/test/Base_Tests/src/Data/Ordering_Spec.enso +++ b/test/Base_Tests/src/Data/Ordering_Spec.enso @@ -1,6 +1,7 @@ from Standard.Base import all import Standard.Base.Errors.Common.Incomparable_Values import Standard.Base.Errors.Common.Type_Error +import Standard.Base.Errors.Illegal_State.Illegal_State from Standard.Test import all @@ -91,6 +92,16 @@ add_specs suite_builder = group_builder.specify "should throw Incomparable_Values when comparing Number with Nothing" <| Ordering.compare 1 Nothing . should_fail_with Incomparable_Values + group_builder.specify "should propagate errors" <| + ((Error.throw (Illegal_State.Error "foo" )) > 42) . should_fail_with Illegal_State + ((Error.throw (Illegal_State.Error "foo" )) >= 42) . should_fail_with Illegal_State + ((Error.throw (Illegal_State.Error "foo" )) < 42) . should_fail_with Illegal_State + ((Error.throw (Illegal_State.Error "foo" )) <= 42) . should_fail_with Illegal_State + (42 > (Error.throw (Illegal_State.Error "foo" ))) . should_fail_with Illegal_State + (42 >= (Error.throw (Illegal_State.Error "foo" ))) . should_fail_with Illegal_State + (42 < (Error.throw (Illegal_State.Error "foo" ))) . should_fail_with Illegal_State + (42 <= (Error.throw (Illegal_State.Error "foo" ))) . should_fail_with Illegal_State + suite_builder.group "Ordering" group_builder-> group_builder.specify "should allow conversion to sign representation" <| Ordering.Less.to_sign . should_equal -1 From bd4d3ba8c49f255d2bed5f7c07b9d16cf4e3716e Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 27 Mar 2024 13:09:17 +0100 Subject: [PATCH 3/4] EqualsNode does not accept errors --- .../interpreter/node/expression/builtin/meta/EqualsNode.java | 4 +--- .../java/org/enso/interpreter/dsl/model/MethodDefinition.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java index b368fb7fe802..93ca416af097 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java @@ -9,7 +9,6 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.AcceptsError; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.node.EnsoRootNode; import org.enso.interpreter.node.callable.InteropConversionCallNode; @@ -82,8 +81,7 @@ public static EqualsNode getUncached() { * @param other the other object * @return {@code true} if {@code self} and {@code that} seem equal */ - public boolean execute( - VirtualFrame frame, @AcceptsError Object self, @AcceptsError Object other) { + public boolean execute(VirtualFrame frame, Object self, Object other) { var areEqual = node.execute(frame, self, other); if (!areEqual) { var selfType = types.execute(self); diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/model/MethodDefinition.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/model/MethodDefinition.java index 683f9eb3b3a3..6c778902e7bc 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/model/MethodDefinition.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/model/MethodDefinition.java @@ -630,7 +630,7 @@ public boolean isSuspended() { } /** - * @return whether thsi argument accepts a dataflow error. + * @return whether this argument accepts a dataflow error. */ public boolean acceptsError() { return acceptsError; From 805785dfcba47fb109cb5d13eaa845ac9c08b1c5 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 27 Mar 2024 14:55:36 +0100 Subject: [PATCH 4/4] Revert 32f876d803599587d453e5fe5cda044fa150529f --- .../0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso index ff18372b2080..ab5f4c03e257 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso @@ -27,13 +27,10 @@ type Enso_Path if raw_segments.is_empty then Error.throw (Illegal_Argument.Error "Invalid path - it should contain at least one segment.") else organization_name = raw_segments.first segments = raw_segments.drop 1 . filter s-> s.is_empty.not - current_user_name = Enso_User.current.name - # The `if_not_error` is a workaround for https://github.com/enso-org/enso/issues/9283 and it can be removed after that is fixed. - current_user_name.if_not_error <| - if organization_name != current_user_name then Unimplemented.throw "Currently only resolving paths for the current user is supported." else - if segments.is_empty then Enso_Path.Value organization_name [] Nothing else - asset_name = segments.last - Enso_Path.Value organization_name (segments.drop (Index_Sub_Range.Last 1)) asset_name + if organization_name != Enso_User.current.name then Unimplemented.throw "Currently only resolving paths for the current user is supported." else + if segments.is_empty then Enso_Path.Value organization_name [] Nothing else + asset_name = segments.last + Enso_Path.Value organization_name (segments.drop (Index_Sub_Range.Last 1)) asset_name ## PRIVATE resolve_parent self =