Why the re-definition of some methods of f make the other methods un-exported?

is this a bug or a usual behavior.

Version 0.7.0-DEV.772

julia> module M
export f
f() = 1
f(x::Int)= x
f(x::Float64) = x
end
M

julia> using M
julia> f()=2
f (generic function with 1 method)
julia> f()
2

julia> f(1)
ERROR: MethodError: no method matching f(::Int32)
Closest candidates are:
f() at REPL[2]:1

When you define f() = 2 outside of M, you are shadowing the definition in M. To get the behavior you expected (extending f) you need to import M: f before you defining a new method.

2 Likes

thanks,

details from the Julia FAQ.