Skip to main content

Syntax Migration Notes

For the design rationale behind these syntax rules, see language-manifesto.md. For exact style expectations, see canonical-syntax-rules.md. For contributor guardrails, see contributor-language-rules.md.

This repository now documents and tests the following syntax as canonical:

Removed from canonical syntax

  • Inline variable annotations such as let value: Int = 1
  • Inline function signatures as the primary style such as fn add(a: Int, b: Int) -> Int
  • @layer blocks
  • Import examples without an explicit module source

Deprecated but still accepted for compatibility

  • Inline field and function annotations in older source files
  • Legacy function type syntax fn(Int) -> Int
  • Older import forms that omit from module.path

These forms remain temporarily to avoid breaking existing projects, but they are no longer the documented style.

In the Rust compiler/tooling path:

  • default mode keeps legacy inline type syntax working and emits deprecation warnings
  • drat build --strict-syntax and drat run --strict-syntax turn the same deprecated forms into hard errors

An in-tree self-host rewrite now lives under compiler/, but canonical syntax enforcement is still authoritative in the Rust frontend/tooling path today. The self-host stage0 pipeline currently runs lex_json in Draton while parse_json, typeck_json, and build_json still bridge through Rust host builtins, so the rewrite must keep matching the same canonical surface instead of reviving compatibility-form syntax.

Canonical replacements

Variable declaration:

let value = 1

Type declarations via @type:

@type {
value: Int
add: (Int, Int) -> Int
}

Explicit returns:

fn add(a, b) {
return a + b
}

Class and layer organization:

class User {
let name

layer info {
fn greet() {
return "hello " + name
}
}

@type {
name: String
greet: () -> String
}
}

Brace imports:

import { login } from services.auth
import { http as nethttp } from std.net

Scope rules for @type

@type blocks are supported at:

  • file/module scope
  • class scope
  • layer scope
  • interface scope
  • function scope

Each scope uses the same declaration shape:

@type {
name: Type
}

Canonical examples for the newly supported scopes:

fn parse_head() {
@type {
head: Node??
}
let head = None
return head
}

interface Drawable {
fn draw()

@type {
draw: () -> Int
}
}

Repository status tracking for future self-host work:

Current CI status:

  • strict syntax is enforced through Rust frontend/tooling checks such as drat build --strict-syntax
  • the repository also exercises an in-tree self-host stage0 surface, but that surface is not a separate syntax authority while host bridges remain in use