fix(codegen): http_serve 1-arg backward-compat — auto-inject handle_request
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.
This commit is contained in:
@@ -690,6 +690,12 @@ fn cg_expr(expr: Map<String, Any>) -> 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 }
|
||||
|
||||
Reference in New Issue
Block a user