Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1578,8 +1578,10 @@ static void method_overwrite(jl_typemap_entry_t *newentry, jl_method_t *oldvalue
jl_printf(s, ".\n");
jl_uv_flush(s);
}
if (jl_generating_output())
jl_error("Method overwriting is not permitted during Module precompile.");
if (jl_generating_output()) {
jl_printf(JL_STDERR, "ERROR: Method overwriting is not permitted during Module precompile.\n");
jl_exit(125);
}
}

static void update_max_args(jl_methtable_t *mt, jl_value_t *type)
Expand Down
10 changes: 10 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@ precompile_test_harness(false) do dir

@test Base.compilecache(Base.PkgId("Baz")) == Base.PrecompilableError() # due to __precompile__(false)

Baz_file = joinpath(dir, "OverwriteMethodError.jl")
write(OverwriteMethodError_file,
"""
module OverwriteMethodError
Base.:(+)(x::Bool, y::Bool) = false
end
""")

@test Base.compilecache(Base.PkgId("OverwriteMethodError")) == Base.PrecompilableError() # due to piracy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is noisy during CI:

precompile                                       (1) |        started at 2023-11-25T02:42:26.767
WARNING: Method definition +(Bool, Bool) in module Base at bool.jl:166 overwritten in module OverwriteMethodError at C:\Users\julia\AppData\Local\Temp\jl_shtGYs\OverwriteMethodError.jl:2.
ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.

(needs @test_warn)


UseBaz_file = joinpath(dir, "UseBaz.jl")
write(UseBaz_file,
"""
Expand Down