Skip to content

Equality depends on declared type of operands #2553

@sungshik

Description

@sungshik

Describe the bug

Equality depends in some cases on the declared type of the operands. This leads to unexpected and asymmetric results.

To Reproduce

The following cases do work as expected:

rascal>value x = 5;
value: 5
rascal>x == 5;
bool: true
rascal>value y = [5, 6, 7];
value: [5,6,7]
rascal>y == [5, 6, 7];
bool: true
rascal>z1 = indexOf;
int (list[&T], &T): function(|std:///List.rsc|(5352,518,<210,0>,<229,1>))
rascal>z1 == indexOf;
bool: true

The following cases don't work as expected (HT: @rodinaarssen):

rascal>value z2 = indexOf;
value: function(|std:///List.rsc|(5352,518,<210,0>,<229,1>))
rascal>z2 == indexOf;
bool: false
rascal>indexOf == z2;
bool: false
rascal>syntax S = "s";
ok
rascal>S ss = (S)`s`;
S: (S) `s`
rascal>value vv = ss;
value: appl(
  prod(
    sort("S"),
    [lit("s")],
    {}),
  [appl(
      prod(
        lit("s"),
        [\char-class([range(115,115)])],
        {}),
      [char(115)])],
  src=|prompt:///|(11,1))
rascal>ss == vv
bool: false
rascal>vv == ss
bool: true

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions