cl: support var define#559
Merged
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #559 +/- ##
==========================================
+ Coverage 90.18% 90.32% +0.14%
==========================================
Files 41 41
Lines 10461 10546 +85
==========================================
+ Hits 9434 9526 +92
+ Misses 737 732 -5
+ Partials 290 288 -2
Continue to review full report at Codecov.
|
Member
|
please fix the conflicts. |
xushiwei
reviewed
Aug 24, 2020
| return isNoExecCtxCallExpr(ctx, v.Call) | ||
| case *ast.GoStmt: | ||
| return isNoExecCtxCallExpr(ctx, v.Call) | ||
| case *ast.DeclStmt: |
Member
There was a problem hiding this comment.
If ast.DeclStmt is not a global declaration but a normal statement in a function, it should be same as ast.AssignStmt (isNoExecCtxAssignStmt).
a := 1 // is same as:
var a = 1
Member
Author
There was a problem hiding this comment.
关于 isNoExecCtxExpr ,因为是 isNoExecCtxXXX 函数都是循环调用。
发现只有在调用链中出现 ast.FuncLit 时才会返回 false 。
func isNoExecCtxFuncLit(ctx *blockCtx, v *ast.FuncLit) bool {
// TODO: log.Warn("isNoExecCtxFuncLit: to be optimized")
return false
}
下面的测试可以通过
isNoExecCtxDeclStmt
fns := make([]func() int, 3)
for i, x <- [3, 15, 777] {
var v = x
var fn = func() int {
return v
}
fns[i] = fn
}
println("values:", fns[0](), fns[1](), fns[2]())
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
cl: support var define
Go+ code
generate Golang code error