Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Bug when comparing a nested array #110

Open
EugeneDar opened this issue Sep 15, 2022 · 14 comments
Open

Bug when comparing a nested array #110

EugeneDar opened this issue Sep 15, 2022 · 14 comments

Comments

@EugeneDar
Copy link
Member

This test crushes because array doesn't have method eq.

[] > nested-arrays-comparing
  assert-that > @
    * (*)
    $.equal-to
      list
        * (*)
@EugeneDar
Copy link
Member Author

@Graur please check

@EugeneDar
Copy link
Member Author

But this tests passed successfully.

[] > nested-arrays-comparing
  assert-that > @
    * (*)
    $.equal-to
      list
        * (list *)

@Graur
Copy link
Contributor

Graur commented Sep 15, 2022

@EugeneDar Looks like expected behavior for me, since array don't have eq object

@EugeneDar
Copy link
Member Author

EugeneDar commented Sep 15, 2022

@yegor256 I think eq is such a fundamental method and we should move it from list to array.

@EugeneDar
Copy link
Member Author

@yegor256 what do you think?

@yegor256
Copy link
Member

@EugeneDar if we do this, we will have to re-implement eq in all data primitives and make them understand "types"... I'm not sure it's the right idea. But I'm not against it either.

@EugeneDar
Copy link
Member Author

@yegor256 I think we should listen to more opinions.

@yegor256
Copy link
Member

@EugeneDar
Copy link
Member Author

@yegor256 I read the article, and I agree that this approach does have benefits. However, if two objects happen to be equal, I want to be sure, not pray that they don't accidentally have the same byte representation. Do you agree with that?

@yegor256
Copy link
Member

@EugeneDar it's a philosophical question. Does apple equal to a pear if they both taste the same?

@EugeneDar
Copy link
Member Author

@yegor256 I assume that most programmers using the equals function do not expect to compare their taste. However, I agree that this is more of a philosophical question, for that reason I want to ask a more specific question: "since the language is supposed to be used for static analysis, won't such false positives in the analysis spoil anything?"

@yegor256
Copy link
Member

@EugeneDar during the analysis we will transpile source languages to EO. During this tanspilation we will make implicit type information from Java explicitly present in EO:

voif f(int x) {
  return x + 1;
}

This is EO:

[x] > f
  if.
    not.
      x.type_of.eq "int"
    error "Wrong type!"
  x.plus 1 > @

@EugeneDar
Copy link
Member Author

@yegor256 I agree that this is a solution for strictly typed languages. But what to do with non-strictly typed languages? Suppose we critically care about the result of the f function.

def f(request):
    if not_failed(request):
        return "some data"
    else:
        return False

if f("some request") == False:
    print("Failed")
else:
    print("Success")

Can we ensure that such a case works correctly?

@EugeneDar
Copy link
Member Author

@yegor256 I agree.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants