# Avoid \`expected Int32, got Int64 value\` error on CI

**URL:** https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695
**Category:** General Usage
**Tags:** testing
**Created:** [June 28, 2021, 1:23pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695 "2021-06-28T13:23:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)
#### Post date: [June 28, 2021, 1:23pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/1 "2021-06-28T13:23:56Z")

</div>

I have an odd error on github actions where my tests fail on `x86` machines but pass on `x64`. Basically this:

```julia
Single Baseline Region: Error During Test at /home/runner/work/LandUse.jl/LandUse.jl/test/model_test.jl:1
385
  Got exception outside of a @test
386
  TypeError: in setfield!, expected Int32, got a value of type Int64

```

In the definition of the concerned data type, I changed all things like

```julia
x :: Int64

```

to

```julia
x :: Int

```

but to no avail. what am I missing?

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [June 28, 2021, 1:27pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/2 "2021-06-28T13:27:55Z")

</div>

Any chance you can link to the code?

---

<div class="post-metadata">

### Author: ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)
#### Post date: [June 28, 2021, 1:45pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/3 "2021-06-28T13:45:48Z")

</div>

unfortunately no. but you just got me onto the right lead I think. I use `JSON.parse` to read default param values into the data type. look what I found:

```julia
help?> JSON.parse
  parse{T<:Associative}(str::AbstractString;
                        dicttype::Type{T}=Dict,
                        inttype::Type{<:Real}=Int64,
                        allownan::Bool=true,
                        null=nothing)

```

that’s it right? How can I know the machine type , so that I can set `inttype` correctly?

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [June 28, 2021, 1:49pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/4 "2021-06-28T13:49:18Z")

</div>

> [@floswald](#):
>
> How can I know the machine type , so that I can set `inttype` correctly?

You can just use `Int` I suppose.

---

<div class="post-metadata">

### Author: ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)
#### Post date: [June 28, 2021, 1:52pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/5 "2021-06-28T13:52:00Z")

</div>

good point. let me try that. for future reference, I thought also that this could work

```julia
JSON.parse(f,inttype = Sys.ARCH == :x86_64 ? Int64 : Int32)

```

but your idea is better I think.

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [June 28, 2021, 2:59pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/6 "2021-06-28T14:59:14Z")

</div>

Unless you want to ignore all non-Intel 64-bit platforms, I believe you wanted to check `Sys.WORD_SIZE == 64`, but `Int` is just much better. `Sys.WORD_SIZE` is defined depending on the size of `Int`:

> <https://github.com/JuliaLang/julia/blob/74fab49ffba4913fd93edb742ed53c5728bc4c42/base/sysinfo.jl#L97>

---

<div class="post-metadata">

### Author: ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)
#### Post date: [June 28, 2021, 3:06pm UTC](https://discourse.julialang.org/t/avoid-expected-int32-got-int64-value-error-on-ci/63695/7 "2021-06-28T15:06:12Z")

</div>

I see! Thanks !
