Skip to content

The method unit(x::Type{Union{Missing,T}}) is causing stack overflow #806

@SeSodesa

Description

@SeSodesa

I've been working on adding Unitful support to FiniteDifferences.jl in JuliaDiff/FiniteDifferences.jl#244, and ran into this issue when running the test suite of the package. The method

Unitful.jl/src/utils.jl

Lines 143 to 145 in c1a9b4e

@inline unit(x::Type{T}) where {T <: Number} = NoUnits
@inline unit(x::Type{Union{Missing, T}}) where T = unit(T)
@inline unit(x::Type{Missing}) = missing
on line 144 of utils.jl is causing stack overflow, probably because of the methods immediately surrounding it. Why does this method exist, if we already have separate methods for Missing and T <: Any? To prefer T != Missing, if it exists?

Anyways, here is the total output of the FiniteDifferences.jl test suite for reference: test.out.txt.

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