From 4a007e61b9603bc806c2450221dea6401d86659b Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Sun, 17 May 2026 11:18:12 +0100 Subject: [PATCH] fix(stdlib): rename try->attempt, ref->make_ref (#135 slice 6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #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` — `try` is the try/catch/finally keyword -> renamed `attempt` (its body still uses the real `try { } catch`). - effects.affine `extern fn ref` — `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) --- stdlib/effects.affine | 4 +++- stdlib/result.affine | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stdlib/effects.affine b/stdlib/effects.affine index 4408e059..259bf22f 100644 --- a/stdlib/effects.affine +++ b/stdlib/effects.affine @@ -18,7 +18,9 @@ extern fn read_file(path: String) -> String / io; extern fn write_file(path: String, content: String) -> Unit / io; // Built-in State operations -extern fn ref(x: T) -> Ref / state; +// `make_ref` (not `ref`) because `ref` is a reserved ownership keyword; +// see #135 keyword-as-identifier slice. +extern fn make_ref(x: T) -> Ref / state; extern fn get(r: Ref) -> T / state; extern fn set(r: Ref, x: T) -> Unit / state; diff --git a/stdlib/result.affine b/stdlib/result.affine index 32cce913..17078644 100644 --- a/stdlib/result.affine +++ b/stdlib/result.affine @@ -225,8 +225,10 @@ fn result_or(a: Result, b: Result) -> Result { // Error Handling Patterns // ============================================================================ -/// Try block emulation - execute function and catch panics as Err -fn try(f: () -> T) -> Result { +/// Try block emulation - execute function and catch panics as Err. +/// Named `attempt` (not `try`) because `try` is a reserved keyword +/// (try/catch/finally); see #135 keyword-as-identifier slice. +fn attempt(f: () -> T) -> Result { // TODO: Requires exception handling support try { Ok(f())