Skip to content

Commit

Permalink
Rewrite scalartype to avoid stackoverflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Mar 30, 2024
1 parent 131ec00 commit 10fd08d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/fallbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ end
#------------
function scalartype(T::Type)
@warn _warn_message(scalartype, T) maxlog = 1
if applicable(eltype, T)
return scalartype(eltype(T))
else
throw(ArgumentError(_error_message(scalartype, T)))
end
# the following does not work because `eltype` is always applicable.
# applicable(eltype, T) && return scalartype(eltype(T))
elT = eltype(T)
elT === Any && throw(ArgumentError(_error_message(scalartype, T)))
return scalartype(elT)
end
# should this try to use `eltype` instead? e.g. scalartype(T) = scalartype(eltype(T))

Expand Down

1 comment on commit 10fd08d

@lkdvos
Copy link
Collaborator Author

@lkdvos lkdvos commented on 10fd08d Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #12

Please sign in to comment.