diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-09 18:17:57 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-09 18:17:57 -0400 |
| commit | 7fbba1b7901fcd9b9363132b99ada636cddbfad9 (patch) | |
| tree | 8b9316a7a3db5469a113e6ac32ecb8952bf036ef | |
| parent | 46f9cebad12cc5f12a966c61b61ab4856e293475 (diff) | |
Check for main func return values (and error if it has any)
| -rw-r--r-- | tomo.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -562,6 +562,10 @@ void transpile_code(env_t *base_env, Text_t filename, bool force_retranspile) binding_t *main_binding = get_binding(module_env, "main"); if (main_binding && main_binding->type->tag == FunctionType) { + type_t *ret = Match(main_binding->type, FunctionType)->ret; + if (ret->tag != VoidType && ret->tag != AbortType) + compiler_err(ast->file, ast->start, ast->end, "The main() function in this file has a return type of %T, but it should not have any return value!", ret); + CORD_put(CORD_all( "int ", main_binding->code, "$parse_and_run(int argc, char *argv[]) {\n" "#line 1\n" |
