Add js.sx bootstrapper docs page with G0 bug discovery writeup
Documents the self-hosting process for js.sx including the G0 bug where Python's `if fn_expr` treated 0/False/"" as falsy, emitting NIL instead of the correct value. Adds live verification page, translation differences table, and nav entry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -872,7 +872,7 @@ class JSEmitter:
|
||||
body = fn_expr[2:]
|
||||
loop_body = self._emit_loop_body(name, body)
|
||||
return f"var {self._mangle(name)} = function() {{ while(true) {{ {loop_body} }} }};"
|
||||
val = self.emit(fn_expr) if fn_expr else "NIL"
|
||||
val = self.emit(fn_expr) if fn_expr is not None else "NIL"
|
||||
return f"var {self._mangle(name)} = {val};"
|
||||
|
||||
def _is_self_tail_recursive(self, name: str, body: list) -> bool:
|
||||
|
||||
@@ -1305,12 +1305,7 @@
|
||||
(symbol-name (nth expr 1))
|
||||
(str (nth expr 1))))
|
||||
(val-expr (nth expr 2)))
|
||||
;; Match G0 bootstrap_js.py: Python `if fn_expr` treats 0/false/None/""
|
||||
;; as falsy, so (define x 0) emits NIL instead of 0. Reproduce for byte-match.
|
||||
(if (or (nil? val-expr)
|
||||
(and (= (type-of val-expr) "number") (= val-expr 0))
|
||||
(and (= (type-of val-expr) "boolean") (= val-expr false))
|
||||
(and (= (type-of val-expr) "string") (= val-expr "")))
|
||||
(if (nil? val-expr)
|
||||
(str "var " (js-mangle name) " = NIL;")
|
||||
;; Detect zero-arg self-tail-recursive functions → while loops
|
||||
(if (and (list? val-expr)
|
||||
|
||||
Reference in New Issue
Block a user