Summary
Source code audit found 7 stdlib functions across 5 modules that are partially wired across the compiler pipeline, meaning they either silently fail, produce broken C output, or are documented in the standard but never implemented. All need to be fully implemented end-to-end.
1. random.seed() — codegen only, missing 3 layers
- Header (
ez_random.h): No ez_random_seed() declaration
- Implementation (
ez_random.c): No user-facing seed function (only an internal ensure_seed() that auto-seeds with srand(time(NULL)))
- Typechecker: Not registered — rejected as unknown function before reaching codegen
- Codegen: Listed in
func_to_mod[] mapping table (codegen.c), so codegen would attempt to emit ez_random_seed() if it ever got there
Impact: Typechecker rejects the call, so users get an error. The codegen entry is dead code pointing at a function that doesn't exist.
Fix: Implement random.seed() end-to-end:
- Add
void ez_random_seed(int64_t value) to ez_random.h
- Implement it in
ez_random.c — call srand((unsigned)value) and set _seeded = true
- Register in typechecker under the random module section (void return)
- Codegen entry already exists
2. json.format() — typechecker only, no codegen handler
- Header (
ez_json.h): No dedicated format function
- Implementation (
ez_json.c): No format function
- Typechecker (
typechecker.c): Accepted — returns string type
- Codegen (
emit_json_call): No case for "format" — falls through, returns false, and hits the generic fallback path producing broken C
Impact: User can write json.format(value) and the typechecker accepts it, but codegen produces broken or incorrect C output.
Fix: Wire json.format() in codegen as an alias for json.encode() (the standard describes them as doing the same thing). Add a strcmp(func, "format") == 0 case in emit_json_call that dispatches identically to the encode path.
3. csv.format() — typechecker only, no codegen handler
- Typechecker: Accepted — returns
string type
- Codegen (
emit_csv_call): No case for "format" — falls through and produces broken C
Impact: Same class as json.format(). Typechecker accepts csv.format() but codegen has no handler.
Fix: Add a strcmp(func, "format") == 0 case in emit_csv_call, likely as an alias for csv.encode() / csv.stringify().
4. csv.headers() — typechecker only, no codegen handler
- Typechecker: Accepted
- Codegen (
emit_csv_call): No case for "headers" — falls through and produces broken C
Impact: Typechecker accepts csv.headers() but codegen has no handler.
Fix: Implement ez_csv_headers() in the C layer and wire the codegen case.
5. server.cors() — typechecker only, no codegen handler
- Typechecker: Accepted
- Codegen (
emit_server_call): No case for "cors" — falls through and produces broken C
Impact: Typechecker accepts server.cors() but codegen has no handler.
Fix: Implement ez_server_cors() in the C layer and wire the codegen case.
6. server.use() — typechecker only, no codegen handler
- Typechecker: Accepted
- Codegen (
emit_server_call): No case for "use" — falls through and produces broken C
Impact: Typechecker accepts server.use() but codegen has no handler.
Fix: Implement ez_server_use() in the C layer and wire the codegen case.
7. sync.try_lock() — missing entirely
- Header (
ez_sync.h): No try_lock declaration
- Implementation (
ez_sync.c): No try_lock function
- Typechecker: Not registered
- Codegen: Not handled
- Standard (STANDARD.md): Documents
sync.try_lock() as an existing function
Impact: Standard says it exists but it was never built. Users reading the docs will try to use it and get an error.
Fix: Implement sync.try_lock() end-to-end across all 4 layers. Should wrap pthread_mutex_trylock() and return a bool.
Bug Class
All 7 fall into the same pattern: the compiler pipeline is incomplete for these functions. Items 2-6 are the most dangerous — the typechecker accepts the call, so the user thinks it's valid, but codegen produces broken C. Items 1 and 7 are less dangerous since the typechecker rejects them, but the standard/codegen entries create confusion.
Summary
Source code audit found 7 stdlib functions across 5 modules that are partially wired across the compiler pipeline, meaning they either silently fail, produce broken C output, or are documented in the standard but never implemented. All need to be fully implemented end-to-end.
1.
random.seed()— codegen only, missing 3 layersez_random.h): Noez_random_seed()declarationez_random.c): No user-facing seed function (only an internalensure_seed()that auto-seeds withsrand(time(NULL)))func_to_mod[]mapping table (codegen.c), so codegen would attempt to emitez_random_seed()if it ever got thereImpact: Typechecker rejects the call, so users get an error. The codegen entry is dead code pointing at a function that doesn't exist.
Fix: Implement
random.seed()end-to-end:void ez_random_seed(int64_t value)toez_random.hez_random.c— callsrand((unsigned)value)and set_seeded = true2.
json.format()— typechecker only, no codegen handlerez_json.h): No dedicatedformatfunctionez_json.c): Noformatfunctiontypechecker.c): Accepted — returnsstringtypeemit_json_call): No case for"format"— falls through, returnsfalse, and hits the generic fallback path producing broken CImpact: User can write
json.format(value)and the typechecker accepts it, but codegen produces broken or incorrect C output.Fix: Wire
json.format()in codegen as an alias forjson.encode()(the standard describes them as doing the same thing). Add astrcmp(func, "format") == 0case inemit_json_callthat dispatches identically to theencodepath.3.
csv.format()— typechecker only, no codegen handlerstringtypeemit_csv_call): No case for"format"— falls through and produces broken CImpact: Same class as json.format(). Typechecker accepts
csv.format()but codegen has no handler.Fix: Add a
strcmp(func, "format") == 0case inemit_csv_call, likely as an alias forcsv.encode()/csv.stringify().4.
csv.headers()— typechecker only, no codegen handleremit_csv_call): No case for"headers"— falls through and produces broken CImpact: Typechecker accepts
csv.headers()but codegen has no handler.Fix: Implement
ez_csv_headers()in the C layer and wire the codegen case.5.
server.cors()— typechecker only, no codegen handleremit_server_call): No case for"cors"— falls through and produces broken CImpact: Typechecker accepts
server.cors()but codegen has no handler.Fix: Implement
ez_server_cors()in the C layer and wire the codegen case.6.
server.use()— typechecker only, no codegen handleremit_server_call): No case for"use"— falls through and produces broken CImpact: Typechecker accepts
server.use()but codegen has no handler.Fix: Implement
ez_server_use()in the C layer and wire the codegen case.7.
sync.try_lock()— missing entirelyez_sync.h): Notry_lockdeclarationez_sync.c): Notry_lockfunctionsync.try_lock()as an existing functionImpact: Standard says it exists but it was never built. Users reading the docs will try to use it and get an error.
Fix: Implement
sync.try_lock()end-to-end across all 4 layers. Should wrappthread_mutex_trylock()and return abool.Bug Class
All 7 fall into the same pattern: the compiler pipeline is incomplete for these functions. Items 2-6 are the most dangerous — the typechecker accepts the call, so the user thinks it's valid, but codegen produces broken C. Items 1 and 7 are less dangerous since the typechecker rejects them, but the standard/codegen entries create confusion.