# @enum macro example fails due to ColorType.jl loaded

**URL:** <https://discourse.julialang.org/t/enum-macro-example-fails-due-to-colortype-jl-loaded/25748>\
**Category:** New to Julia\
**Tags:** question, enum\
**Created:** [June 26, 2019, 9:35pm UTC](https://discourse.julialang.org/t/enum-macro-example-fails-due-to-colortype-jl-loaded/25748 "2019-06-26T21:35:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samusz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samusz/32/7972_2.png) [@samusz](https://discourse.julialang.org/u/samusz)\
**Post date:** [June 26, 2019, 9:35pm UTC](https://discourse.julialang.org/t/enum-macro-example-fails-due-to-colortype-jl-loaded/25748/1 "2019-06-26T21:35:00Z")

</div>

When running this [Base.instances](https://docs.julialang.org/en/v1.1/base/base/#Base.instances) exemple code with Julia 1.2

> julia\> @enum Color red blue green  
> julia\> instances(Color)  
> (red::Color = 0, blue::Color = 1, green::Color = 2)

I got the following error :

> julia\> @enum Color red blue green  
> ERROR: cannot assign a value to variable ColorTypes.Color from module Main  
> Stacktrace:  
> [1] top-level scope at Enums.jl:184

Surprised by a Base function documentation fail, as a double check, (even if the err message isn’t related to @enum), I did

```julia
julia> @enum Age young adult old
julia> instances(Age)
(young, adult, old)

julia> typeof(Color)
UnionAll

julia> instances(Color)
ERROR: MethodError: no method matching instances(::Type{Color})
Closest candidates are:
  instances(::Type{Base.MPFR.MPFRRoundingMode}) at Enums.jl:193
  instances(::Type{LibGit2.Consts.OBJECT}) at Enums.jl:193
  instances(::Type{LibGit2.Consts.DELTA_STATUS}) at Enums.jl:193
  ...
Stacktrace:
 [1] top-level scope at REPL[400]:1

```

So Color is part of the ColorsTypes hierarchy. So this must mean I am using the ColorType.jl , that I’ve must have loaded with some “using Pkg”, possibly Plots.

Finding the explanation for myself is good Julia experience, but still I feel it can be really confusing to get a documentation example fail for newcomers.

Should I open a issue in Julialang/julia to propose to get this example less prone to this kind of name clash error (using another @enum example) ?

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [June 27, 2019, 12:04am UTC](https://discourse.julialang.org/t/enum-macro-example-fails-due-to-colortype-jl-loaded/25748/2 "2019-06-27T00:04:22Z")

</div>

I think a PR to make the documentation example less likely to clash with widely used packages would be welcome.

---

<div class="post-metadata">

**Author:** ![samusz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samusz/32/7972_2.png) [@samusz](https://discourse.julialang.org/u/samusz)\
**Post date:** [June 28, 2019, 7:09pm UTC](https://discourse.julialang.org/t/enum-macro-example-fails-due-to-colortype-jl-loaded/25748/3 "2019-06-28T19:09:08Z")

</div>

@c42f Thanks for your input.  
I’ll do it over the weekend.  
Best.
