Clarity's type checker is meant to ensure that a value's type at analysis matches its type at runtime. The SIP identifies edge cases where that did not hold and proposes fixes in four areas.
Type-checking soundness. According to the SIP, the checker accepted some code whose runtime values didn't match their declared types. Examples:
- Two tuples with different fields could merge into a narrower type, letting a hidden field travel through merge, is-eq and lists.
- fold over an empty sequence could return a value of a type the checker never accounted for.
- Extra arguments passed to a function were never type-checked but were still evaluated, which could trigger an early return. Under the proposal, extra arguments would fail analysis for user-defined and native functions alike.
Analysis and runtime agreement. The analyzer and the runtime sometimes read the same code differently. The proposal would align them:
- let names would be checked against every global name, not only function names.
- A contract could call its own traits during deployment, which currently fails with NoSuchContract.
Consistent value limits. Rules that apply to values built in Clarity would apply to values from any source:
- from-consensus-buff? would return none for tuples with missing, extra or duplicate fields.
- Contract names over 40 bytes would be rejected everywhere, including transaction arguments and NFT post-conditions.
Errors and costs. Some failures cause a transaction to be rejected outright when, per the SIP, it should be included in a block as a failed, fee-paying transaction. The proposal would continue the conversion started in SIP-039. It would also charge costs for all work performed, including type checking of contracts that fail analysis and the identifiers carried by trait and contract principal values.
Under the proposal, analysis changes would apply only to contracts deployed after activation. Runtime changes, such as the new cost charges, would apply to all contracts.