StaticLint.jl icon indicating copy to clipboard operation
StaticLint.jl copied to clipboard

False positive: Defining a new constructor causes a type to longer be understood as a type

Open dzhang314 opened this issue 5 months ago • 0 comments

Consider the following Julia code:

module M

struct MyNumber
    sign::Bool
    exponent::Int
    mantissa::Int
end

function BigFloat(::MyNumber)
    ...
end

function cube_root(x::BigFloat)
    ...
end

end # module M

This yields blue squiggles under the definition of function cube_root(x::BigFloat) with the following message:

A non-DataType has been used in a type declaration statement. Julia(InvalidTypeDeclaration)

Here, the presence of a new constructor BigFloat(::MyNumber) has caused StaticLint to stop regarding BigFloat as a type. This pattern occurs a few times in my package MultiFloats.jl.

dzhang314 avatar Sep 13 '24 23:09 dzhang314