# Baffling ERROR: LoadError: type DataType has no field contents

**URL:** https://discourse.julialang.org/t/baffling-error-loaderror-type-datatype-has-no-field-contents/10333
**Category:** General Usage
**Created:** [April 14, 2018, 4:09pm UTC](https://discourse.julialang.org/t/baffling-error-loaderror-type-datatype-has-no-field-contents/10333 "2018-04-14T16:09:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [April 14, 2018, 4:09pm UTC](https://discourse.julialang.org/t/baffling-error-loaderror-type-datatype-has-no-field-contents/10333/1 "2018-04-14T16:09:10Z")

</div>

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?

```julia
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.

```julia
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.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [April 14, 2018, 7:39pm UTC](https://discourse.julialang.org/t/baffling-error-loaderror-type-datatype-has-no-field-contents/10333/2 "2018-04-14T19:39:41Z")

</div>

On the latest `master`, this instead gives:

```julia
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.
