-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
This issue summarises the behaviour of julia when exposed to circular includes.
The observed behaviour varies between julia versions from segfaults, irresponsive REPL or execution to rather intractable error messages.
Even though circular includes are without a doubt a sign of bad code design, I'd find it desirable to see a more helpful error message and to avoid julia to run into a stack overflow or become irresponsive 😄.
To reproduce
- File
a.jl
:
include("b.jl")
- File
b.jl
:
include("a.jl")
Test cases
- REPL: A plain
julia> include("a.jl")
was issued inside the REPL. - script: I executed from a shell
julia a.jl
.
Result summary
julia version | REPL | script |
---|---|---|
1.1 | segfault | lengthy StackOverflowError |
1.2 | lengthy StackOverflowError + irresponsive | irresponsive |
1.3 | lengthy StackOverflowError + irresponsive | irresponsive |
The behaviour changes between 1.1 and 1.2. The 1.2+ REPL behaviour is to print the error message
LoadError: LoadError: LoadError: LoadError: LoadError: LoadError:
... (many more times and finally) ...
StackOverflowError:
followed by an irresponsive REPL. When run as a script on 1.2+ the only printed output is
ERROR:
followed by an irresponsive julia process.
Update: In fact "irresponsive" is not correct. The REPL/process just takes long (order of 2 minutes) to respond.