Fix primitive? lookup + replace coercion; remove debug output
primitive? in make_server_env was checking env bindings only (NativeFn), missing all 132 primitives in the Sx_primitives hashtable. Now checks both primitives table and env. get-primitive similarly fixed. replace primitive now coerces SxExpr/Thunk/RawHTML/etc to strings instead of crashing with "replace: 3 string args" — fixes aser JIT DISABLED. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -593,14 +593,17 @@ let make_server_env () =
|
||||
bind "primitive?" (fun args ->
|
||||
match args with
|
||||
| [String name] ->
|
||||
(* Check if name is bound in the env as a NativeFn *)
|
||||
(try match env_get env name with NativeFn _ -> Bool true | _ -> Bool false
|
||||
with _ -> Bool false)
|
||||
(* Check both the primitives table and the env *)
|
||||
Bool (Sx_primitives.is_primitive name ||
|
||||
(try (match env_get env name with NativeFn _ -> true | _ -> false)
|
||||
with _ -> false))
|
||||
| _ -> Bool false);
|
||||
bind "get-primitive" (fun args ->
|
||||
match args with
|
||||
| [String name] ->
|
||||
(try env_get env name with _ -> Nil)
|
||||
(* Check primitives table first, then env *)
|
||||
(try Sx_primitives.get_primitive name
|
||||
with _ -> try env_get env name with _ -> Nil)
|
||||
| _ -> Nil);
|
||||
|
||||
(* Character classification — platform primitives for spec/parser.sx *)
|
||||
|
||||
Reference in New Issue
Block a user