-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sem): errors in lambdas no longer crash
Summary --------- Errors in lambdas requiring inference (`proc(e: auto) echo e`), no longer crash the compiler. Instead errors within the lambda body are reported and lambda inference fails as it should. Details ------- `semInferredLambda` failed to wrap its output when there were errors. This would reach `transf` and result in a compiler crash by hitting an `unreachable` assertion. Now errors in the body are reported immediately (to provide context for inference failure) and AST output from the inference attempt is correctly wrapped such that inference appropriately fails.
- Loading branch information
Showing
2 changed files
with
39 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/lang_callable/generics/tauto_inference_failure_due_to_body_error.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
discard """ | ||
description: "Fail lambda inference due to error without the body." | ||
errormsg: "undeclared identifier: 'i'" | ||
line: 11 | ||
""" | ||
|
||
# This is a regression test, ensure we report errors inside lambdas during | ||
# inference | ||
|
||
var x: seq[proc(i: int)] | ||
x.add proc(e: auto) = echo i |