Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function method errors are hidden #4

Closed
mmiller-max opened this issue Jan 6, 2021 · 0 comments · Fixed by #5
Closed

Function method errors are hidden #4

mmiller-max opened this issue Jan 6, 2021 · 0 comments · Fixed by #5

Comments

@mmiller-max
Copy link
Contributor

MWE:

using Dates
using ExpiringCaches

@cacheable Second(10) function foo(arg1::Int)::Int64
    sleep(5.0)
    return arg1
end

Calling the function with the wrong arguments gives this:

julia> foo(1.0)
ERROR: MethodError: no method matching get(::Cache{Tuple{Int64},Int64,Second}, ::Tuple{Float64}, ::Symbol)
Closest candidates are:
  get(::REPL.Terminals.TTYTerminal, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/Terminals.jl:161
  get(::IdDict{K,V}, ::Any, ::Any) where {K, V} at iddict.jl:86
  get(::Base.Iterators.Pairs, ::Any, ::Any) at iterators.jl:252
  ...
Stacktrace:
 [1] in(::Tuple{Float64}, ::Base.KeySet{Tuple{Int64},Cache{Tuple{Int64},Int64,Second}}) at ./abstractdict.jl:65
 [2] haskey(::Cache{Tuple{Int64},Int64,Second}, ::Tuple{Float64}) at ./abstractdict.jl:17
 [3] get!(::var"#9#10"{Tuple{Float64}}, ::Cache{Tuple{Int64},Int64,Second}, ::Tuple{Float64}) at ./abstractdict.jl:504
 [4] foo(::Float64) at /Users/malmiller/repos/ExpiringCaches.jl/src/ExpiringCaches.jl:169
 [5] top-level scope at REPL[5]:1

Rather than

julia> foo(1.0)
ERROR: MethodError: no method matching foo(::Float64)
Closest candidates are:
  foo(::Int64) at REPL[5]:1
Stacktrace:
 [1] top-level scope at REPL[4]:1

I think this will also mean that functions where only 1 method is @cacheable may not work correctly as foo(args...) has been defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant