FluxML / FluxML/IRTools.jl

Bounds error in dynamo with dummy metadata

Open
#44 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
113
Forks
37
PR merge metrics
No merged PRs in 30d

Description

I know I shouldn't build IR from scratch, but I really wonder why the following happens:

```
julia> plus_dummy(x, y) = nothing
plus_dummy (generic function with 1 method)

julia> @dynamo function foo(X, Y)
ir = IR(typeof(plus_dummy), X, Y)
@show ir
@show _args = IRTools.arguments(ir)
s = push!(ir, xcall(:+, _args[end-1], _args[end]))
@show ir
return!(ir, s)
@show ir
return ir
end

julia> foo(1, 2)
ir = 1: (%1, %2, %3)
return :(Main.nothing)
_args = IRTools.arguments(ir) = Any[%1, %2, %3]
ir = 1: (%1, %2, %3)
%4 = %2 + %3
return :(Main.nothing)
ir = 1: (%1, %2, %3)
%4 = %2 + %3
return %4
ERROR: BoundsError: attempt to access (1, 2)
at index [3]
Stacktrace:
[1] foo(::Int64, ::Int64) at /home/philipp/.julia/packages/IRTools/Fl3dY/src/reflection/dynamo.jl:44
[2] top-level scope at REPL[7]:1
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproducer in the issue and inspect src/reflection/dynamo.jl at line 44, where foo is called with two Int64 arguments. Trace how IR(typeof(plus_dummy), X, Y) and its dummy metadata produce the third argument access; done means the shown call no longer raises the BoundsError, with the behavior covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.