lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.37k stars 156 forks source link

Debug scopes are not handled for loops #2732

Open advikkabra opened 2 weeks ago

advikkabra commented 2 weeks ago

In the example code here,

i: i32
for i in range(10):
    q: i32 = 10
    j: i32
    for j in range(5):
        p: i32 = i+1

the following error pops up:

code generation error: asr_to_llvm: module failed verification. Error:
conflicting debug info for argument
  call void @llvm.dbg.declare(metadata i32* %p, metadata !10, metadata !DIExpression()), !dbg !17
!7 = !DILocalVariable(name: "j", arg: 1, scope: !3, file: !1, line: 4, type: !8)
!10 = !DILocalVariable(name: "p", arg: 1, scope: !3, file: !1, line: 6, type: !8)

This is due to both j and p being in the same scope when declaring the DILocalVariable, even though they are not in the same scope.