WIP: make require() load at top level #1809
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the major piece of work needed to address #1411. Please check, esp. @JeffBezanson. I'm especially worried about the module context in toplevel.c, if the imported file has errors in it. Testing did not result in a segfault, but I doubt the thoroughness of this test.
On both the C side and the julia side this is ugly, but when I tried the more obvious thing in
boot.jl
I either (1) ran intocconvert not defined
errors (presumably the conversion of a bool to an Int32 is not yet automatizable), (2) didn't figure out a way to generate0::Int32
in a boot.jl-safe way, or (3) got a weird warning when I saidimport Core.include; include(fname::ByteString, inmain::Bool) = ...
. Hence I definedimport_main
. By this point the interface seems kinda dumb (why take a second argument toimport_main
??), but I suspect there's a cleaner solution, so I decided to leave my fingerprints on it.Also, a more general interface would be
import(fname, mod::Module)
, but I don't know whether that's desirable.