Skip to content
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

Avoiding problems of missing == by using Meta.is_same_object #11974

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Jan 4, 2025

Pull Request Description

Based on the logs we know that the error behind #11127 is in Common.enso line 204. If we change it to:

diff --git distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso
index 9ee140e332..be8e212fa8 100644
--- distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso
+++ distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso
@@ -201,7 +201,7 @@ type No_Such_Method
    to_display_text self =
        target_name =
          is_poly = Meta.is_polyglot self.target
-          is_fn = Meta.type_of self.target == Function
+          is_fn = False # Meta.type_of self.target == Function
          if is_poly then "type " + self.target.to_display_text else
             if is_fn then self.target.to_text else
                "type " + (Meta.type_of self.target).to_display_text

we get 2 tests failed. when running test/Base_Tests:

sbt:enso> runEngineDistribution --run test/Base_Tests no.conversion.of.\.\.B|no.conversion.of.function.value
[FAILED] No_Such_Method: [0/2, 161ms]

    - [FAILED] no conversion of ..B [146ms]
        Reason: The value (Error: Method `sample` of type Function could not be found.) did not contain the element (of ..B) (at /home/devel/NetBeansProjects/enso/enso.master/test/Base_Tests/src/Data/Function_Spec.enso:65:13-55).


    - [FAILED] no conversion of function value [14ms]
        Reason: The value (Error: Method `sample` of type Function could not be found.) did not contain the element (of Function_Spec.add_specs) (at /home/devel/NetBeansProjects/enso/enso.master/test/Base_Tests/src/Data/Function_Spec.enso:83:13-75).

Let's rewrite the code and eliminate the usage of == at this location. Let's replace it with more bullet proof Meta.is_same_object. The tests work again and maybe we eliminate #11127.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the Enso guidelines
  • Unit tests continue to pass

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Jan 4, 2025
@JaroslavTulach JaroslavTulach self-assigned this Jan 4, 2025
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Jan 4, 2025

I tried to write some tests to emulate the problem, but not even

from Standard.Base import all
import Standard.Base.Errors.Common.No_Such_Method

main =
    err = Error.throw "Hi"
    te = Meta.type_of err
    t = Meta.type_of te

    handle err =
        err

    m = Panic.catch handle <|
        t.no_such_method

    [err, te, t, t == t, t == te, te == t, m, m.to_display_text]

is enough to get the same failure. E.g. we have no reproducer, just random failures on our CI.

@JaroslavTulach JaroslavTulach added CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: Keep up to date Automatically update this PR to the latest develop. labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: Keep up to date Automatically update this PR to the latest develop. CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants