Skip to content

Commit e88c8ec

Browse files
committed
Align ION_SPEC with the compiler and fix Ion snippets in the spec and writing-ion-code skills.
1 parent 0f60d50 commit e88c8ec

3 files changed

Lines changed: 157 additions & 149 deletions

File tree

.cursor/skills/writing-ion-code/SKILL.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ let items: Vec<MyStruct> = Vec::new(); // element type from annotation
7171
**Integer limits**
7272

7373
```ion
74-
if n == int::MIN { ... }
74+
if n == int::MIN {
75+
return 0;
76+
}
7577
let cap: int = int::MAX;
7678
```
7779

@@ -91,7 +93,7 @@ Tuple values (flat only, no nesting): `let t: (int, int) = (1, 2);` then `t.0`,
9193
**Control flow**
9294

9395
- `if` / `else if` / `else` conditions must be `bool`.
94-
- `while`, `loop`, `break`, `continue`, `for x in expr;` (`for` ends with `;` per grammar).
96+
- `while`, `loop`, `break`, `continue`, `for x in expr` over `Vec<T>`, `[T; N]`, or `String` (bytes as `u8`)
9597
- `match expr { Pattern => { ... } }` with guards `pattern if cond =>`.
9698

9799
**Methods**

.cursor/skills/writing-ion-code/references/verified-patterns.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let x: int = Box::unwrap(b);
7878
```ion
7979
let arr: [int; 3] = [1, 2, 3];
8080
let fill: [u8; 4] = [0; 4];
81-
let slice: []int = arr; // array to slice coercion
81+
let s: &[]int = &arr; // array-to-slice coercion via borrow
8282
let elem: int = arr[0]; // bounds checked unless unsafe
8383
```
8484

@@ -147,9 +147,7 @@ Multi-file mode prefixes each module's C symbols (`io_print_int`, `fmt_print_int
147147

148148
## Channel send expressions
149149

150-
`send(&tx, make())` is valid ([tests/test_channel_send_call_expr.ion](../../../../tests/test_channel_send_call_expr.ion)).
151-
152-
Expression form `tx<-value` exists in grammar; prefer `send(&tx, value)` to match tests and examples.
150+
`send(&tx, make())` is valid ([tests/test_channel_send_call_expr.ion](../../../../tests/test_channel_send_call_expr.ion)). Use `send(&tx, value)` and `recv(&mut rx)` (see [examples/spawn_channel/spawn_channel.ion](../../../../examples/spawn_channel/spawn_channel.ion)).
153151

154152
## if / ownership merge
155153

@@ -190,7 +188,7 @@ channel<&int>()
190188
spawn { use_ref(&x); };
191189
192190
// use after move
193-
let v = Vec::new();
191+
let v: Vec<int> = Vec::new();
194192
let w = v;
195193
let _ = v.len();
196194
```

0 commit comments

Comments
 (0)