# Surprising behaviour of @enum conversion from Integer types

**URL:** https://discourse.julialang.org/t/surprising-behaviour-of-enum-conversion-from-integer-types/23556
**Category:** New to Julia
**Tags:** enum
**Created:** [April 26, 2019, 1:30pm UTC](https://discourse.julialang.org/t/surprising-behaviour-of-enum-conversion-from-integer-types/23556 "2019-04-26T13:30:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![speps](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/speps/32/8186_2.png) [@speps](https://discourse.julialang.org/u/speps)
#### Post date: [April 26, 2019, 1:30pm UTC](https://discourse.julialang.org/t/surprising-behaviour-of-enum-conversion-from-integer-types/23556/1 "2019-04-26T13:30:45Z")

</div>

I have this code :

```julia
@enum EnumTest::UInt32 begin
	ONE = 1
	TWO = 2
end

@show EnumTest(2) # this works
convert(EnumTest, 2) # this fails

```

The output is

```julia
EnumTest(2) = TWO::EnumTest = 0x00000002
ERROR: LoadError: MethodError: Cannot `convert` an object of type Int64 to an object of type EnumTest
Closest candidates are:
  convert(::Type{T}, !Matched::T) where T at essentials.jl:154
  EnumTest(::Integer) at Enums.jl:134

```

I should have thought the second candidate would be matched. What’s happening?

Thanks.
