You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I defined a function that uses a yet-to-be-defined method.
If I don't call the function until after I've defined the function it calls, everything is fine.
If I call it before I define the method, then it (as I expected) throws an error.
If I then define the missing method and run the first function again, there is no error but it also doesn't return the value that it should. I expected it to either work correctly or at least keep throwing an error.
julia> function foo(x,y)
x + y
end
# methods for generic function foo
foo(x,y) at none:2
julia> foo(true,"hi")
ERROR: no method +(Bool,ASCIIString)
in foo at none:2
julia> +(b::Bool,s::String) = "$b$s"
# methods for generic function +
+(x::Bool,y::Bool) at bool.jl:38
+(x::Int64,y::Int64) at int.jl:36
+(x::Union(SubArray{Bool,N,A<:Array{T,N},I<:(Union(Int64,Range1{Int64},Range{Int64})...,)},Array{Bool,N}),y::Union(SubArray{Bool,N,A<:Array{T,N},I<:(Union(Int64,Range1{Int64},Range{Int64})...,)},Array{Bool,N})) at array.jl:1003
+{S,T}(A::Union(SubArray{S,N,A<:Array{T,N},I<:(Union(Int64,Range1{Int64},Range{Int64})...,)},Array{S,N}),B::Union(SubArray{T,N,A<:Array{T,N},I<:(Union(Int64,Range1{Int64},Range{Int64})...,)},Array{T,N})) at array.jl:947
+{T<:Union(Int8,Int64,Int16,Int32)}(x::T<:Union(Int8,Int64,Int16,Int32),y::T<:Union(Int8,Int64,Int16,Int32)) at int.jl:11
... 87 methods not shown (use methods(+) to see them all)
julia> foo(true,"hi")
julia> foo(true,"hi")
julia> function foo(x,y)
x + y
end
# methods for generic function foo
foo(x,y) at none:2
julia> foo(true,"hi")
"truehi"
The text was updated successfully, but these errors were encountered:
I defined a function that uses a yet-to-be-defined method.
If I don't call the function until after I've defined the function it calls, everything is fine.
If I call it before I define the method, then it (as I expected) throws an error.
If I then define the missing method and run the first function again, there is no error but it also doesn't return the value that it should. I expected it to either work correctly or at least keep throwing an error.
The text was updated successfully, but these errors were encountered: