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

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

Closed

Description

@kmr-srbh
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 <.

Activity

  1. 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[/+] on Apr 30, 2024
  2. ubaidsk commented on May 1, 2024

    @ubaidsk
    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.

  3. kmr-srbh commented on May 1, 2024

    @kmr-srbh
    ContributorAuthor

    Thanks for confirming this @Shaikh-Ubaid!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions