← 输入框|github.com|刷新
Skip to content

Missing multiadic Boolean == #2131

Open

Description

@rebcabin

VE:

from lpython import (i8, i32, i64, f32, f64,
                     dataclass
                     )
from numpy import (empty,
                   int8,
                   )

r : i8 = i8(240)

@dataclass
class Foo:
    a : i8[4] = empty(4, dtype=int8)
    dim : i32 = 4

def trinary_majority(x : Foo, y : Foo, z : Foo) -> Foo:
    foo : Foo = Foo()

    assert foo.dim == x.dim == y.dim == z.dim

    i : i32
    for i in range(foo.dim):
        pass


    # Issue 2130
    # foo.a = x.a | y.a | z.a
    return foo


t1 : Foo = Foo()
t1.a = empty(4, dtype=int8)

t2 : Foo = Foo()
t2.a = empty(4, dtype=int8)

t3 : Foo = Foo()
t3.a = empty(4, dtype=int8)

r1 : Foo = trinary_majority(t1, t2, t3)

runs:

(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s012)─┐
└─(11:39:11 on brian-lasr ✹ ✭)──> ~/CLionProjects/lpython/src/bin/lpython -I. issue2126.py                                                            1 ↵ ──(Sun,Jul09)─┘
semantic error: Type mismatch in comparison operator, the types must be compatible
  --> issue2126.py:18:12
   |
18 |     assert foo.dim == x.dim == y.dim == z.dim
   |            ^^^^^^^^^^^^^^^^    ^^^^^ type mismatch ('bool' and 'i32')


Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that must be fixed).
(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s012)─┐
└─(11:39:26 on brian-lasr ✹ ✭)──> PYTHONPATH='../../src/runtime/lpython' python issue2126.py

Activity

  1. added
    enhancement
    on Jul 9, 2023
  2. rebcabin commented on Jul 9, 2023

    @rebcabin
    ContributorAuthor

    In lieu of a fix, I suggest a --> help line like the following:

    (lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm)─────────────────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s012)─┐
    └─(11:39:11 on brian-lasr ✹ ✭)──> ~/CLionProjects/lpython/src/bin/lpython -I. issue2126.py                                                            1 ↵ ──(Sun,Jul09)─┘
    semantic error: Type mismatch in comparison operator, the types must be compatible
      --> issue2126.py:18:12
       |
    18 |     assert foo.dim == x.dim == y.dim == z.dim
       |            ^^^^^^^^^^^^^^^^    ^^^^^ type mismatch ('bool' and 'i32')
    
      --> help: separate into multiple Boolean asserts for now.
    
    Note: if any of the above error or warning messages are not clear or are lacking
    context please report it to us (we consider that a bug that must be fixed).
  3. rebcabin commented on Jul 9, 2023

    @rebcabin
    ContributorAuthor

    This is definitely a semantic bug, a deviation w.r.t. CPython.

  4. added
    bug
    and removed
    enhancement
    on Jul 9, 2023
  5. self-assigned this
    on Jul 26, 2023
  6. Smit-create commented on Jul 30, 2023

    @Smit-create
    Collaborator

    #2213 reverted in #2229. Relevant issue: #2227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions