Skip to content

Commit 06929d2

Browse files
feat: add @syms syntax to specify type of symbolic function
1 parent 0f414e1 commit 06929d2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/types.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,16 @@ function _name_type(x)
10211021
lhs, rhs = x.args[1:2]
10221022
if lhs isa Expr && lhs.head === :call
10231023
# e.g. f(::Real)::Unreal
1024+
if lhs.args[1] isa Expr
1025+
func_name_and_type = _name_type(lhs.args[1])
1026+
name = func_name_and_type.name
1027+
functype = func_name_and_type.type
1028+
else
1029+
name = lhs.args[1]
1030+
functype = Nothing
1031+
end
10241032
type = map(x->_name_type(x).type, lhs.args[2:end])
1025-
return (name=lhs.args[1], type=:($FnType{Tuple{$(type...)}, $rhs}))
1033+
return (name=name, type=:($FnType{Tuple{$(type...)}, $rhs, $functype}))
10261034
else
10271035
return (name=lhs, type=rhs)
10281036
end

0 commit comments

Comments
 (0)