Skip to content

Commit

Permalink
Merge pull request #167 from onflow/supun/contract-updatability
Browse files Browse the repository at this point in the history
Remove details about unavailable type-removal pragma
  • Loading branch information
SupunS authored Oct 22, 2024
2 parents 7079a21 + 950efd9 commit 0fb474d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/language/contract-updatability.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ A field may belong to a contract, struct, resource, or interface.
}
```
- Initializer of a contract only run once, when the contract is deployed for the first time. It does not rerun
when the contract is updated. However it is still required to be present in the updated contract to satisfy type checks.
when the contract is updated. However, it is still required to be present in the updated contract to satisfy type checks.
- Thus, the stored data won't have the new field, as the initializations for the newly added fields do not get
executed.
- Decoding stored data will result in garbage or missing values for such fields.
Expand Down Expand Up @@ -231,9 +231,9 @@ A field may belong to a contract, struct, resource, or interface.
prevent performing such an update.

#### Invalid Changes:
- Removing an existing declaration is not valid without using the `#removedType` pragma
- Removing an existing declaration is not valid.
- Removing a declaration allows adding a new declaration with the same name, but with a different structure.
- Any program that uses that declaration would face inconsistencies in the stored data.
- Any program that uses stored data belong to that type would face inconsistencies.
- Renaming a declaration is not valid. It can have the same effect as removing an existing declaration and adding
a new one.
- Changing the type of declaration is not valid. i.e: Changing from a struct to interface, and vise versa.
Expand Down Expand Up @@ -266,6 +266,8 @@ A field may belong to a contract, struct, resource, or interface.
struct Foo {
}
```
- Otherwise, types that used to conform to an interface would no longer conform to that interface, which would lead
to type safety issues at runtime.

### Updating Members
Similar to contracts, these composite declarations: structs, resources, and interfaces also can have fields and
Expand Down

0 comments on commit 0fb474d

Please sign in to comment.