COBCH1485 Field field-name can only be modified inside class constructor

The program contains a static field defined with the INITIALIZE ONLY phrase, and that is modified outside of a class constructor (new static) method. This is not allowed.

Resolution:

Change the code to modify the static field inside of a class constructor, or make other appropriate code adjustments to eliminate the coding error.

Example:

In the following example, the MAIN static method, which is not a class constructor method, modifies the INIT-ONLY field. Because the INIT-ONLY field is defined with the INITIALIZE ONLY phrase, this is incorrect. The example also correctly shows the INIT-ONLY field modified by the NEW static method. This is correct because the NEW method is a class constuctor.

       class-id a.
       01 init-only string initialize only static.
       method-id main static.
           move "A" to init-only    *> Error
       end method.
       method-id new static.
           move "A" to init-only    *> Ok
       end method.
       end class.