JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.84k stars 5.49k forks source link

Accumulate eagerly throws, ignoring side effects [low priority] #53458

Open LilithHafner opened 9 months ago

LilithHafner commented 9 months ago

This code should print (1, 2) forever, and on Julia 1.0, it does. However, on 1.6 and 1.12 it throws.

accumulate([1,2,3]) do args...
    while true
        println(args)
    end
end

Just because we can infer that something does not return does not mean we may turn it into an error. Infinite loops are not UB in Julia.

Weakly related to #53438

Seelengrab commented 9 months ago

Infinite loops have been UB in julia, see https://github.com/JuliaLang/julia/issues/40009. There's currently a mix going on between what inference assumes and what LLVM assumes of the code julia generates.