Skip to content

Commit 1f8d1a0

Browse files
committed
Fix for non-associative functions
1 parent e91c00b commit 1f8d1a0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/types.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ function Base.hash(t::Term{T}, salt::UInt) where {T}
290290
return h′
291291
end
292292

293+
isassociative(::Any) = false
294+
isassociative(::Union{typeof(+),typeof(*)}) = true
295+
293296
_promote_symtype(f::Sym, args) = promote_symtype(f, map(symtype, args)...)
294297
function _promote_symtype(f, args)
295298
if length(args) == 0
@@ -298,9 +301,11 @@ function _promote_symtype(f, args)
298301
promote_symtype(f, symtype(args[1]))
299302
elseif length(args) == 2
300303
promote_symtype(f, symtype(args[1]), symtype(args[2]))
301-
else
304+
elseif isassociative(f)
302305
# TODO: maybe restrict it only to functions that are Associative
303306
mapfoldl(symtype, (x,y) -> promote_symtype(f, x, y), args)
307+
else
308+
promote_symtype(f, map(symtype, args)...)
304309
end
305310
end
306311

0 commit comments

Comments
 (0)