| author | |
| committer | |
| log | 91eb1af9177d774158d888484023e3bf0be65412 |
| tree | 8aafa2cc145b16cfaf854980e58bbca0aff8f29f |
| parent | 3432e66faf8940bbbfc7ee24d0e17e6127e66bf6 |
* 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.2 files changed, 19 insertions(+), 3 deletions(-)
src/Module.zig+12-2| ... | ... | @@ -4854,7 +4854,12 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem |
| 4854 | 4854 | error.GenericPoison => unreachable, |
| 4855 | 4855 | error.ComptimeReturn => unreachable, |
| 4856 | 4856 | error.ComptimeBreak => unreachable, |
| 4857 | error.AnalysisFail => {}, | |
| 4857 | error.AnalysisFail => { | |
| 4858 | // In this case our function depends on a type that had a compile error. | |
| 4859 | // We should not try to lower this function. | |
| 4860 | decl.analysis = .dependency_failure; | |
| 4861 | return error.AnalysisFail; | |
| 4862 | }, | |
| 4858 | 4863 | else => |e| return e, |
| 4859 | 4864 | }; |
| 4860 | 4865 | |
| ... | ... | @@ -4867,7 +4872,12 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem |
| 4867 | 4872 | error.GenericPoison => unreachable, |
| 4868 | 4873 | error.ComptimeReturn => unreachable, |
| 4869 | 4874 | error.ComptimeBreak => unreachable, |
| 4870 | error.AnalysisFail => {}, | |
| 4875 | error.AnalysisFail => { | |
| 4876 | // In this case our function depends on a type that had a compile error. | |
| 4877 | // We should not try to lower this function. | |
| 4878 | decl.analysis = .dependency_failure; | |
| 4879 | return error.AnalysisFail; | |
| 4880 | }, | |
| 4871 | 4881 | else => |e| return e, |
| 4872 | 4882 | }; |
| 4873 | 4883 | } |
src/Sema.zig+7-1| ... | ... | @@ -1639,7 +1639,13 @@ fn failWithOwnedErrorMsg(sema: *Sema, block: *Block, err_msg: *Module.ErrorMsg) |
| 1639 | 1639 | sema.owner_decl.analysis = .sema_failure; |
| 1640 | 1640 | sema.owner_decl.generation = mod.generation; |
| 1641 | 1641 | } |
| 1642 | mod.failed_decls.putAssumeCapacityNoClobber(sema.owner_decl, err_msg); | |
| 1642 | const gop = mod.failed_decls.getOrPutAssumeCapacity(sema.owner_decl); | |
| 1643 | if (gop.found_existing) { | |
| 1644 | // If there are multiple errors for the same Decl, prefer the first one added. | |
| 1645 | err_msg.destroy(mod.gpa); | |
| 1646 | } else { | |
| 1647 | gop.value_ptr.* = err_msg; | |
| 1648 | } | |
| 1643 | 1649 | return error.AnalysisFail; |
| 1644 | 1650 | } |
| 1645 | 1651 |