Skip to content

Commit d0654d4

Browse files
fix(stdlib): rename try->attempt, ref->make_ref (#135 slice 6) (#156)
#135 slice 6 — keyword-as-identifier. Two stdlib externs/fns were named with reserved keywords and could not parse in fn-name position: - result.affine `fn try<T>` — `try` is the try/catch/finally keyword -> renamed `attempt` (its body still uses the real `try { } catch`). - effects.affine `extern fn ref<T>` — `ref` is the ownership keyword -> renamed `make_ref`. Pure stdlib rename — zero grammar/compiler change, zero risk. No other stdlib file referenced the old names (verified). Both files now clear the parse wall and advance to deeper, distinct later-slice defects (result -> empty-array `(T,Int)` family = slice 7; effects -> generic- extern kind-checking, separate). Resolve-at-source via rename was the recommended option in the triage doc (local + safe vs a broad contextual-keyword grammar change). Advances #135. Refs #128, #135. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 24379f9 commit d0654d4

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

stdlib/effects.affine

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ extern fn read_file(path: String) -> String / io;
1818
extern fn write_file(path: String, content: String) -> Unit / io;
1919

2020
// Built-in State operations
21-
extern fn ref<T>(x: T) -> Ref<T> / state;
21+
// `make_ref` (not `ref`) because `ref` is a reserved ownership keyword;
22+
// see #135 keyword-as-identifier slice.
23+
extern fn make_ref<T>(x: T) -> Ref<T> / state;
2224
extern fn get<T>(r: Ref<T>) -> T / state;
2325
extern fn set<T>(r: Ref<T>, x: T) -> Unit / state;
2426

stdlib/result.affine

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ fn result_or<T, E>(a: Result<T, E>, b: Result<T, E>) -> Result<T, E> {
225225
// Error Handling Patterns
226226
// ============================================================================
227227

228-
/// Try block emulation - execute function and catch panics as Err
229-
fn try<T>(f: () -> T) -> Result<T, String> {
228+
/// Try block emulation - execute function and catch panics as Err.
229+
/// Named `attempt` (not `try`) because `try` is a reserved keyword
230+
/// (try/catch/finally); see #135 keyword-as-identifier slice.
231+
fn attempt<T>(f: () -> T) -> Result<T, String> {
230232
// TODO: Requires exception handling support
231233
try {
232234
Ok(f())

0 commit comments

Comments
 (0)