From 91eb1af9177d774158d888484023e3bf0be65412 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 2 Apr 2022 19:12:08 -0700 Subject: stage2: more resilient error handling * If more than one error is reported for the same Decl, the first error message is kept and the second one discarded. * Prevent functions from being sent to codegen backends if there were any errors resolving any of their parameter types or return type. --- src/Module.zig | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 154c7426d2..fdf61c4bf6 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4854,7 +4854,12 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem error.GenericPoison => unreachable, error.ComptimeReturn => unreachable, error.ComptimeBreak => unreachable, - error.AnalysisFail => {}, + error.AnalysisFail => { + // In this case our function depends on a type that had a compile error. + // We should not try to lower this function. + decl.analysis = .dependency_failure; + return error.AnalysisFail; + }, else => |e| return e, }; @@ -4867,7 +4872,12 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem error.GenericPoison => unreachable, error.ComptimeReturn => unreachable, error.ComptimeBreak => unreachable, - error.AnalysisFail => {}, + error.AnalysisFail => { + // In this case our function depends on a type that had a compile error. + // We should not try to lower this function. + decl.analysis = .dependency_failure; + return error.AnalysisFail; + }, else => |e| return e, }; } -- cgit v1.2.3