# E4094

Cannot modify a read-only field.

For a read-only `struct`, you cannot modify the value of a field using
assignment outside of the package where the type is defined.

## Erroneous example

Suppose you have a package `a` in module `username/hello`:

`a/moon.pkg`:

```{literalinclude} /sources/error_codes/4094_error/a/moon.pkg
:language: moonbit
```

`a/a.mbt`:

```{literalinclude} /sources/error_codes/4094_error/a/top.mbt
:language: moonbit
```

And you have another package `b` in the same module:

`b/moon.pkg`:

```{literalinclude} /sources/error_codes/4094_error/moon.pkg
:language: moonbit
```

`b/b.mbt`:

```{literalinclude} /sources/error_codes/4094_error/top.mbt
:language: moonbit
```

## Suggestion

If you have control over the package where the type is defined, expose mutation
through a method in that package.

`a/a.mbt`:

```{literalinclude} /sources/error_codes/4094_fixed/a/top.mbt
:language: moonbit
```

`b/b.mbt`:

```{literalinclude} /sources/error_codes/4094_fixed/top.mbt
:language: moonbit
```
