> For the complete documentation index, see [llms.txt](https://docs.midnight.network/llms.txt)

# Compact compiler 0.21.0 (Compact language 0.14.0)

Compact is Midnight's dedicated smart contract programming language, designed for building secure, efficient, and adaptable decentralized applications.

Compact compiler translates Compact smart contract code into executable bytecode and proof-generating circuits.

***

23 January 2025

## Compact compiler 0.21.0 (Compact language 0.14.0) release notes[​](#compact-compiler-0210-compact-language-0140-release-notes "Direct link to Compact compiler 0.21.0 (Compact language 0.14.0) release notes")

Today we are releasing version 0.21.0 of the Compact compiler. This release updates the language version to 0.14.0, which contains a number of improvements over language version 0.13.x, and some breaking changes. This is a big update to the language, so read these release notes carefully to understand the changes.

The new release is available for you to try out. If you recompile your Compact code with the new compiler, you may need to update your code to accommodate the breaking changes.

## Summary of Changes[​](#summary-of-changes "Direct link to Summary of Changes")

### Language Changes[​](#language-changes "Direct link to Language Changes")

* **\[Breaking change]** Witness return values may need to be "disclosed."
* Square brackets construct TypeScript-compatible tuples.
* You can use TypeScript-compatible destructuring.
* **\[Breaking change]** The `Void` type is removed.
* **\[Breaking change]** The syntax of `for` loops is aligned with TypeScript.
* **\[Breaking change]** The `Cell` ledger ADT is now implicit.
* **\[Breaking change]** Ledger ADT names are now part of the standard library.
* Exported circuits are allowed to have the same name as witnesses.
* Improved syntax error messages.

***

## Language Changes[​](#language-changes-1 "Direct link to Language Changes")

### **\[Breaking Change]** Witness Return Values May Need to Be "Disclosed"[​](#breaking-change-witness-return-values-may-need-to-be-disclosed "Direct link to breaking-change-witness-return-values-may-need-to-be-disclosed")

In Compact 0.14.0, witness return values are considered private data. To prevent unintentional "leaks" of this data (e.g., writing it to the public ledger), the compiler now enforces explicit disclosure using the new `disclose` syntax.

#### Example:[​](#example "Direct link to Example:")

```
// Pre-0.14.0 version:

poster = public_key(local_secret_key(), instance as Field as Bytes<32>);



// Post-0.14.0 version with disclosure:

poster = disclose(public_key(local_secret_key(), instance as Field as Bytes<32>));
```

#### Why We Made This Change[​](#why-we-made-this-change "Direct link to Why We Made This Change")

To ensure contract developers are deliberate about revealing potentially private data.

#### How to Fix Your Code[​](#how-to-fix-your-code "Direct link to How to Fix Your Code")

Wrap witness return values with `disclose` when intentionally revealing private data.

***

### Square Brackets Construct TypeScript-Compatible Tuples[​](#square-brackets-construct-typescript-compatible-tuples "Direct link to Square Brackets Construct TypeScript-Compatible Tuples")

Square brackets now construct tuples instead of vectors. Tuples allow precise tracking of element types and are compatible with TypeScript.

#### Example:[​](#example-1 "Direct link to Example:")

```
// Tuple example:

const tuple = [1, 2, 3]; // Type: [Uint<0..0>, Uint<0..1>, Uint<0..2>]



// Tuple subtyping example:

const vector: Vector<3, Uint<8>> = tuple;
```

Vector types still exist; tuples with identical element types are equivalent to vectors.

***

### You Can Use TypeScript-Compatible Destructuring[​](#you-can-use-typescript-compatible-destructuring "Direct link to You Can Use TypeScript-Compatible Destructuring")

Destructuring is now supported for tuples, vectors, and structs in const bindings and circuit parameters, including arrow circuits.

#### Example:[​](#example-2 "Direct link to Example:")

```
const [x, y] = [1, 2];



circuit example([a, b]: [Uint<8>, Uint<8>]): Uint<8> {

  return a + b;

}
```

#### Limitations:[​](#limitations "Direct link to Limitations:")

* The `...` (spread) syntax is not yet supported.
* Destructuring does not work for ledger field assignments.

***

### **\[Breaking Change]** The `Void` Type Is Removed[​](#breaking-change-the-void-type-is-removed "Direct link to breaking-change-the-void-type-is-removed")

The `Void` type has been replaced with the empty tuple type `[]`. A circuit or witness that does not return a useful value should now return `[]`.

#### Example:[​](#example-3 "Direct link to Example:")

```
// Old syntax:

circuit foo(): Void {

  return;

}



// New syntax:

circuit foo(): [] {

  return [];

}
```

#### Why We Made This Change[​](#why-we-made-this-change-1 "Direct link to Why We Made This Change")

`Void` behaved in unintuitive ways and was replaced with a simpler and more consistent unit type.

#### How to Fix Your Code[​](#how-to-fix-your-code-1 "Direct link to How to Fix Your Code")

Replace occurrences of `Void` with `[]`.

***

### **\[Breaking Change]** The Syntax of `for` Loops Is Aligned with TypeScript[​](#breaking-change-the-syntax-of-for-loops-is-aligned-with-typescript "Direct link to breaking-change-the-syntax-of-for-loops-is-aligned-with-typescript")

The syntax for `for` loops now matches TypeScript. Use `for (const x of collection)` instead of the previous Compact-specific syntax.

#### Examples:[​](#examples "Direct link to Examples:")

```
// Old syntax:

for x in v do {

  // Loop body

}



// New syntax:

for (const x of v) {

  // Loop body

}
```

#### Why We Made This Change[​](#why-we-made-this-change-2 "Direct link to Why We Made This Change")

To reduce syntactic differences with TypeScript.

#### How to Fix Your Code[​](#how-to-fix-your-code-2 "Direct link to How to Fix Your Code")

Update `for` loops to use the new syntax.

***

### **\[Breaking Change]** The `Cell` Ledger ADT Is Now Implicit[​](#breaking-change-the-cell-ledger-adt-is-now-implicit "Direct link to breaking-change-the-cell-ledger-adt-is-now-implicit")

Ledger fields no longer explicitly declare `Cell`. Instead, Compact treats them as cells implicitly.

#### Example:[​](#example-4 "Direct link to Example:")

```
// Old syntax:

ledger state: Cell<STATE>;



// New syntax:

ledger state: STATE;
```

#### Why We Made This Change[​](#why-we-made-this-change-3 "Direct link to Why We Made This Change")

To simplify ledger field declarations.

#### How to Fix Your Code[​](#how-to-fix-your-code-3 "Direct link to How to Fix Your Code")

Remove `Cell` from ledger field declarations.

***

### **\[Breaking Change]** Ledger ADT Names Are Now Part of the Standard Library[​](#breaking-change-ledger-adt-names-are-now-part-of-the-standard-library "Direct link to breaking-change-ledger-adt-names-are-now-part-of-the-standard-library")

Ledger ADT type names (e.g., `Counter`, `Set`) are no longer built-in identifiers. They are now part of the standard library and must be imported explicitly.

#### Example:[​](#example-5 "Direct link to Example:")

```
import CompactStandardLibrary;



const counter: Counter = CompactStandardLibrary.Counter();
```

#### Why We Made This Change[​](#why-we-made-this-change-4 "Direct link to Why We Made This Change")

To allow more flexible naming and modularity.

#### How to Fix Your Code[​](#how-to-fix-your-code-4 "Direct link to How to Fix Your Code")

Import the standard library if you use ledger ADTs.

***

### Exported Circuits Are Allowed to Have the Same Name as Witnesses[​](#exported-circuits-are-allowed-to-have-the-same-name-as-witnesses "Direct link to Exported Circuits Are Allowed to Have the Same Name as Witnesses")

Exported circuits can now share names with witnesses. The compiler will flag ambiguities as errors, but most valid use cases will work without modification.

***

### Improved Syntax Error Messages[​](#improved-syntax-error-messages "Direct link to Improved Syntax Error Messages")

Syntax error messages now indicate both the expected syntax and the issue encountered, making it easier to understand and resolve errors.

***

## TL;DR[​](#tldr "Direct link to TL;DR")

🚀 Compact language 0.14.0 introduces breaking changes and improvements:

* **Witness disclosure**: Use `disclose` for witness return values when needed.
* **Tuples**: Square brackets now create tuples, compatible with TypeScript.
* **Destructuring**: TypeScript-compatible destructuring for tuples, vectors, and structs.
* **`Void` removed**: Use the empty tuple type `[]` instead.
* **`for` loops**: Aligned with TypeScript syntax.
* **Ledger fields**: `Cell` is now implicit.
* **Ledger ADTs**: Part of the standard library.
* **Error messages**: More helpful syntax errors.

Make sure to update your code to take advantage of these changes!

## Artifacts[​](#artifacts "Direct link to Artifacts")

* [Compiler Linux](https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_0.21.0/compactc-linux.zip)
* [Compiler macOS](https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_0.21.0/compactc-macos.zip)
