# Cannot declare constant it already has a value

**URL:** <https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 3, 2022, 5:23pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372 "2022-03-03T17:23:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![the\_dude](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_dude/32/33355_2.png) [@the\_dude](https://discourse.julialang.org/u/the_dude)\
**Post date:** [March 3, 2022, 5:23pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/1 "2022-03-03T17:23:34Z")

</div>

I used this struct I created a lot of times, but now, out of nothing, my VSCode started presenting this:

 ![error_constant](https://global.discourse-cdn.com/julialang/original/3X/0/3/037cc37062d55ddbe20471d0bbb9e0dab72db7f7.png)

Any idea of what is happening?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 3, 2022, 6:09pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/2 "2022-03-03T18:09:11Z")

</div>

I can reproduce this easily:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/d/dd6eb39abe45f420f1b980b414d5c39ae49d9339.png)

you see the line at the beginning `cow=1`.  
So my guess you already have defined `Cow` somewhere else. Didn’t you want to take a break? 😉 Or did you took your nap already?

---

<div class="post-metadata">

**Author:** ![the\_dude](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_dude/32/33355_2.png) [@the\_dude](https://discourse.julialang.org/u/the_dude)\
**Post date:** [March 3, 2022, 6:56pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/3 "2022-03-03T18:56:12Z")

</div>

I know… I’m sorry, but I can’t. The deadline for my graduation project is tomorrow and my Dissertation advisor asked me to do some modifications on it. 😓

Couldn´t find it yet. Now the warning is appearing in two other struct files (out of nothing too)!

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 3, 2022, 7:18pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/4 "2022-03-03T19:18:05Z")

</div>

Use search of VSCode.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [March 3, 2022, 7:53pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/5 "2022-03-03T19:53:07Z")

</div>

If you changed the definition of those structs and didn’t restart julia, this would happen as well. You cannot redefine a struct within a given session; it’s considered const.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 3, 2022, 7:59pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/6 "2022-03-03T19:59:04Z")

</div>

> [@the\_dude](#):
>
> my Dissertation advisor asked me to do some modifications on it.

so you have been working on this Julia code for months now ?

---

<div class="post-metadata">

**Author:** ![the\_dude](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_dude/32/33355_2.png) [@the\_dude](https://discourse.julialang.org/u/the_dude)\
**Post date:** [March 3, 2022, 8:07pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/7 "2022-03-03T20:07:50Z")

</div>

> If you changed the definition of those structs and didn’t restart julia, this would happen as well. You cannot redefine a struct within a given session; it’s considered const.

It worked! Thank you!

> so you have been working on this Julia code for months now ?

About one year. I already presented it a few times. But now I’m creating a code for generate new data for testing.

---

<div class="post-metadata">

**Author:** ![SSF](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@SSF](https://discourse.julialang.org/u/SSF)\
**Post date:** [May 11, 2023, 4:16pm UTC](https://discourse.julialang.org/t/cannot-declare-constant-it-already-has-a-value/77372/8 "2023-05-11T16:16:20Z")

</div>

> [@the\_dude](#):
>
> If you changed the definition of those structs and didn’t restart julia, this would happen as well. You cannot redefine a struct within a given session; it’s considered const.

Thanks! I had the same issue coming from the fact that I included twice the same file containing a structure definition.
