warn when generator function without any yield expression (#13847)#19413
Closed
Kingwl wants to merge 1 commit into
Closed
warn when generator function without any yield expression (#13847)#19413Kingwl wants to merge 1 commit into
Kingwl wants to merge 1 commit into
Conversation
5a8a59c to
a024434
Compare
mhegazy
suggested changes
Oct 30, 2017
|
|
||
| function checkGeneratorWithReturnStatementMustHaveYield (func: FunctionLikeDeclaration) { | ||
| let hasReturnStmt = false; | ||
| forEachReturnStatement(<Block>func.body, _ => hasReturnStmt = true); |
Contributor
There was a problem hiding this comment.
seems weird that we have to do this walk again. we have already walked the yield statements to get the types a bit earlier. we can just report the error there instead.
| "category": "Error", | ||
| "code": 1329 | ||
| }, | ||
| "generator with 'return statement' must not have zero 'yield return' statements.": { |
Contributor
There was a problem hiding this comment.
A generator cannot have a return statement and no yield statements.
Contributor
|
In light of the recent discussion about warnings vs. errors, i want to revisit our decision to accept this proposal in the first place. |
a024434 to
e4576ed
Compare
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13847