lpython
lpython copied to clipboard
Improvement: Comparison on dissimilar types can be improved
Comparing dissimilar types throws a semantic error stating type mismatch.
Checking equality
integer: i32 = 1
integer_list: list[i32] = [1, 2, 3, 4, 5]
print(integer == integer_list)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
semantic error: Type mismatch in comparison operator, the types must be compatible
--> ./examples/example.py:5:7
|
5 | print(integer == integer_list)
| ^^^^^^^ ^^^^^^^^^^^^ type mismatch ('i32' and 'list[i32]')
Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.
Checking inequality
integer: i32 = 1
integer_list: list[i32] = [1, 2, 3, 4, 5]
print(integer != integer_list)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
semantic error: Type mismatch in comparison operator, the types must be compatible
--> ./examples/example.py:5:7
|
5 | print(integer != integer_list)
| ^^^^^^^ ^^^^^^^^^^^^ type mismatch ('i32' and 'list[i32]')
Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.
Similar error is thrown for other operators.