-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: confusing error message when returning value from void functions (…
…#3098) Checks whether the return statement is within a context of a void function and provides a clearer message. Fixes #1550 ## Checklist - [X] Title matches [Winglang's style guide](https://docs.winglang.io/contributing/pull_requests#how-are-pull-request-titles-formatted) - [X] Description explains motivation and solution - [X] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*.
- Loading branch information
eladcon
authored
Jun 28, 2023
1 parent
6976e6f
commit 014dd96
Showing
6 changed files
with
129 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
return 9; | ||
// ^^^^^^^^^ Return statement outside of function cannot return a value | ||
if true { | ||
return 9; | ||
// ^^^^^^^^^ Return statement outside of function cannot return a value | ||
} | ||
|
||
inflight (): void => { | ||
return 9; | ||
//^^^^^^^^^ Unexpected return value from void function | ||
if true { | ||
return 9; | ||
// ^^^^^^^^^ Unexpected return value from void function | ||
} | ||
}; | ||
|
||
class C { | ||
func() { | ||
return 9; | ||
// ^^^^^^^^^ Unexpected return value from void function | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.