Skip to content

numargs fails for a function with explicit generic (and constrained) arguments #55

@mobius-eng

Description

@mobius-eng

I have a function with explicitly stated constrained generic arguments:

function equation!{T<:Real, U <:AbstractUnsaturatedModel{T}, V <: Inlet{T}}(t :: T, s :: Vector{T}, d :: Darcy{T,U,V}, Ds :: Vector{T})

Creating a parameterized function as

ParameterizedFunction(equation!, d)

Results in error in numargs (utils.jl) function that seems unable to calculate correctly the number of arguments of such a generic function. The problem is in the call

m.sig.parameters

where m is a method of equation!: there is no field parameters for my function.

For something simpler it works:

function lz(t, u, du)
	σ = 10.0
	ρ = 28.0
	β = 8/3.0
	du[1] = σ*(u[2]-u[1])
	du[2] = u[1]*-u[3]) - u[2]
	du[3] = u[1]*u[2] - β*u[3]
end

first(methods(lz)).sig.parameters
svec(DarcyExample.#lz, Any, Any, Any)

However the change to explicit argument type results in error:

function lz1{T<:Real}(t::T, u::Vector{T}, du::Vector{T})
	σ = 10.0
	ρ = 28.0
	β = 8/3.0
	du[1] = σ*(u[2]-u[1])
	du[2] = u[1]*-u[3]) - u[2]
	du[3] = u[1]*u[2] - β*u[3]
end

first(methods(lz1)).sig.parameters
type UnionAll has no field parameters

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions