# TypeError: in typeassert in hashindex method

**URL:** <https://discourse.julialang.org/t/typeerror-in-typeassert-in-hashindex-method/69941>\
**Category:** General Usage\
**Tags:** question, error, dictionary\
**Created:** [October 17, 2021, 7:38pm UTC](https://discourse.julialang.org/t/typeerror-in-typeassert-in-hashindex-method/69941 "2021-10-17T19:38:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daneshvar.amrollahi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daneshvar.amrollahi/32/30018_2.png) [@daneshvar.amrollahi](https://discourse.julialang.org/u/daneshvar.amrollahi)\
**Post date:** [October 17, 2021, 7:38pm UTC](https://discourse.julialang.org/t/typeerror-in-typeassert-in-hashindex-method/69941/1 "2021-10-17T19:38:55Z")

</div>

Hi,

I am new to Julia. I am working with a Julia package not written by myself which the writer is not available. I am facing this error:

`ERROR: TypeError: in typeassert, expected UInt64, got a value of type UInt32`

The error is happening on the `haskey` line:

```julia
function find_partition(model::Model, ms)
    ps = Dict{Z3Expr,Vector{Int}}()
    for (i, m) in enumerate(ms)
        mval = Z3.eval(model, m, false)
        println(ps)
        println(mval)
        println(typeof(mval))
        if haskey(ps, mval)
            push!(ps[mval], i)
        else
            push!(ps, mval=>Int[i])
        end
    end
    values(ps)
end

```

The output of the following code is:

Dict{Z3.Expr, Vector{Int64}}()  
1.0  
Z3.ExprAllocated  
ERROR: TypeError: in typeassert, expected UInt64, got a value of type UInt32

Here is the Stacktrace:

```julia
[1] hashindex(key::Z3.ExprAllocated, sz::Int64)
    @ Base ./dict.jl:169
  [2] ht_keyindex(h::Dict{Z3.Expr, Vector{Int64}}, key::Z3.ExprAllocated)
    @ Base ./dict.jl:284
  [3] haskey(h::Dict{Z3.Expr, Vector{Int64}}, key::Z3.ExprAllocated)
    @ Base ./dict.jl:550
  [4] find_partition(model::Z3.ModelAllocated, ms::Vector{Z3.ExprAllocated})
    @ Absynth.NLSat ~/Desktop/faoc/Absynth/src/nlsat/cfinitesolver.jl:101

```

I think this package has been consistent with previous Julia versions. I guess the error is happening because of the type of the variable `sz` which is the length of a dictionary which seems to be different in the current Julia version in comparison to previous ones.

Is there any way I could fix this? Like rewriting this part of the code without the usage of haskey method and recompiling the package?  
All this haskey, ht\_keyindex and hashindex methods are in the dict.jl file of Julia.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [October 17, 2021, 9:29pm UTC](https://discourse.julialang.org/t/typeerror-in-typeassert-in-hashindex-method/69941/2 "2021-10-17T21:29:41Z")

</div>


