| author | |
| committer | |
| log | 886fa455fad4997cf766ec2adcbac09d7e28f668 |
| tree | 08703f05c86c640fe4ed5bfa8be24a9036fd9eeb |
| parent | e6588857dfb7a4528e698604d31cc2a5e26c0fb8 |
5 files changed, 23 insertions(+), 17 deletions(-)
src/Sema.zig+4| ... | ... | @@ -2257,6 +2257,9 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError { |
| 2257 | 2257 | sema.owner_decl.analysis = .sema_failure; |
| 2258 | 2258 | sema.owner_decl.generation = mod.generation; |
| 2259 | 2259 | } |
| 2260 | if (sema.func) |func| { | |
| 2261 | func.state = .sema_failure; | |
| 2262 | } | |
| 2260 | 2263 | const gop = mod.failed_decls.getOrPutAssumeCapacity(sema.owner_decl_index); |
| 2261 | 2264 | if (gop.found_existing) { |
| 2262 | 2265 | // If there are multiple errors for the same Decl, prefer the first one added. |
| ... | ... | @@ -6385,6 +6388,7 @@ fn analyzeCall( |
| 6385 | 6388 | }), |
| 6386 | 6389 | else => unreachable, |
| 6387 | 6390 | }; |
| 6391 | if (!is_comptime_call and module_fn.state == .sema_failure) return error.AnalysisFail; | |
| 6388 | 6392 | |
| 6389 | 6393 | // Analyze the ZIR. The same ZIR gets analyzed into a runtime function |
| 6390 | 6394 | // or an inlined call depending on what union tag the `label` field is |
test/cases/compile_errors/missing_main_fn_in_executable.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | ||
| 2 | ||
| 3 | // error | |
| 4 | // backend=llvm | |
| 5 | // target=x86_64-linux | |
| 6 | // output_mode=Exe | |
| 7 | // | |
| 8 | // :?:?: error: root struct of file 'tmp' has no member named 'main' | |
| 9 | // :?:?: note: called from here |
test/cases/compile_errors/private_main_fn.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | fn main() void {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=llvm | |
| 5 | // target=x86_64-linux | |
| 6 | // output_mode=Exe | |
| 7 | // | |
| 8 | // :?:?: error: 'main' is not marked 'pub' | |
| 9 | // :1:1: note: declared here | |
| 10 | // :?:?: note: called from here |
test/cases/compile_errors/stage1/exe/missing_main_fn_in_executable.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | ||
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // output_mode=Exe | |
| 7 | // | |
| 8 | // error: root source file has no member called 'main' |
test/cases/compile_errors/stage1/exe/private_main_fn.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | fn main() void {} | |
| 2 | ||
| 3 | // error | |
| 4 | // backend=stage1 | |
| 5 | // target=native | |
| 6 | // output_mode=Exe | |
| 7 | // | |
| 8 | // error: 'main' is private | |
| 9 | // tmp.zig:1:1: note: declared here |