From 579d899fd8980df5f2016dcbcaea434f2d8a3892 Mon Sep 17 00:00:00 2001 From: belowzeroff Date: Tue, 22 Sep 2026 04:22:42 -0400 Subject: [PATCH 1/2] fix(system): reject arguments to gc --- src/ops/system.c | 3 ++- test/rfl/system/reserved_namespace.rfl | 8 ++++---- test/rfl/system/system_branch_cov.rfl | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ops/system.c b/src/ops/system.c index 176415645..c72e2da4c 100644 --- a/src/ops/system.c +++ b/src/ops/system.c @@ -872,7 +872,8 @@ ray_t* ray_mem_ts_fn(ray_t** args, int64_t n) { * pages/pools. Rayforce values are reference-counted, so this is allocator * GC rather than a tracing collector. Variadic to allow `(.sys.gc)`. */ ray_t* ray_gc_fn(ray_t** args, int64_t n) { - (void)args; (void)n; + (void)args; + if (n != 0) return ray_error("domain", ".sys.gc takes no arguments"); ray_heap_gc(); /* Same statement-boundary rule as the REPL: an explicit maintenance * call is also a chance to notice the process has gone quiet. */ diff --git a/test/rfl/system/reserved_namespace.rfl b/test/rfl/system/reserved_namespace.rfl index fd0d72382..d8db459a6 100644 --- a/test/rfl/system/reserved_namespace.rfl +++ b/test/rfl/system/reserved_namespace.rfl @@ -5,10 +5,10 @@ ;; `'?` regardless of arity — so we exercise by calling, which is ;; what actually matters here.) ;; .sys.gc returns 0 on success — doubles as a binding-exists probe. -;; Registered as variadic so both (.sys.gc) and (.sys.gc 0) work; -;; other .sys.* info builtins follow the same convention. +;; Registered as variadic so the zero-argument call remains valid while +;; the implementation can reject unexpected arguments explicitly. (.sys.gc) -- 0 -(.sys.gc 0) -- 0 +(.sys.gc 0) !- domain (count (.sys.info)) -- 5 (count (.sys.mem)) -- 16 (count (.sys.build)) -- 2 @@ -116,7 +116,7 @@ internals !- name (del .sys.gc) !- reserve (del .os.getenv) !- reserve ;; Built-in still resolves after the blocked shadow attempts. -(.sys.gc 0) -- 0 +(.sys.gc) -- 0 (nil? .os.getenv) -- false ;; User-level dotted writes under a non-`.` root still work. (set myns.x 1) diff --git a/test/rfl/system/system_branch_cov.rfl b/test/rfl/system/system_branch_cov.rfl index 32adf1dd5..a139b5087 100644 --- a/test/rfl/system/system_branch_cov.rfl +++ b/test/rfl/system/system_branch_cov.rfl @@ -179,8 +179,8 @@ ;; ray_gc_fn (line 539) ;; ══════════════════════════════════════════════════════════════════════ (.sys.gc) -- 0 -(.sys.gc 0) -- 0 -(.sys.gc "x") -- 0 +(.sys.gc 0) !- domain +(.sys.gc "x") !- domain ;; ────────────── teardown ────────────── (.sys.exec "rm -rf /tmp/rfl_sys_bc_*") From 0dbc7a8c7f3cd0101bb49745ead0e29190bf0d28 Mon Sep 17 00:00:00 2001 From: belowzeroff Date: Tue, 22 Sep 2026 04:30:35 -0400 Subject: [PATCH 2/2] docs(memory): use zero-argument gc form --- docs/docs/guides/memory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/guides/memory.md b/docs/docs/guides/memory.md index 998c1d2d6..0ae3b4771 100644 --- a/docs/docs/guides/memory.md +++ b/docs/docs/guides/memory.md @@ -389,7 +389,7 @@ This tells you the join needed about 1 GB of temporary memory beyond what was al | Tool | What It Does | When to Use | |---|---|---| | `(.sys.mem 0)` | Returns heap allocation statistics | Monitor memory usage, detect leaks | -| `(.sys.gc 0)` | Flushes caches, releases pages | Between heavy queries, before benchmarks | +| `(.sys.gc)` | Flushes caches, releases pages | Between heavy queries, before benchmarks | | `(.sys.info 0)` | Shows system and runtime info | Check total RAM, CPU count, OS details | | `(timeit expr)` | Measures execution time of one expression | Benchmark a specific operation | | `:timeit` | Toggles profiling for all REPL expressions | Interactive performance exploration |