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

# Compact fixup usage page

This is the usage page of **fixup-compact**, a fix up tool for Compact. This document assumes you are using **fixup-compact** directly. Typically, however, the fixup tool is invoked via the **compact** tool's `fixup` command, which is described in the [usage page for that tool](https://docs.midnight.network/compact/compilation-and-tooling/dev-tool-usage.md).

# NAME

fixup-compact

# OVERVIEW

The Compact fixup tool is part of the Compact toolchain. It takes as input a Compact source program in a specified source file, attempts to update the source program to account for recent changes in the Compact language, reformats the updated program, and writes the updated and reformatted program to the specified target file. If a target file is not specified, the formatter writes the updated and reformatted program to standard output.

# SYNOPSIS

**fixup-compact** *flag* **...** *sourcepath* \[ *targetpath* ]

# DESCRIPTION

The flags *flag* **...** are optional. They are described under FLAGS later in this document.

*sourcepath* should specify a file containing a Compact source program, and *targetpath* should specify the file into which the updated and formatted program should be written. *targetpath* may be the same as *sourcepath*, in which case the source program is replaced with the updated and reformatted equivalent. We recommend, however, that you direct the output to a different file and compare it with the original, to verify that the changes make sense.

# FLAGS

The following flags, if present, affect the fixup tool's behavior as follows:

**--help**

Prints help text and exits.

**--version**

Prints the compiler version and exits.

**--language-version**

Prints the language version and exits.

**--vscode**

Causes error messages to be printed on a single line so they are rendered properly within the VS Code extension for Compact.

**--update-Uint-ranges**

Adjusts the end point of each Uint whose size is given by a range with a constant end point and issues a warning for each Uint whose size is given by a range when the end point is a generic-variable reference.

**--compact-path *search list***

Sets the Compact search list to ***search list***, overriding the default (the value of the **COMPACT\_PATH** environment variable, if set, otherwise empty). The search list is a colon-separated (semicolon-separated on Windows) list of directory pathnames.

**--trace-search**

Causes the fixup tool to print a sequence of messages saying where it is looking for each included file and imported module source file.

**--line-length *n***

Sets the target line length to *n* (default 100).

# EXAMPLES

Assuming **src/test.compact** contains a well-formed Compact program, running:

```
fixup-compact src/test.compact
```

prints the updated and formatted program of **src/test.compact** to standard output.

Assuming that **fixed** is an existing directory, running:

```
fixup-compact src/test.compact fixed/test.compact
```

writes the updated and formatted program to **fixed/test.compact**. If the **fixed** directory does not exist the fixup tool complains that it cannot create the output file.

Alternatively, running:

```
fixup-compact src/test.compact src/test.compact
```

rewrites the updated and formatted program to **src/test.compact**.

Assuming **src/test.compact** contains an ill-formed Compact program, running:

```
fixup-compact src/test.compact
```

exits with an error message describing the problem that prevents the Compact program in **src/test.compact** from compiling.
