- Language mode
- 6.0
- Product
- Not released
Using the checklist
Review the execution results section even if your source passes the 6.0 check. The comparisons follow the language rules and the interpreter source for both editions. Later sections link to diagnostics and examples for source changes.
Follow the 6.0 alpha migration guide to preview and check your code. The design decision record shows the implementation status of each rule.
Same source, different execution results
- Arrays, maps and sets change independently after assignment, argument passing, return or field storage. For example,
let a = [1, 2],let mut b = aandb.leave lengthspush(3) 3:3in 5.21 and2:3in 6.0. Look for a collection stored in a second binding or field, followed by an indexed write or a method such aspush,insertoradd. If callers need the updated value, return it and assign it where it is used. Mutable closures can still share a variable. Open files still use shared resource handles. Decision · Example - An indexed assignment writes to the collection currently held by its binding after the right-hand side runs. If
shrink()rebindsxsto[7]and returns5, thenxs[0] = shrink()leavesxsas[7]in 5.21 and[5]in 6.0. Look for indexed writes whose right-hand sides call a function that can rebind the target. Make the order explicit with separate statements when both changes are intentional. Decision · Example - Float interpolation and derived display keep a fractional digit even for large integral floats. Interpolating
1000000000000000.yields0 1000000000000000in 5.21 and1000000000000000.in 6.0. Look for interpolated floats and derived display output used in snapshots, text comparisons or file formats. Review consumers that require a particular spelling. Decision · Example0 - Inside a multiline literal, a source line containing only spaces or tabs keeps those bytes in 5.21. In 6.0 it contributes an empty line. Look inside
"""literals for lines made only of spaces or tabs, especially in byte comparisons and templates. Use escapes or interpolation for whitespace that belongs in the resulting text. Decision · Example - A physical lone CR inside multiline string text can survive in 5.21 as a carriage return. In 6.0 it becomes a newline, just like CRLF and LF. Search source files for byte
0without a followingD 0insideA """literals. Write\ras an escape in an ordinary string when the resulting data needs a carriage return. Decision · Example
Comments, names and literals
- Replace
/with* … */ /at the start of each comment line. Move any code that followed the closing delimiter onto its own line. Decision · TPZ2001 · Example/ - Replace semicolon separators with line breaks. If a trailing semicolon discarded the final value of a block, write
let _on the last line. Decision · TPZ2001 · Example= expression - Put identifier spellings in Unicode 16 NFC in declarations and at each use. Leave string data as written. Decision · TPZ0007 · Example
- Write binary and hexadecimal prefixes as
0band0x. Use lowercaseathroughfin hexadecimal digits, as in0→XFF 0xff. Decision · TPZ2001 · Example - Replace
p"notes"withPath.after importingfrom("notes") Pathfromstd.. Handle the resultingpath Ok(path)andErr(error)cases. Decision · TPZ2002 · Example
Expressions and control flow
- Add parentheses around control operands and guards, as in
if (test),while (test)andmatch (value). Themigratepreview can add these parentheses where the 5.21 parser records an unparenthesized control operand. Decision · TPZ2001 · Example - Remove unary
+and keep the operand, as in+1→1and+value→value. Decision · TPZ2001 · Example - Replace pipelines and expression placeholders with ordinary calls. For
value |> f(arg, _, save) valuein aletbefore callingf(arg, saved). For composition, save the two function values in order asfirstandsecond, then use(x) => second(first(x)). Decision · TPZ2001 · Example - An
ifwithoutelseyields(). If the enclosing expression needs a value, supply anelsebranch with a compatible type, as inif (test) { 7 } else { 0 }. Decision · TPZ5001 · Example - A
forloop returns(). To collect the loop results into an array, write a comprehension such as[for item in (items) => item * 2]. Decision · TPZ5001 · Example - Give
defera block. Rewritedefer f()asdefer { f() }. Decision · TPZ2004 · Example - Move a
return,break,continueor?that exits adeferbody outside the cleanup block. Handle cleanup errors inside the block if the cleanup itself can fail. Decision · TPZ5001 · Example
Patterns and match arms
- Wrap range patterns by hand, as in
case (1 .. The automatic edit for control operands does not wrap range patterns. Decision · TPZ2001 · Example. 3) => 1 - Write the argument list for a constructor in both values and patterns, even when it is empty. Replace bare
NonewithNone()and write a qualified variant asChoice.. Decision · TPZ2012 · ExampleEmpty() - Write each record pattern field as
field: pattern. Replace{x}with{x: x}to bind a field to a name with the same spelling. Decision · TPZ2001 · Example - Give
.in a list pattern a following pattern. To ignore the remainder, use. ., as in. _ [first, .. Decision · TPZ2001 · Example. _ ] - Use a block when a
matcharm returns from the enclosing function. Rewritecase true => return 7ascase true => { return 7 }. Decision · TPZ2001 · Example - Cover every possible input, including cases inside constructor payloads. Add explicit cases for missing values or a final unguarded
case _for the remainder. A guarded arm does not establish coverage. Decision · TPZ5021 · Example - Remove an arm fully covered by earlier unguarded arms. If it should handle a special case, place the specific case before the broader one. Arms are tried in source order. Decision · TPZ5713 · Example
- Remove a literal range pattern that can never match, or fix its bounds. For example,
(0 .is empty and. < 0) (0 .matches zero. Decision · TPZ5714 · Example. 0)
Functions and calls
- Parenthesize every lambda parameter list. Rewrite
x => x + 1as(x) => x + 1. Decision · TPZ2001 · Example - Pass arguments in parameter order. If reordering would change when an argument expression runs, evaluate the expressions in their original order into local names first. To keep independent options named, change the function to take a settings record. Decision · TPZ2001 · Example
identity<int> (1)andidentity<int>(1)both parse as calls with type arguments. Remove the type arguments for a non-generic function, as inidentity(1). If you intended a comparison, use parentheses to make the comparison explicit. Decision · TPZ5512 · Example- Give repeated parameters in one function or lambda different names. Update references in the body to the intended parameter. Decision · TPZ5008 · Example
- Remove the default from a variadic parameter, as in
.. If an empty argument list should use fallback values, select them explicitly when the collected array is empty. Decision · TPZ2001 · Example. . values: int - For a field or method read on an unconstrained generic parameter, declare the required operation in a protocol. Add a bound such as
T: Readableand useReadable.. Decision · TPZ5006 · Exampleread(value) - A call through a union needs each argument to have one type accepted by every possible callee. Add a type annotation if the branches accept a common type but inference lacks context. If the branches require different callback types, narrow the union first and make a separate call in each case. Decision · TPZ5020 · Example
Bindings, constructors and updates
- Keep one type annotation for a binding. Replace
let answer: int: int = 1withlet answer: int = 1. Decision · TPZ2001 · Example - A local
functionshadows an outer name throughout the block. For a direct call before the local declaration, put the declaration first. If that call was meant to reach an outer function, give the local function a distinct name. Decision · TPZ3018 · Example - Rename bindings, parameters or functions that share a name with a visible constructor, and update their uses. For an imported constructor, check its name as seen in the importing module, including any alias. Decision · TPZ5712 · Example
- To construct a value, write a call such as
Choice.. To pass the operation as a function value, wrap that call in a lambda, as inFull(value) (value) => Choice.. Decision · TPZ5004 · ExampleFull(value) - Write each field once per structural record update. If earlier field expressions must still run, evaluate them separately in their intended order before writing the final field value. Decision · TPZ5008 · Example
- When you need to retain a changed value, bind it with
let mutbefore calling the mutator. When you need the return value of a call on a temporary, use it, as inlet last = make().. Decision · TPZ5027 · Examplepop() - To call a mutating method later, store a lambda that calls it on a mutable binding, as in
let add = (v) => xs.. The receiver is accessed when the lambda runs. Decision · TPZ5028 · Examplepush(v) - For a write such as
xs?., make the root binding mutable. To start from an immutable parameter or loop variable, first copy its value into a mutable local binding. Decision · TPZ5003 · Examplepush(2)
Protocols
- Remove the type parameter from protocol declarations such as
protocol Labelled<T>. In the protocol method signatures, writeSelfwhereTnamed the conforming type. Keep naming the concrete type inimpl Labelled<Item>. Decision · TPZ2001 · Example - Remove parameter defaults and per-method
exportfrom protocol implementations. Keep any default in the protocol declaration if it belongs to the common interface. For a fallback specific to one caller, pass it explicitly at that call site. Decision · TPZ5022 · Example
Imports, errors and concurrency
- Remove
aswhen it repeats the imported name. For example, replaceimport lib as libwithimport lib. Decision · TPZ2009 · Example - To change an imported array locally, copy its value with
let mut localand updateItems = items local. That changes the local value. Decision · TPZ5003 · ExampleItems - When a record field default reads a name in another module, use an exported name. For example, if
defaults.belongs in that module’s public interface, declareseed export let seed: int = 41indefaults. Decision · TPZ3009 · Example - Use public types in exported signatures, including types inferred from function bodies or expanded from aliases. Export a nominal type if it belongs to the public interface. Otherwise, return or accept a public representation at the boundary. Decision · TPZ3014 · Example
- When the checker cannot infer the error type of a
Result, annotate the return type with the intended error type. For example, a function that returnsOk(1)can declare-if it uses string errors. Decision · TPZ5022 · Example> Result<int, string> - Have a concurrent arm produce a result value. Handle an enclosing function return, loop transfer or error propagation after the group instead of transferring control out of the arm. Decision · TPZ5001 · Example
- An empty
concurrent {}group yields an empty record. If you need its result, use the record type{}. If the surrounding expression needs unit, discard the group result and produce()explicitly. Decision · TPZ5001 · Example