# Redefining Identical Struct

**URL:** https://discourse.julialang.org/t/redefining-identical-struct/16047
**Category:** General Usage
**Created:** [October 8, 2018, 11:39pm UTC](https://discourse.julialang.org/t/redefining-identical-struct/16047 "2018-10-08T23:39:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)
#### Post date: [October 8, 2018, 11:39pm UTC](https://discourse.julialang.org/t/redefining-identical-struct/16047/1 "2018-10-08T23:39:47Z")

</div>

Redefining a struct with an identical definition does not lead to an `ERROR: LoadError: invalid redefinition of constant` error:

```julia
mutable struct LFKernel
  A0::Array{Float64, 2}
end

mutable struct LFKernel
  A0::Array{Float64, 2}
end

```

Is it supposed to? After reorganizing some code, I found I had duplicate definitions in different files.

It also appears this can be used to trick the language into keeping the default constructor while also providing an inner constructor:

```julia
mutable struct LFKernel
  A0::Array{Float64, 2}

  function LFKernel(a::Int, b::Int)

    return new(zeros(a, b))
  end
end

mutable struct LFKernel
  A0::Array{Float64, 2}
end

LFKernel(2, 3) # no error
LFKernel(zeros(2, 3)) # also no error

```

This could potentially lead to confusion about what constructors a type has by looking at the source code when the definitions are in different files.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 9, 2018, 12:07am UTC](https://discourse.julialang.org/t/redefining-identical-struct/16047/2 "2018-10-09T00:07:12Z")

</div>

I think this is indeed intended.

---

<div class="post-metadata">

### Author: ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)
#### Post date: [October 9, 2018, 12:26am UTC](https://discourse.julialang.org/t/redefining-identical-struct/16047/3 "2018-10-09T00:26:50Z")

</div>

Is there a rationale for this? On the surface, it doesn’t look particularly useful.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 9, 2018, 1:15am UTC](https://discourse.julialang.org/t/redefining-identical-struct/16047/4 "2018-10-09T01:15:47Z")

</div>

including a file twice in the REPL for example.
