From 6647c43a7b82957401b112ebb4f53ac9dda0f8fa Mon Sep 17 00:00:00 2001 From: Jaden Weiss Date: Wed, 1 Apr 2020 18:57:58 -0400 Subject: [PATCH] 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. --- compiler/gc.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/gc.go b/compiler/gc.go index ceb071bf..6aa0b45a 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) + } } }