Skip to content

recursive_bottom_eltype breaks when given non-numeric type or value #54

@janlucaklees

Description

@janlucaklees

Hi all,

I'd like to discuss the implementation of the recursive_bottom_eltype function found in utils.jl on line 79 - 80.

I don't think the context is really necessary here. If you are curious, I added it at the end. I just happened to stumble across this.

So here's what I don't like:
The recursive_bottom_eltype seems to be written with only Numbers in mind, while at the same time not explicitly disallowing non-numeric values.
This leaves us with a function that works for numbers, but for Strings (and I suspect all other non-numeric type) it fails badly in a StackOverflowError. Because there is no other definition for non-numeric types other than the one that call itself recursively.

Steps to reproduce this error:
Run recursive_bottom_eltype("I love to eat up stack space") in your Julia shell.

How I would like it:
Instead of failing with a StackOverflowError the function should either directly throw an adequate error for non-numeric values, or it should be extended to also work for other types as well.

And here is where I would like to hear your suggestions. I don't know this Package really at all, so I can't tell which way would be the better one.

I would offer to implement a solution myself, after hearing your feedback on which way would be more suitable for this package.

As promised, the context:
I am trying to implement a dynamic solver (using DiffEqFlux) that uses a custom (not yet build) DSL. The idea is that this way the end-user does not need to learn Julia and how to handle any of the Packages involved, but just can model their problem using this DSL.
So I am at the beginning of this and rather than using a DLS I just use strings that will be evaluated during the solving with the Meta package. (I know, I know, performance and security; This is just to get things going and figure out other stuff in my project.) And so I ended up passing arrays of strings into the solving function of DiffEqFlux (more specifically in the problem for the solving function) rather than a arrays of numbers. And somehow diffeq_fd ends up calling recursive_bottom_eltype on the u0 or u array (not too sure form looking at their code). But as explained above, strings cause the recursive_bottom_eltype function to recurse infinitely. And thus, here I am complaining ;P

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