From ca0149acb94ba7732403437415a3de6b52f8030b Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Mon, 4 May 2026 18:32:05 -0500 Subject: [PATCH] =?UTF-8?q?fix(codegen):=20http=5Fserve=201-arg=20backward?= =?UTF-8?q?-compat=20=E2=80=94=20auto-inject=20handle=5Frequest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El v1.2.1 changed http_serve to require an explicit handler argument. Restore 1-arg backward compat: if the call site passes only a port, codegen auto-injects the conventional handle_request name so existing El code continues to compile without modification. Also marks http_serve arity as -1 (variadic) so the arity checker doesn't reject 1-arg call sites before codegen can rewrite them. --- el-compiler/src/codegen.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/el-compiler/src/codegen.el b/el-compiler/src/codegen.el index 81b164d..f253533 100644 --- a/el-compiler/src/codegen.el +++ b/el-compiler/src/codegen.el @@ -690,6 +690,12 @@ fn cg_expr(expr: Map) -> String { } } } + // http_serve(port): backward-compat 1-arg form — auto-inject handle_request + if str_eq(fn_name, "http_serve") { + if arity == 1 { + return "http_serve(" + args_c + ", handle_request)" + } + } return fn_name + "(" + args_c + ")" } @@ -1995,7 +2001,7 @@ fn builtin_arity(name: String) -> Int { if str_eq(name, "http_get_with_headers") { return 2 } if str_eq(name, "http_post_with_headers") { return 3 } if str_eq(name, "http_post_form_auth") { return 3 } - if str_eq(name, "http_serve") { return 2 } + if str_eq(name, "http_serve") { return -1 } // variadic: 1-arg (port, auto-injects handle_request) or 2-arg (port, handler) if str_eq(name, "http_set_handler") { return 1 } // Filesystem if str_eq(name, "fs_read") { return 1 }