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

Fix bug in at-derived macro parsing methods w/ unnamed arguments. #10

Merged
2 commits merged into from
Apr 20, 2020
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
2 changes: 1 addition & 1 deletion src/Salsa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ macro derived(f)
cache
end

function $(@__MODULE__()).invoke_user_function(::$derived_key_t, $(args...))
function $(@__MODULE__()).invoke_user_function(::$derived_key_t, $(fullargs...))
$userfname($(argnames[1]), $(argnames[2:end]...))
end

Expand Down
15 changes: 9 additions & 6 deletions test/Salsa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,19 @@ end
# ----------------------------------

# Allow functions with multiple methods
Salsa.@derived f(db::AbstractComponent) = 1
Salsa.@derived f(db::AbstractComponent, arg::Any) = arg
Salsa.@derived f(db::AbstractComponent, arg::Int) = 10
# NOTE: Also testing varied arg syntax (`x`, `x::T`, `::T`).
Salsa.@derived multi_method(db::AbstractComponent) = 1
Salsa.@derived multi_method(db::AbstractComponent, arg) = arg
Salsa.@derived multi_method(db::AbstractComponent, arg::Int) = 10
Salsa.@derived multi_method(db::AbstractComponent, ::Symbol) = "!"

Salsa.@component MultiMethodFunctions begin
end
@testset "multiple methods" begin
@test f(MultiMethodFunctions()) == 1
@test f(MultiMethodFunctions(), 2) == 10
@test f(MultiMethodFunctions(), "hi") == "hi"
@test multi_method(MultiMethodFunctions()) == 1
@test multi_method(MultiMethodFunctions(), 2) == 10
@test multi_method(MultiMethodFunctions(), "hi") == "hi"
@test multi_method(MultiMethodFunctions(), :bang) == "!"
end

# ----------------------------------
Expand Down