JuliaLang / julia

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

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

Open LilithHafner opened 8 months ago

LilithHafner commented 8 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 8 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.