fix(gnovm): handle blank range key/value per-operand, validate assignment targets#5764
fix(gnovm): handle blank range key/value per-operand, validate assignment targets#5764ltzmaxwell wants to merge 43 commits into
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| @@ -0,0 +1,11 @@ | |||
| package main | |||
|
|
|||
| // Regression: `for _ = range slice` used to panic on nil key in assertIndexTypeIsInt. | |||
There was a problem hiding this comment.
This also fix
package main
func main() {
a := []int{1, 2, 3}
var v int
for _, v = range a {
}
_ = v
println("ok")
}
// Output:
// okRef: #5751 (comment) (+ verified personally)
…atten string check
…compound-assign and inc/dec targets)
…targets at callers
|
@davd-gzl requesting a fresh review: your approval was at |
Follow-up to #5751 — main target: blank range key/value handled per-operand. Along the way it generalizes target/RHS validation to every assigning statement (absorbs #5804) and fixes adjacent issues found while unifying the pattern.
RangeStmt.AssertCompatiblechecks each operand independently via the newevalAssignLhsTypehelper (validity asked of every operand; type check skipped for blank), fixing thefor _, v = range slicepanic and the string-branch message printingktforvt.checkAssignableTo/assertIndexTypeIsIntpanic on nil destination type — nil aliases an untyped-nil lvalue (for k, nil = range m) with blank, so a missing blank-skip now fails loudly in CI instead of silently skipping the check.for _, c = range awith const,c += 1/s[0] += 1silently discarding writes,c++runtime panic —IncDecStmt.AssertCompatiblenow takes(store, last)like its peers);_ = nilrejected (T(nil)stays legal); compound assigns get blank-target (_ += 1) and RHS validity (i += int,i += f()) checks; range/index,okchecks resolvebaseOfand use assignability instead of kind, fixing silent type confusion with declared map types and named int/rune operands — all with go/types-matching messages and error precedence.types/range_blank_key2–5,assign_range_f–k,assign_index_d/e,assign_op_a–g(c–g also pin the check ORDER: each program has two errors and the golden records which fires first),incdec_a5,assign_nil3; nil-dt panic pinned inTestCheckAssignableTo.