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

Default parameters not supported in derived functions #12

Closed
comnik opened this issue Apr 24, 2020 · 0 comments · Fixed by #32
Closed

Default parameters not supported in derived functions #12

comnik opened this issue Apr 24, 2020 · 0 comments · Fixed by #32
Assignees
Labels

Comments

@comnik
Copy link
Contributor

comnik commented Apr 24, 2020

Adding the following derived function on MyQueryGroup to test/Salsa.jl

# Verify that derived functions can take default parameters.
Salsa.@derived function default_source(db::MyQueryGroup, name::String="stdlib")
    return db.source_text[name]
end

and including the following testset

@testset "Default parameters in derived functions" begin
    db = MyQueryGroup()
    db.source_text["stdlib"] = "..."
    @test default_source(db) == default_source(db, "stdlib")
end

fails with

Default parameters in derived functions: Error During Test at /Users/niko/Projects/raicode/packages/Salsa/test/Salsa.jl:279
  Test threw exception
  Expression: default_source(db) == default_source(db, "stdlib")
  MethodError: no method matching default_source(::Main.SalsaTest.MyQueryGroup)
  Closest candidates are:
    default_source(::Main.SalsaTest.MyQueryGroup, !Matched::String) at /Users/niko/Projects/raicode/packages/Salsa/src/Salsa.jl:481
  Stacktrace:
   [1] top-level scope at /Users/niko/Projects/raicode/packages/Salsa/test/Salsa.jl:279
   [2] top-level scope at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Test/src/Test.jl:1113
   [3] top-level scope at /Users/niko/Projects/raicode/packages/Salsa/test/Salsa.jl:277

Would it be possible to support default parameters on derived functions? Or is there a conceptual reason not to do so?

Thanks!

@ghost ghost self-assigned this Apr 24, 2020
@ghost ghost added the macros label Apr 24, 2020
@ghost ghost assigned NHDaly and unassigned NHDaly Dec 20, 2021
@NHDaly NHDaly assigned NHDaly and unassigned NHDaly Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants