v2.3.0#

Upgrading from v2.2.0: what breaks, how to fix it, and what to try.

Dang 2.3 adds no new language version: the newest is still 2.1, and a project reads as whatever its dang = "X.Y" pin says. It fixes how the older versions behave. A project pinned to "1.0" or "2.0" now reads like the Dang it was written for: rescue is an ordinary name again, try { } catch { } is the error handling syntax again, and dang fmt keeps it. In every version, a module's own top-level declarations now shadow builtins such as loop and toString. They used to be silently dropped. $name is a new escape for names spelled like a reserved word, which dang migrate writes when moving 2.0 code to 2.1.

Most projects need no changes. If your project is read as 2.1 (it pins "2.1", has a dang.toml without a dang key, or has no dang.toml), the only change you can hit is declarations shadowing builtins. The rest is for projects pinned to 1.0 or 2.0.

The type-soundness sweep is not in 2.3; it shipped in 2.4 (see the 2.4 notes).

Upgrade checklist#

For a typical project, in order.

  1. Find out which language version your project is read as (table below). Nothing about that changed since v2.2.

  2. Look for top-level declarations named like a builtin (loop, toString, print, …) in directories run as a module (dang ./dir, imported Dang modules, Dagger modules). Your declaration now wins. If you relied on the builtin, rename yours (details).

  3. Pinned to 1.0 or 2.0? Postfix rescue no longer parses there. v2.2's dang fmt wrote it into such projects, so look for it and turn it back into try { } catch { }, or migrate to 2.1 (details).

    grep -rnw rescue --include='*.dang' .   # in a project pinned to 1.0 or 2.0
    
  4. Moving a 2.0 project to 2.1? dang migrate now carries names spelled rescue and try/catch blocks across (details).

    dang migrate        # preview
    dang migrate -w     # rewrite .dang files, bump dang.toml to "2.1"
    

Who is affected#

Per-project language versions and dang migrate arrived in v2.2.0. v2.3 reads projects at the same versions as v2.2. What changed is how 1.0 and 2.0 behave.

Your project Read as rescue try { } catch { }
dang = "1.0" or "2.0" 1.0 / 2.0 an ordinary name changed; no postfix rescue the error syntax, no warning changed
dang = "2.1" 2.1 reserved; postfix rescue still runs, with a warning
dang.toml without a dang key 2.1 reserved; postfix rescue still runs, with a warning
no dang.toml (a lone script) 2.1 reserved; postfix rescue still runs, with a warning

Changes marked 1.0 / 2.0 only apply only to projects pinned to those versions. Changes marked every version apply whatever the pin. Everything marked new works at every version. The pre-2.1 fixes come from Dagger moving old modules off its Dang v1 library onto Dang v2 in dang = "1.0" mode: a parity run found where that mode didn't match Dang v1.

What breaks, and how to fix it#

In order of how likely each is to hit existing code.

A module's declarations shadow builtins every version#

A directory evaluated as a module (dang ./dir, an imported Dang module, a Dagger module) dropped top-level declarations named like a builtin or prelude binding when it ran. The type checker still used them. Every builtin name was affected, loop and toString included. A single file (dang main.dang) was not affected. Now the module's own declaration wins, in type checking and at runtime, as any outer binding would be shadowed.

Beforev2.2, a module's main.dang
pub loop(n: Int!): Int! { n }
loop(2)
# too many positional arguments: got 1, expected at most 0
Afterv2.3
pub loop(n: Int!): Int! { n }
assert { loop(2) == 2 }   # passes in 1.0, 2.0 and 2.1

Likewise let loop = 1 followed by assert { loop == 1 } failed with left: builtin:loop, and now passes.

Unqualified imports still never shadow a builtin. With import Lib, bare toString(1) is the builtin, and Lib.toString(1) reaches the import's.

Fix

Usually nothing: the program now does what it says. If code in the module meant the builtin, rename your declaration.

v2.2's errors are quoted from #212's description; v2.3's behaviour from tests/builtin_shadowing_test.go at v2.3.0. A lone script can't show either, because dang script.dang was never affected.

Postfix rescue is 2.1 syntax 1.0 / 2.0 only#

Dang 2.1 introduced postfix rescue, but v2.2 reserved the word, and parsed the syntax, in every version. Now both start at 2.1. In a project pinned to 1.0 or 2.0, expr rescue … is a syntax error, and a rescue(1) line after let y = foo is a form of its own instead of rescuing the line above. v2.2's dang fmt rewrote try/catch into postfix rescue in those projects too, so formatted code is where to look.

Beforev2.2, pinned 2.0
let unmatched = classify(9) rescue {
  e: Error => e.message
}
Afterv2.3, pinned 2.0
let unmatched = try {
  classify(9)
} catch {
  e: Error => e.message
}
Fix

Write the pinned version's syntax, try { } catch { }, which dang fmt now keeps. Or move the project to 2.1 with dang migrate -w (below), where postfix rescue is right.

The pair is the change #212 made to the migration fixture tests/testdata/migrations/2.0-to-2.1/before/case_unmatched_raises.dang ("2.0 never had postfix rescue"). The syntax error is from TestVersionRescue; run can't pin 2.0, so it was not run here.

What's new and worth trying#

Unless marked, examples were run with dang built at v2.3.0 (3ee188d) and no dang.toml, so at language 2.1, and the output is quoted as printed.

$name is the identifier name new#

Write $rescue to name something rescue where the word is reserved. Only the spelling changes: the name is still rescue, so x.rescue reads a field declared pub $rescue, and a Dagger API name stays rescue. Where only a name can go, you don't need the escape: after a dot, in a {{ }} selection, as a named argument, and as an object key.

Program
let $rescue = 1

inc($rescue: Int!): Int! {
  $rescue + 1
}

type Thing {
  pub $rescue: Int! = 3
}

let thing = Thing
print(inc(rescue: 41))
print(thing.rescue)
print(thing.{{rescue}}.rescue)
print({{rescue: 4}}.rescue)
print($rescue)
Output
42
3
3
4
1
Without the escape, at 2.1
let rescue = 1
print(rescue)

Error: syntax error: unexpected 'rescue'
  --> /tmp/script.dang:2:7

The escape works for any keyword at every version (let $true = 1, let $if = 2, then print($true + $if) prints 3). dang fmt writes it for a name the formatted version reserves, and keeps it wherever the bare word would parse as something else ($true, $self, $break, …).

1.0 and 2.0 projects read like the Dang they were written for 1.0 / 2.0 only#

rescue is a name

Each of these parses again at 1.0 and 2.0. In v2.2 all of them were syntax errors.

let rescue = 1
pub rescue: Int! = 1
f(rescue: Int!): Int! { rescue }
let x = f(rescue: 1)
try/catch keeps its own rules

No warnings, bare err => catch-alls included. A catch with no clauses re-raises, and clauses that can't match are dead code rather than errors. dang fmt leaves it as written.

let x = try {
  boom
} catch {
  err => 1
  e: Error => 2
}
for loops can't be captured

Before 2.1, a for loop runs as a call to the loop builtin. Now that declarations shadow builtins, a module's own loop would capture it, so it calls the builtin by an alias nothing can shadow.

pub loop(n: Int!): Int! { n }   # loop.dang

count(): Int! {                 # main.dang
  let i = 0
  for (i < 3) {
    i += 1
  }
  i
}
assert { count() == 3 }
assert { loop(2) == 2 }
dang fmt keeps for loops

v2.2's formatter printed a pre-2.1 for loop as a loop call, which a module's own loop would then capture, and try/catch as postfix rescue. Both now print as written. Only migrating to 2.1 changes the spelling.

Quoted from TestVersionRescue, TestVersionForLoops (pkg/dang/version_test.go) and tests/builtin_shadowing_test.go at v2.3.0, which pin 1.0 and 2.0 in a dang.toml or through the Go API; not run here.

At 2.1, try/catch still runs as before, with a warning, and dang fmt -w rewrites it to postfix rescue. The exception is a catch that postfix rescue would reject, which the formatter now keeps as written:

Program2.1
let first = try {
  raise "boom"
} catch {
  err => "first"
  e: Error => "second"
}
print(first)
Outputsource excerpts trimmed
Warning: try/catch was replaced by postfix `rescue`; attach `rescue` to an expression or block — run `dang fmt -w` to migrate
  --> /tmp/script.dang:1:13
Warning: bare catch-all `err =>` is no longer supported; bind the error with `err: Error =>` or discard it with `else =>`
  --> /tmp/script.dang:4:3
first

The same clauses written as a postfix rescue fail with unreachable clause: the Error clause on line 2 already matches every error.

dang migrate from 2.0 to 2.1 new#

Migrating to 2.1, the version that reserves rescue, escapes the names spelled like it, public ones included. It rewrites each try/catch to postfix rescue, turning bare err => into err: Error =>, and drops a catch with no clauses. In v2.2, a 2.0 file naming anything rescue didn't parse at all.

Beforedang = "2.0"
let rescue = 1

pub inc(rescue: Int!): Int! {
  rescue + 1
}
assert { inc(rescue: 1) == 2 }

type Thing {
  pub rescue: Int! = 3
}

boom(): String! {
  raise "boom"
}

let typed = try {
  boom()
} catch {
  e: Error => e.message
}

let fallback = try {
  boom()
} catch {
  err => "fallback"
}
Afterdang migrate -w
let $rescue = 1

inc($rescue: Int!): Int! {
  $rescue + 1
}

assert { inc(rescue: 1) == 2 }

type Thing {
  $rescue: Int! = 3
}

boom: String! {
  raise "boom"
}

let typed = boom rescue {
  e: Error => e.message
}

let fallback = boom rescue "fallback"

The dropped pub and () are only dang fmt's usual spelling, which a migrated file is printed in: a function or field declared without pub is public in every version, so the formatter leaves pub implicit, and it drops an empty () from declarations and calls. Neither changes meaning, and neither is new in 2.3.

Excerpts of the migration fixtures rescue_identifier.dang and try_catch.dang under tests/testdata/migrations/2.0-to-2.1/ at v2.3.0; the refusal message is pkg/dang/migrate.go's, with the line number left as N. The pub/() spelling is from formatFieldDecl, formatFunDeclSignature and formatFunCall in pkg/dang/format.go, the same at v2.2.0 and v2.3.0, and from the grammar, where an omitted visibility means public at every version.

Sources and verification#

Sources. v2.3.0 (3ee188d, tagged 2026-10-29) is v2.2.0 (10fb92d) plus one pull request, #212 "Version-gate reserved words; let modules shadow builtins": module declarations shadow builtins (9e98b65), rescue reserved from 2.1 only (187f22c), the $name escape (9eba4b6), unshadowable for loops (7054ac5), formatter fixes (d87acf2), pre-2.1 try/catch rules (ece919c) and migration keeping what rescue can't express (16d9d2d).

Verification. Every program and output under $name, and the 2.1 try/catch warnings and unreachable clause error, were run with dang built at v2.3.0, with no dang.toml (so language 2.1); ANSI colours are stripped and source excerpts trimmed where marked. Behaviour that needs a module directory or a 1.0/2.0 pin can't be run as a lone script, so it is quoted from the tests and fixtures at v2.3.0 named under each example, and v2.2's errors from #212's description.