Repository navigation
v0.4.0 — Classes, exceptions and Linux x86-64
dartc 0.4.0 brings class hierarchies, enums, custom operators, native doubles and synchronous exceptions to the native compiler. It also adds a Linux x86-64 archive alongside macOS ARM64 and Linux ARM64.
Upgrading from 0.3: replace the whole native archive, including
lib/. The internal runtime ABI moves from 14 to 17. Use a 0.4.0 native seed when rebuilding the compiler from source; the compiler now uses syntax that 0.3 cannot compile. See the upgrade steps below.
🧩 Use richer Dart classes and function values
Combine primary constructors, enums, constructor values, operators and contextual dot shorthands in ordinary Dart code:
enum Axis { x, y }
class Vector(final double x, final double y) {
Vector operator +(Vector other) => Vector(x + other.x, y + other.y);
double component(Axis axis) => switch (axis) {
.x => x,
.y => y,
};
}
void main() {
final create = Vector.new;
final sum = create(1.5, 2.0) + create(2.0, 4.0);
print(sum.component(.x)); // 3.5
}Non-generic classes also gain abstract declarations, inheritance, interfaces, super parameters and factory constructors. Enums provide values, index and name; their switches are checked for exhaustiveness. Custom indexing operators work with compound assignment and increments, preserving evaluation order and separate read/write conversions.
Function values now accept optional and named arguments, including the target's defaults:
String decorate(String value, {String prefix = 'dartc'}) => '$prefix: $value';
void main() {
final format = decorate;
print(format('hello', prefix: 'native')); // native: hello
}Non-generic closures inside generic functions can also retain enclosing type arguments after the outer call returns.
Classes and constructors · Function values and captures
🧹 Handle synchronous failures and cleanup
throw, typed catches, finally and rethrow now work across native call frames. finally runs on normal completion, exceptions, returns and jumps:
double positive(String input) {
final value = double.parse(input);
if (value < 0) throw 'negative value';
return value;
}
void main() {
try {
print(positive('-1.5'));
} on String catch (message) {
print(message); // negative value
} finally {
print('done');
}
}Catch clauses can receive a stack trace. StackTrace.current, StackTrace.fromString and StackTrace.empty are available too. This covers synchronous Dart throws; failed type, bounds, late and other runtime checks still terminate the process rather than producing catchable exceptions.
Exception behavior and remaining work
🐧 Compile for Linux x86-64
The new linux-x64 target uses the same language implementation as the ARM64 targets. Select it explicitly when cross-compiling:
dartc app.dart --target linux-x64 -o app-linux-x64Run the resulting executable on Linux x86-64. Native compiler archives include the matching Dart runtime sources; compilation and generated executables need no installed Dart SDK or VM. Linux library output and external FFI remain unimplemented.
Other changes
- Double arithmetic, decimal parsing, shortest round-trip formatting and numeric conversions are now available, including mixed numeric values and constants.
latelocals, captures, globals and typed fields initialize lazily and check final writes and recursive initialization.- ARM64 integer division and modulo by zero now stop before later side effects. Non-returning calls and missing-return checks also preserve their control-flow behavior through native compilation.
Upgrading and downloads
Download the archive matching your host and verify it against SHA256SUMS:
| Platform | Download |
|---|---|
| macOS ARM64 | dartc-0.4.0-macos-arm64.tar.gz |
| Linux ARM64 | dartc-0.4.0-linux-arm64.tar.gz |
| Linux x86-64 | dartc-0.4.0-linux-x64.tar.gz |
Keep bin/ and lib/ from the same archive. For a source checkout with an older seed, explicitly select the new compiler, for example on macOS ARM64:
dart tool/bootstrap.dart --seed /path/to/dartc-0.4.0-macos-arm64/bin/dartcThe pub package hosts dartc on the official Dart SDK. Update that distribution with:
dart pub global activate dartc 0.4.00.4.0 remains an early preview, with Dart SDK 3.13.7 as the behavior reference. Complete Dart language and standard-library implementation remains the goal; specs owns the current support and gaps.