Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
Use baseValue from source in binOp to make gc working
Browse files Browse the repository at this point in the history
Fixes #184

`binSrc(src.Pos(), op, x, other)` will hold reference to `left` and `right` variables which will prevent them from gc.

Closes #188
#188

GitOrigin-RevId: e9af654
Change-Id: I740c0847fe4c7446ec5c0823aca1ede10bf1dd21
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4181
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
adieu authored and mpvl committed Nov 30, 2019
1 parent 6f9c049 commit 8a043dc
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cue/binop.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,14 +625,20 @@ func (x *structLit) binOp(ctx *context, src source, op op, other evaluated) eval
return x
}
arcs := make(arcs, 0, len(x.arcs)+len(y.arcs))
var base baseValue
if src.computed() != nil {
base = baseValue{src.computed()}
} else {
base = binSrc(src.Pos(), op, x, other)
}
obj := &structLit{
binSrc(src.Pos(), op, x, other), // baseValue
x.emit, // emit
nil, // template
x.closeStatus | y.closeStatus, // closeStatus
nil, // comprehensions
arcs, // arcs
nil, // attributes
base, // baseValue
x.emit, // emit
nil, // template
x.closeStatus | y.closeStatus, // closeStatus
nil, // comprehensions
arcs, // arcs
nil, // attributes
}
defer ctx.pushForwards(x, obj, y, obj).popForwards()

Expand Down

0 comments on commit 8a043dc

Please sign in to comment.