I can reproduce the comma vs semicolon difference on 1 week old master. Moreover, the result of @code_warntype
is different if g
has been called, for example:
julia> f(n) = (i^2 for i in 1:n)
f (generic function with 1 method)
julia> g(n) = sum(x^2 for x in f(n); init=0)
g (generic function with 1 method)
julia> @code_warntype g(3) # does not infer
MethodInstance for g(::Int64)
from g(n) in Main at REPL[2]:1
Arguments
#self#::Core.Const(g)
n::Int64
Locals
#5::var"#5#6"
Body::Any
1 ─ (#5 = %new(Main.:(var"#5#6")))
│ %2 = #5::Core.Const(var"#5#6"())
│ %3 = Main.f(n)::Core.PartialStruct(Base.Generator{UnitRange{Int64}, var"#3#4"}, Any[Core.Const(var"#3#4"()), Core.PartialStruct(UnitRange{Int64}, Any[Core.Const(1), Int64])])
│ %4 = Base.Generator(%2, %3)::Core.PartialStruct(Base.Generator{Base.Generator{UnitRange{Int64}, var"#3#4"}, var"#5#6"}, Any[Core.Const(var"#5#6"()), Core.PartialStruct(Base.Generator{UnitRange{Int64}, var"#3#4"}, Any[Core.Const(var"#3#4"()), Core.PartialStruct(UnitRange{Int64}, Any[Core.Const(1), Int64])])])
│ %5 = (:init,)::Core.Const((:init,))
│ %6 = Core.apply_type(Core.NamedTuple, %5)::Core.Const(NamedTuple{(:init,)})
│ %7 = Core.tuple(0)::Core.Const((0,))
│ %8 = (%6)(%7)::Core.Const((init = 0,))
│ %9 = Core.kwfunc(Main.sum)::Core.Const(Base.var"#sum##kw"())
│ %10 = (%9)(%8, Main.sum, %4)::Any
└── return %10
julia> g(4)
354
julia> @code_warntype g(3) # now it infers?
MethodInstance for g(::Int64)
from g(n) in Main at REPL[2]:1
Arguments
#self#::Core.Const(g)
n::Int64
Locals
#5::var"#5#6"
Body::Int64
1 ─ (#5 = %new(Main.:(var"#5#6")))
│ %2 = #5::Core.Const(var"#5#6"())
│ %3 = Main.f(n)::Core.PartialStruct(Base.Generator{UnitRange{Int64}, var"#3#4"}, Any[Core.Const(var"#3#4"()), Core.PartialStruct(UnitRange{Int64}, Any[Core.Const(1), Int64])])
│ %4 = Base.Generator(%2, %3)::Core.PartialStruct(Base.Generator{Base.Generator{UnitRange{Int64}, var"#3#4"}, var"#5#6"}, Any[Core.Const(var"#5#6"()), Core.PartialStruct(Base.Generator{UnitRange{Int64}, var"#3#4"}, Any[Core.Const(var"#3#4"()), Core.PartialStruct(UnitRange{Int64}, Any[Core.Const(1), Int64])])])
│ %5 = (:init,)::Core.Const((:init,))
│ %6 = Core.apply_type(Core.NamedTuple, %5)::Core.Const(NamedTuple{(:init,)})
│ %7 = Core.tuple(0)::Core.Const((0,))
│ %8 = (%6)(%7)::Core.Const((init = 0,))
│ %9 = Core.kwfunc(Main.sum)::Core.Const(Base.var"#sum##kw"())
│ %10 = (%9)(%8, Main.sum, %4)::Int64
└── return %10
which is definitely mysterious to me.