Hi Magnus, Definitely looks like a bug. Would you be able to submit a bug report at https://github.com/JuliaLang/julia/issues/new ? Your first example is probably the easiest, since it's easier to follow.
Cheers, Kevin On Mon, Jul 7, 2014 at 4:09 AM, Magnus Lie Hetland <[email protected]> wrote: > Here's another version. Yes, there's a lot of cruft in there, and I'm sure > one could trim it down to a smaller example of the same issue, but (1) it > seems that removing things tend to remove the problem (… and I don't really > understand what the problem is), and (2) it sort of illustrates how odd the > whole thing is—there are lots of undefined variables here, which Julia > probably should be reacting to. > > function loop(unused4, x, unused5) > > for unused3 in undef1() # 1 > > func(undef6, x, undef7) > > end # 1 > > end > > > type Wrapper{T} > > vals::Vector{T} # 2 > > end > > > function func{T}(x::(Wrapper{T}, None), unused1::T, unused2) # 3 > > loop(undef2, x[1].vals, undef3) > > end > > > function outer() > > s = 1 > > function inner() > > func(s, [1], undef4) > > for s in [1] # 4 > > func(s, [1], undef5) # 4 > > end # 4 > > end > > inner() > > end > > outer() > > Now, you can get Julia to react properly (i.e., with an exception) by most > minor tweaks, it seems. Some examples (referring to the numbered lines): > > > 1. Take away dummy-loop, but keep the call inside it. > 2. Make vals untyped. > 3. Make unused1 untyped. > 4. Remove the loop, including the enclosed call. > > So, yeah, I still don't understand what's going on. Have I, perhaps, > created infinite mutual recursion at the type inference level? I can't see > that I have, but I'm just guessing that the "hang" is not in normal > execution of Julia. (Partly because printing, with flushing, at places that > *should* have been reached does nothing—and there's no reaction to scores > of undefined variables and functions that would be in the execution path, > if this were only infinite mutual recursion.) > > This code is, of course, pathological, but I believe that my original may > not be. But anyway, if it is, an exception with a clear traceback would > surely be preferable to an inscrutable hang? >
