This is a totally mad thing to do and as noted in #21771 (comment) not entirely surprising that it crashes. Would be nice if it could be made to fail more gracefully though.
julia> versioninfo()
Julia Version 0.7.0-DEV.391
Commit 526ed78 (2017-05-30 03:28 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
julia> Base.promote_type(::Type{T}, ::Type{S}) where {T,S} = Int
WARNING: Method definition promote_type(Type{T}, Type{S}) in module Base at promotion.jl:155 overwritten in module Main at REPL[2]:1.
fatal: error thrown and no exception handler available.
Base.MethodError(f=typeof(Base.hash_uint)(), args=(-3417188764257106000,), world=0x00000000000055dc)
rec_backtrace at /home/gunnar/julia0.7/src/stackwalk.c:84
record_backtrace at /home/gunnar/julia0.7/src/task.c:245
jl_throw at /home/gunnar/julia0.7/src/task.c:564
jl_method_error_bare at /home/gunnar/julia0.7/src/gf.c:1469
jl_method_error at /home/gunnar/julia0.7/src/gf.c:1487
jl_lookup_generic_ at /home/gunnar/julia0.7/src/gf.c:1900 [inlined]
jl_apply_generic at /home/gunnar/julia0.7/src/gf.c:1920
hashindex at ./dict.jl:210
ht_keyindex at ./dict.jl:322
haskey at ./dict.jl:505
unknown function (ip: 0x7f3588d69726)
jl_call_fptr_internal at /home/gunnar/julia0.7/src/julia_internal.h:353 [inlined]
jl_call_method_internal at /home/gunnar/julia0.7/src/julia_internal.h:372 [inlined]
jl_invoke at /home/gunnar/julia0.7/src/gf.c:41
repl_color at ./client.jl:74
unknown function (ip: 0x7f3588d63041)
jl_call_fptr_internal at /home/gunnar/julia0.7/src/julia_internal.h:353 [inlined]
jl_call_method_internal at /home/gunnar/julia0.7/src/julia_internal.h:372 [inlined]
jl_apply_generic at /home/gunnar/julia0.7/src/gf.c:1923
display_error at ./client.jl:133
unknown function (ip: 0x7f3588d6ad2d)
jl_call_fptr_internal at /home/gunnar/julia0.7/src/julia_internal.h:353 [inlined]
jl_call_method_internal at /home/gunnar/julia0.7/src/julia_internal.h:372 [inlined]
jl_apply_generic at /home/gunnar/julia0.7/src/gf.c:1923
display_error at ./client.jl:142
unknown function (ip: 0x7f3588d6a7b6)
jl_call_fptr_internal at /home/gunnar/julia0.7/src/julia_internal.h:353 [inlined]
jl_call_method_internal at /home/gunnar/julia0.7/src/julia_internal.h:372 [inlined]
jl_apply_generic at /home/gunnar/julia0.7/src/gf.c:1923
do_call at /home/gunnar/julia0.7/src/interpreter.c:75
eval at /home/gunnar/julia0.7/src/interpreter.c:242
eval_body at /home/gunnar/julia0.7/src/interpreter.c:539
jl_toplevel_eval_body at /home/gunnar/julia0.7/src/interpreter.c:511
jl_toplevel_eval_flex at /home/gunnar/julia0.7/src/toplevel.c:569 [inlined]
jl_toplevel_eval at /home/gunnar/julia0.7/src/toplevel.c:598
jl_toplevel_eval_in at /home/gunnar/julia0.7/src/builtins.c:496
eval at ./boot.jl:236
unknown function (ip: 0x7f35a0f4d70f)
jl_call_fptr_internal at /home/gunnar/julia0.7/src/julia_internal.h:353 [inlined]
jl_call_method_internal at /home/gunnar/julia0.7/src/julia_internal.h:372 [inlined]
jl_apply_generic at /home/gunnar/julia0.7/src/gf.c:1923
_start at ./client.jl:419
unknown function (ip: 0x7f35a0fa2ea8)
jl_call_fptr_internal at /home/gunnar/julia0.7/src/julia_internal.h:353 [inlined]
jl_call_method_internal at /home/gunnar/julia0.7/src/julia_internal.h:372 [inlined]
jl_apply_generic at /home/gunnar/julia0.7/src/gf.c:1923
jl_apply at /home/gunnar/julia0.7/ui/../src/julia.h:1424 [inlined]
true_main at /home/gunnar/julia0.7/ui/repl.c:127
main at /home/gunnar/julia0.7/ui/repl.c:264
__libc_start_main at /build/eglibc-MjiXCM/eglibc-2.19/csu/libc-start.c:287
unknown function (ip: 0x4015fa)
This does not crash if you provide a correct redefinition but everything else I've tried runs into the crash.
julia> Base.promote_type(::Type{T}, ::Type{S}) where {T,S} = Base.promote_result(T, S, promote_rule(T,S), promote_rule(S,T))
WARNING: Method definition promote_type(Type{T}, Type{S}) in module Base at promotion.jl:155 overwritten in module Main at REPL[1]:1.
julia>
This is a totally mad thing to do and as noted in #21771 (comment) not entirely surprising that it crashes. Would be nice if it could be made to fail more gracefully though.
This does not crash if you provide a correct redefinition but everything else I've tried runs into the crash.