# Initializing a persistable class field with a constant leads to linker error

**URL:** <https://forums.unrealengine.com/t/initializing-a-persistable-class-field-with-a-constant-leads-to-linker-error/2648608>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, question, fortnite, verse\
**Created:** [August 20, 2025, 11:00pm UTC](https://forums.unrealengine.com/t/initializing-a-persistable-class-field-with-a-constant-leads-to-linker-error/2648608 "2025-08-20T23:00:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Romanito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Romanito](https://forums.unrealengine.com/u/Romanito)\
**Post date:** [August 20, 2025, 11:00pm UTC](https://forums.unrealengine.com/t/initializing-a-persistable-class-field-with-a-constant-leads-to-linker-error/2648608/1 "2025-08-20T23:00:12Z")

</div>

Here’s a persistable class and its weak\_map:

```verse
using { /Verse.org/Simulation }

var MyClassMap:weak_map(player, my_class) = map{}

my_class := class<final><persistable>:
    MyField:int = 0

```

^ This code compiles with no problem.

I want to use a constant to initialize my field, so I add it:

```verse
using { /Verse.org/Simulation }

MyDefaultValue:int = 0

var MyClassMap:weak_map(player, my_class) = map{}

my_class := class<final><persistable>:
    MyField:int = MyDefaultValue

```

Now this won’t compile anymore, I get this error:

```auto
Script error 9000: Linker task graph contains a cycle:
    (1,1, 1,1): Verse compiler info: Linking object '_Root'
    myclass.verse(8,14, 9,34): Verse compiler info: Linking object 'my_class'
    (1,1, 1,1): Verse compiler info: Linking object '_Root' 

```

The error goes away if I remove the weak\_map declaration.

Am I doing something wrong or is this a Verse bug?

---

<div class="post-metadata">

**Author:** ![BRGJuanCruzMK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brgjuancruzmk/32/1036548_2.png) [@BRGJuanCruzMK](https://forums.unrealengine.com/u/BRGJuanCruzMK)\
**Post date:** [August 27, 2025, 7:43pm UTC](https://forums.unrealengine.com/t/initializing-a-persistable-class-field-with-a-constant-leads-to-linker-error/2648608/2 "2025-08-27T19:43:01Z")

</div>

Hey @Romanito how are you?

I’ve been testing this and what I think is hapenning is that ‘\_Root’ (which is the top-level scope where “MyDefaultValue” lives) has a dependency on “my\_class”, as you are using it in “MyClassMap”. But, at the same time, “my\_class” has a dependency on ‘\_Root’ because you are trying to use “MyDefaultValue”.

That “cycle” could be causing the error you are seeing. And it stops giving you errores when you remove the map because ‘\_Root’ doesn’t have a dependency from “my\_class” anymore, breaking the cycle.

The best thing you can do is to initialize the variable “MyField” as you do in the first code example you shared.

Hope this makes sense!

---

<div class="post-metadata">

**Author:** ![Romanito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Romanito](https://forums.unrealengine.com/u/Romanito)\
**Post date:** [August 27, 2025, 8:06pm UTC](https://forums.unrealengine.com/t/initializing-a-persistable-class-field-with-a-constant-leads-to-linker-error/2648608/3 "2025-08-27T20:06:25Z")

</div>

Hi @BRGJuanCruzMK,

That makes sense, thanks for your explanation. This code is a simplified example but this default value is used in multiple places in my project, hence the use of a global constant. For the time being I’m not using this constant for the field initialization but I’m using it at the other places.
