COBCH1486 Field field-name can only be modified inside constructor

The program contains an instance field defined with the INITIALIZE ONLY phrase, and that is modified outside of a constructor (new) method.

Resolution:

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

Example:

In the following example, the M1 method, which is not a 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 method. This is correct because the NEW method is a constuctor method.

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