Splatting causes BoundsError in 0.7-alpha

bug
error

#1

I get a weird BoundsError when I use splatting in v0.7-alpha. Below is a MWE.

function test(a,b)
    c = (b,(0,1)...)
    test(a, c...)
end
    
function test2(a,b)
    c = (b,0,1)
    test(a, c...)
end

test(a, b, c, d) = a.*(b, c, d)

Calling test2(1,1) works as expected returning (1, 0, 1). Running test(1,1) however gives the following

Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (6,)}[
  Tuple{Int64},
  Core.Compiler.Const(val=(0, 1), actual=false),
  Tuple{Int64, Int64, Int64},
  Tuple{Int64},
  Tuple{Int64, Int64, Int64},
  Any], i=(7,))
rec_backtrace at julia/src/stackwalk.c:94
record_backtrace at julia/src/task.c:246 [inlined]
jl_throw at julia/src/task.c:577
jl_bounds_error_ints at julia/src/rtutils.c:187
getindex at ./array.jl:707
abstract_eval_ssavalue at ./compiler/ssair/queries.jl:60 [inlined]
exprtype at ./compiler/utilities.jl:183 [inlined]
assemble_inline_todo! at ./compiler/ssair/inlining2.jl:801
ssa_inlining_pass! at ./compiler/ssair/inlining2.jl:54 [inlined]
run_passes at ./compiler/ssair/driver.jl:168
optimize at ./compiler/optimize.jl:183
typeinf at ./compiler/typeinfer.jl:436
typeinf_frame at ./compiler/typeinfer.jl:96 [inlined]
typeinf_code at ./compiler/typeinfer.jl:191
typeinf_ext at ./compiler/typeinfer.jl:233
jfptr_typeinf_ext_12 at julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at julia/src/./julia.h:1540 [inlined]
jl_apply_with_saved_exception_state at julia/src/rtutils.c:257
jl_type_infer at julia/src/gf.c:274
jl_compile_method_internal at julia/src/gf.c:1778
jl_fptr_trampoline at julia/src/gf.c:1822
do_call at julia/src/interpreter.c:324
eval_body at julia/src/interpreter.c:559
jl_interpret_toplevel_thunk_callback at julia/src/interpreter.c:798
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x11307df8f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at julia/src/interpreter.c:807
jl_toplevel_eval_flex at julia/src/toplevel.c:856
jl_toplevel_eval_in at julia/src/builtins.c:631
eval at ./boot.jl:316
eval_user_input at julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
macro expansion at julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:116 [inlined]
#28 at ./task.jl:254
jl_fptr_trampoline at julia/src/gf.c:1823
jl_apply at julia/src/./julia.h:1540 [inlined]
start_task at julia/src/task.c:268
(1, 0, 1)

The weirdest part is that it still gives the correct output at the end. . .


#2

Seems like a compiler bug. Would you mind filing an issue?


#3

Issue #27566 posted.