-
Notifications
You must be signed in to change notification settings - Fork 35
Func.End: support AutoLambdaCond/Loop #643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1022,6 +1022,21 @@ func buildTypeForCallExpr(pkg *Package, T types.Type) ast.Expr { | |
| } | ||
| } | ||
|
|
||
| func return0IfNeeded(stmts []ast.Stmt) []ast.Stmt { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] return0IfNeeded hardcodes
The tests ( |
||
| var hasReturn bool | ||
| if len(stmts) > 0 { | ||
| _, hasReturn = stmts[len(stmts)-1].(*ast.ReturnStmt) | ||
| } | ||
| if !hasReturn { | ||
| stmts = append(stmts, &ast.ReturnStmt{ | ||
| Results: []ast.Expr{ | ||
| &ast.BasicLit{Kind: token.INT, Value: "0"}, | ||
| }, | ||
| }) | ||
| } | ||
| return stmts | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| func newIncDecStmt(x ast.Expr, tok token.Token) *ast.IncDecStmt { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3]
Fordoc comment ordering reads reversedThe new comment
// For loop statement: For (..|None) Then [.. Post] .. Endgroups[.. Post]as the optional element with the bare body..after it, which reads as "optional post-section, then body" — the reverse of the actual builder order.TestForand thestmt.gogrammar block show:For→ init/cond (orNone) →Then→ body → optional (Post→ post-stmt) →End. Suggest e.g.For (..|None) Then .. [Post ..] End.