`functional()` throws error for a `break` statement
- Dominant language
- Julia
- Stars
- 113
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Using `functional()` on a function that consist of a loop and a `break` statement throws a ` KeyError`. I have included a minimal example below. I am using Julia version 1.10.5. This bug further causes issues in using Julia library functions like `reduce` as they use functions within Julia that have a loop with a `break` statement.
```
julia> using IRTools: @code_ir, functional
julia> function f()
while true break end
end
f (generic function with 1 method)
julia> functional(@code_ir f())
ERROR: KeyError: key 2 not found
Stacktrace:
[1] getindex(h::Dict{Any, Any}, key::Int64)
@ Base ./dict.jl:498
[2] functionalbranches!(bl::Any, pr::Any, labels::Any)
@ IRTools.Inner ~/Desktop/IRTools.jl/src/passes/cps.jl:31
[3] _functional(ir::Any, tree::Any, vars::Any, cs::Any)
@ IRTools.Inner ~/Desktop/IRTools.jl/src/passes/cps.jl:66
[4] _functional
@ ~/Desktop/IRTools.jl/src/passes/cps.jl:50 [inlined]
[5] _functional(ir::Any, tree::Any, vars::Any, cs::Any)
@ IRTools.Inner ~/Desktop/IRTools.jl/src/passes/cps.jl:62
[6] _functional
@ ~/Desktop/IRTools.jl/src/passes/cps.jl:50 [inlined]
[7] functional(ir::Any)
@ IRTools.Inner ~/Desktop/IRTools.jl/src/passes/cps.jl:70
[8] top-level scope
@ REPL[3]:1
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.