That’s probably an issue with the parser, but I wouldn’t have expected this to work in the first place - it’s usually best to define that outside of the default argument and just pass the name of the function in.
Are you trying to restrict g to only match functions that take a dictionary as an argument? If so, that kind of dispatch doesn’t exist in julia, as far as I’m aware, since the types of each argument are not part of the type of a function.
julia> f(a = (b::String)::Bool -> true) = a
ERROR: syntax: "b::String" is not a valid function argument name around REPL[13]:1
Stacktrace:
[1] top-level scope
@ REPL[13]:1
julia> f(a = (b::String)::Bool -> begin true end) = a
ERROR: syntax: "b::String" is not a valid function argument name around REPL[14]:1
Stacktrace:
[1] top-level scope
@ REPL[14]:1
You’re welcome! You’ll also get e.g. Documenter.jl support for free, which already generates documentation from docstrings. It also has cross references and all kinds of fancy things you might be interested in.
That’s on Julia 1.8-DEV. I don’t know if that can be fixed or if its ambigues…
julia> function()::Bool true end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function.
Stacktrace:
[1] top-level scope
@ none:1
julia> ()::Bool -> true
#7 (generic function with 1 method)
julia> (::Bool)::Bool -> true
ERROR: syntax: "::Bool" is not a valid function argument name around REPL[12]:1
Stacktrace:
[1] top-level scope
@ REPL[12]:1
julia> function(abc::Int) true end
#7 (generic function with 1 method)
julia> VERSION
v"1.7.0-beta2"
julia> function(abc::Int)::Bool true end
ERROR: syntax: expected "(" in function definition
Stacktrace:
[1] top-level scope
@ none:1
julia> function(a::Int)::Bool end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function.
Stacktrace:
[1] top-level scope
@ none:1
julia> function(a::Int,)::Bool end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function.
Stacktrace:
[1] top-level scope
@ none:1
julia> VERSION
v"1.8.0-DEV.94"