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.
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.