Fix parse-int to handle 2-arg form (value + default)

cssx-resolve calls (parse-int "699" nil) — the 2-arg form was
falling to the catch-all and returning Nil, causing colour tokens
like text-violet-699 to not generate CSS rules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 16:31:41 +00:00
parent 8f2a51af9d
commit 364fbac9e1

View File

@@ -633,7 +633,10 @@ let make_server_env () =
bind "parse-int" (fun args ->
match args with
| [String s] -> (try Number (float_of_int (int_of_string s)) with _ -> Nil)
| [Number n] -> Number (Float.round n)
| [String s; default_val] ->
(try Number (float_of_int (int_of_string s)) with _ -> default_val)
| [Number n] | [Number n; _] -> Number (Float.round n)
| [_; default_val] -> default_val
| _ -> Nil);
bind "json-encode" (fun args -> io_request "helper" (String "json-encode" :: args));