diff --git a/docs/docs/guides/memory.md b/docs/docs/guides/memory.md index 998c1d2d..0ae3b477 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 | diff --git a/src/ops/system.c b/src/ops/system.c index 17641564..c72e2da4 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 fd0d7238..d8db459a 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 32adf1dd..a139b508 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_*")