mutable decl syntax change

This commit is contained in:
2026-08-05 21:19:41 +02:00
parent 88b94197c9
commit 081a3fd5df
74 changed files with 870 additions and 733 deletions
+12 -12
View File
@@ -19,7 +19,7 @@ basic func() i32 {
# Typed `T =`: the yield coerces to the annotation.
typed func() i64 {
x i64 = {
x i64 := {
yield 100
}
return x
@@ -29,7 +29,7 @@ typed func() i64 {
# local, but the captured value is unchanged.
spill func() i32 {
v :: {
n i32 = 5
n i32 := 5
defer n = 999
yield n
}
@@ -38,7 +38,7 @@ spill func() i32 {
# Reassignment into an existing mutable local.
reassign func() i32 {
r i32 = 0
r i32 := 0
r = {
yield 7
}
@@ -61,13 +61,13 @@ vif_untyped func(sel i32) i32 {
# Typed `T =`: every branch coerces to the annotation.
vif_typed func(sel i32) i32 {
r i32 = if (sel == 0) { yield 100 } else { yield 200 }
r i32 := if (sel == 0) { yield 100 } else { yield 200 }
return r
}
# Assigned into an existing local.
vif_reassign func(sel i32) i32 {
r i32 = 0
r i32 := 0
r = if (sel == 0) { yield 7 } else { yield 9 }
return r
}
@@ -76,7 +76,7 @@ vif_reassign func(sel i32) i32 {
# the yield.
vif_defer func() i32 {
r :: if (true) {
n i32 = 5
n i32 := 5
defer n = 999
yield n
} else {
@@ -123,7 +123,7 @@ loop_none func() i32 {
# Labeled `while` value loop (label follows the `: update` clause).
loop_while func() i32 {
n i32 = 0
n i32 := 0
found :: while n < 100 : n += 1 blk: {
if (n == 8) yield :blk n
yield null
@@ -199,7 +199,7 @@ lblock func(sel i32) i32 {
# the block's defer runs.
lblock_defer func() i32 {
r :: blk: {
n i32 = 5
n i32 := 5
defer n = 999
if (true) yield :blk n
yield :blk 0
@@ -235,7 +235,7 @@ yield_outer func(target i32) i32 {
# Plain `break :outer` exits an outer loop from an inner loop.
break_outer func() i32 {
count i32 = 0
count i32 := 0
for 0..3 |a| outer: {
for 0..3 |b| {
count += 1
@@ -247,7 +247,7 @@ break_outer func() i32 {
# A labeled block *statement* (not a value source): `break :blk` exits it early.
stmt_block func(early i32) i32 {
x i32 = 0
x i32 := 0
blk: {
x = 1
if (early == 1) break :blk
@@ -259,7 +259,7 @@ stmt_block func(early i32) i32 {
# `break :search` escapes a nested loop and the block in one jump; the block's
# defer still runs on the way out.
stmt_block_escape func() i32 {
hits i32 = 0
hits i32 := 0
search: {
defer hits += 1000
for 0..10 |i| {
@@ -273,7 +273,7 @@ stmt_block_escape func() i32 {
# A labeled block can also be exited through an ordinary nested block.
stmt_block_nested func() i32 {
hits i32 = 0
hits i32 := 0
outer: {
{
hits = 1