# Using revise.jl to sort Invalid redefinition of constant

**URL:** https://discourse.julialang.org/t/using-revise-jl-to-sort-invalid-redefinition-of-constant/65752
**Category:** New to Julia
**Tags:** revise
**Created:** [August 3, 2021, 3:25pm UTC](https://discourse.julialang.org/t/using-revise-jl-to-sort-invalid-redefinition-of-constant/65752 "2021-08-03T15:25:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![imantha](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@imantha](https://discourse.julialang.org/u/imantha)
#### Post date: [August 3, 2021, 3:25pm UTC](https://discourse.julialang.org/t/using-revise-jl-to-sort-invalid-redefinition-of-constant/65752/1 "2021-08-03T15:25:56Z")

</div>

Hi,

I want edit the parameters in a struct. However when I try to change I get an error `ERROR: invalid redifinition of constant ...`

For example if I want to change from

```julia
mutable struct CasAgent
    id::Int
    pos::Dims{2}
end

```

to

```julia
mutable struct CasAgent
    id::Int
    pos::Dims{2}
    TS::Int
end

```

`ERROR: invalid redifinition of constant CasAgent`

I am aware that you can exit and restart to solve this issue however I saw a few posts suggesting that `Revise.jl` can be useful. But got no idea how to do so?. Any ideas how to use do this?

---

<div class="post-metadata">

### Author: ![jakobnissen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobnissen/32/13477_2.png) [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)
#### Post date: [August 3, 2021, 3:42pm UTC](https://discourse.julialang.org/t/using-revise-jl-to-sort-invalid-redefinition-of-constant/65752/2 "2021-08-03T15:42:04Z")

</div>

It is, unfortunately, not possible to redefine types, even with Revise. As far as I know, the issue is that there is no mechanism to invalidate code that used the old definition.

The easiest workaround is to wrap your code in a module, then redefine the module when you change a struct. That works OK, though not quite as smooth as Revise.
