summaryrefslogtreecommitdiff
path: root/mk2rbc/variable.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2021-12-22 14:08:08 -0800
committer Cole Faust <colefaust@google.com> 2021-12-22 14:08:08 -0800
commit0484c2378f5f016d9d5b11fe81a8790352c7753e (patch)
treeb25549bd310d1a51a1809f46c886309a048f0d7a /mk2rbc/variable.go
parent68542bfcb5674a0e2661407c03563f6a90a9243c (diff)
Fix "unknown binary op: string + list" errors
Convert lists to strings when adding them to a string. Bug: 201700692 Test: go test Change-Id: Iefb68f48191136e7115a6d6bfa0608c73d5afdac
Diffstat (limited to 'mk2rbc/variable.go')
-rw-r--r--mk2rbc/variable.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/mk2rbc/variable.go b/mk2rbc/variable.go
index 6b67a7cb9..f7adca568 100644
--- a/mk2rbc/variable.go
+++ b/mk2rbc/variable.go
@@ -81,10 +81,12 @@ func (pcv productConfigVariable) emitSet(gctx *generationContext, asgn *assignme
emitAppend := func() {
pcv.emitGet(gctx, true)
gctx.write(" += ")
+ value := asgn.value
if pcv.valueType() == starlarkTypeString {
gctx.writef(`" " + `)
+ value = &toStringExpr{expr: value}
}
- asgn.value.emit(gctx)
+ value.emit(gctx)
}
switch asgn.flavor {
@@ -136,10 +138,12 @@ func (scv otherGlobalVariable) emitSet(gctx *generationContext, asgn *assignment
emitAppend := func() {
scv.emitGet(gctx, true)
gctx.write(" += ")
+ value := asgn.value
if scv.valueType() == starlarkTypeString {
gctx.writef(`" " + `)
+ value = &toStringExpr{expr: value}
}
- asgn.value.emit(gctx)
+ value.emit(gctx)
}
switch asgn.flavor {
@@ -193,10 +197,12 @@ func (lv localVariable) emitSet(gctx *generationContext, asgn *assignmentNode) {
case asgnAppend:
lv.emitGet(gctx, false)
gctx.write(" += ")
+ value := asgn.value
if lv.valueType() == starlarkTypeString {
gctx.writef(`" " + `)
+ value = &toStringExpr{expr: value}
}
- asgn.value.emit(gctx)
+ value.emit(gctx)
case asgnMaybeAppend:
gctx.writef("%s(%q, ", cfnLocalAppend, lv)
asgn.value.emit(gctx)