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

Bug: Comparing lists using the == and != operators leads to an LLVM code generation error #2676

Closed
kmr-srbh opened this issue Apr 30, 2024 · 2 comments · Fixed by #2697
Closed

Comments

@kmr-srbh
Copy link
Contributor

from lpython import i32

my_first_list: list[i32] = [1, 2, 3, 4]
my_second_list: list[i32] = [5, 6, 7, 8]

print(my_first_list == my_second_list)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
; ModuleID = 'LFortran'
source_filename = "LFortran"

%list = type { i32, i32, i32* }
.
.
.
declare void @_lpython_call_initial_functions(i32, i8**)

attributes #0 = { argmemonly nounwind willreturn }
asr_to_llvm: module failed verification. Error:
Basic Block in function '__module___main_____main__global_stmts' does not have terminator!
label %.entry

code generation error: asr_to_llvm: module failed verification. Error:
Basic Block in function '__module___main_____main__global_stmts' does not have terminator!
label %.entry



Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.

The issue is the same for !=. It does not occur for > and <.

@kmr-srbh kmr-srbh changed the title Bug: Comparing lists using the == and != operators leads to an LLVM code generation error. Bug: Comparing lists using the == and != operators leads to an LLVM code generation error Apr 30, 2024
@Shaikh-Ubaid
Copy link
Collaborator

% cat examples/expr2.py 
from lpython import i32

def main():
    my_first_list: list[i32] = [1, 2, 3, 4]
    my_second_list: list[i32] = [5, 6, 7, 8]

    print(my_first_list == my_second_list)

main()
% python examples/expr2.py 
False
% lpython examples/expr2.py
False

It seems this happens only for global list variables.

@kmr-srbh
Copy link
Contributor Author

kmr-srbh commented May 1, 2024

Thanks for confirming this @Shaikh-Ubaid!

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

Successfully merging a pull request may close this issue.

2 participants