aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJaden Weiss <[email protected]>2020-04-01 18:57:58 -0400
committerAyke <[email protected]>2020-04-02 14:04:25 +0200
commit6647c43a7b82957401b112ebb4f53ac9dda0f8fa (patch)
tree9e1c6c08665111c7b52981246d52dde211662be8
parent6e86daa95e2b0279d31c142b88c0e99e95cff6c0 (diff)
downloadtinygo-6647c43a7b82957401b112ebb4f53ac9dda0f8fa.tar.gz
tinygo-6647c43a7b82957401b112ebb4f53ac9dda0f8fa.zip
compiler: track the result of string concatenation
Before this commit, the garbage collector was able to collect string values while they were still in use.
-rw-r--r--compiler/gc.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/gc.go b/compiler/gc.go
index ceb071bf7..6aa0b45a9 100644
--- a/compiler/gc.go
+++ b/compiler/gc.go
@@ -41,6 +41,12 @@ func (b *builder) trackExpr(expr ssa.Value, value llvm.Value) {
// pointer in there (if there is one).
b.trackValue(value)
}
+ case *ssa.BinOp:
+ switch expr.Op {
+ case token.ADD:
+ // String concatenation.
+ b.trackValue(value)
+ }
}
}