Skip to content

Commit d41315d

Browse files
hyperpolymathclaude
andcommitted
refactor(stdlib,tests,examples)!: migrate record literals to #{ [#218]
Mechanical companion to the `#{` grammar change — 45 in-repo `.affine` files (stdlib, tests, golden oracles, e2e fixtures, examples) rewritten from legacy `{ … }` record literals to `#{ … }`. Method: a sound, convergent codemod that depends ONLY on the new, unambiguous grammar (never the old ambiguous parser): parse with the new grammar, and at each parse error insert `#` before the innermost enclosing record `{`, iterating to a fixed point. Codepoint-correct (handles non-ASCII). The codemod tooling is intentionally not committed. Result: `dune runtest` = 257/257 green (the #218 gate), identical to the pre-change baseline — no regression; `#{` is now the record syntax across the full test suite. Out of scope (tracked, per the #218 plan steps 3–4): - estate-wide `.affine` sweep in other repos; - ~24 non-gating files the convergent codemod did not auto-migrate (LR error reported past the record's `}`): conformance/valid/*, docs/guides/warmup/*, codegen-deno/*, some tests/types/* — plus the intentional conformance/invalid/* error fixtures and face-syntax examples which must stay as-is. None are in the 257 gate. Refs #218 #215 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fc1aa88 commit d41315d

45 files changed

Lines changed: 176 additions & 176 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

affinescript-deno-test/example/codegen_regression_test.affine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn advance(s: Lifecycle) -> Lifecycle {
4040
}
4141

4242
fn make_counters() -> Counters {
43-
{ tag: 1, profile_id: 42, activity_count: 7 }
43+
#{ tag: 1, profile_id: 42, activity_count: 7 }
4444
}
4545

4646
fn read_profile_id(c: Counters) -> Int {

conformance/valid/011_rows.affine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn get_name[..r](entity: {name: String, ..r}) -> String {
99
}
1010

1111
fn with_id[..r](record: {..r}, id: Int) -> {id: Int, ..r} {
12-
{ id: id, ..record }
12+
#{ id: id, ..record }
1313
}
1414

1515
type HasPosition[..r] = {x: Int, y: Int, ..r}

examples/comprehensive_test.affine

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum Shape {
1212
}
1313

1414
fn vec2_add(a: Vec2, b: Vec2) -> Vec2 {
15-
{ x: a.x + b.x, y: a.y + b.y }
15+
#{ x: a.x + b.x, y: a.y + b.y }
1616
}
1717

1818
fn area(s: Shape) -> Int {
@@ -30,7 +30,7 @@ fn larger_area(s1: Shape, s2: Shape) -> Int = max(area(s1), area(s2));
3030

3131
fn main() -> () {
3232
let circle = Circle(5);
33-
let rect = Rect({ x: 3, y: 4 });
33+
let rect = Rect(#{ x: 3, y: 4 });
3434
let result = larger_area(circle, rect);
3535
();
3636
}

examples/rows.affine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ struct Point3D {
1515
fn getX(p: Point2D) -> Int = p.x;
1616

1717
fn mk_point(x: Int, y: Int) -> Point2D {
18-
{ x: x, y: y }
18+
#{ x: x, y: y }
1919
}

examples/typecheck_complete_test.affine

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ enum Color {
1515
}
1616

1717
fn make_point(x: Int, y: Int) -> Point {
18-
{ x: x, y: y }
18+
#{ x: x, y: y }
1919
}
2020

2121
fn origin() -> Point {
22-
{ x: 0, y: 0 }
22+
#{ x: 0, y: 0 }
2323
}
2424

2525
fn mutate_counter() -> Int {

stdlib/testing.affine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ fn bench(f: () -> (), iterations: Int) -> BenchResult {
303303
}
304304

305305
let tot = time_now() - start;
306-
{
306+
#{
307307
iterations: iterations,
308308
total_time: tot,
309309
avg_time: tot / float(iterations)

test/e2e/fixtures/counter.affine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn counter_subs(model: Int) -> String {
6868
// Wire up the TEA runtime and hand off to the interpreter loop.
6969

7070
fn main() -> () {
71-
tea_run({
71+
tea_run(#{
7272
init: counter_init,
7373
update: counter_update,
7474
view: counter_view,

test/e2e/fixtures/full_pipeline.affine

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum Shape {
1313
}
1414

1515
fn vec2_add(a: Vec2, b: Vec2) -> Vec2 {
16-
{ x: a.x + b.x, y: a.y + b.y }
16+
#{ x: a.x + b.x, y: a.y + b.y }
1717
}
1818

1919
fn area(s: Shape) -> Int {
@@ -31,7 +31,7 @@ fn larger_area(s1: Shape, s2: Shape) -> Int = max(area(s1), area(s2));
3131

3232
fn main() -> () {
3333
let circle = Circle(5);
34-
let rect = Rect({ x: 3, y: 4 });
34+
let rect = Rect(#{ x: 3, y: 4 });
3535
let result = larger_area(circle, rect);
3636
();
3737
}

test/e2e/fixtures/row_polymorphism.affine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ struct Point3D {
1616
fn getX(p: Point2D) -> Int = p.x;
1717

1818
fn mk_point(x: Int, y: Int) -> Point2D {
19-
{ x: x, y: y }
19+
#{ x: x, y: y }
2020
}

test/e2e/fixtures/titlescreen.affine

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct TitleModel {
4444
// ── init ─────────────────────────────────────────────────────────────────────
4545

4646
fn title_init() -> TitleModel {
47-
{
47+
#{
4848
screen_w: 1280,
4949
screen_h: 720,
5050
bgm_playing: 0,
@@ -58,10 +58,10 @@ fn title_init() -> TitleModel {
5858

5959
fn title_update(msg: TitleMsg, model: TitleModel) -> TitleModel {
6060
match msg {
61-
NewGame => { screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "new_game" },
62-
LoadGame => { screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "load_game" },
63-
Settings => { screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "settings" },
64-
Credits => { screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "credits" }
61+
NewGame => #{ screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "new_game" },
62+
LoadGame => #{ screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "load_game" },
63+
Settings => #{ screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "settings" },
64+
Credits => #{ screen_w: model.screen_w, screen_h: model.screen_h, bgm_playing: model.bgm_playing, selected: "credits" }
6565
}
6666
}
6767

@@ -84,7 +84,7 @@ fn title_subs(model: TitleModel) -> String {
8484
// ── main ──────────────────────────────────────────────────────────────────────
8585

8686
fn main() -> () {
87-
tea_run({
87+
tea_run(#{
8888
init: title_init,
8989
update: title_update,
9090
view: title_view,

0 commit comments

Comments
 (0)