Baffling ERROR: LoadError: type DataType has no field contents


#1

the following is not at all important. I know it works if the Point initializer method is outside the function. this is pure curiosity. why would the following not work?

mutable struct Point; x::Float64; end#struct 

function x()
    Point(x::Int) = Point( Float64(x) )
    isindomain( p::Point )= (!isinf(p.x))

    println(isindomain(Point(2)) && "we are all good")
end

the error message seems pretty bad, though.

ERROR: LoadError: type DataType has no field contents

took me a while to figure out what the problem was. if initializers in general are not allowed inside functions, then it could probably give a more descriptive error.


#2

On the latest master, this instead gives:

ERROR: syntax: local variable Point cannot be used in closure declaration

which at least suggests that something is wrong in your code, but is still not terribly clear.