compile: Superstring compilation bug
authorJean Privat <jean@pryen.org>
Tue, 9 Jun 2009 19:23:17 +0000 (15:23 -0400)
committerJean Privat <jean@pryen.org>
Wed, 10 Jun 2009 14:04:55 +0000 (10:04 -0400)
Before:
  var a = 5
  var b = "{a}"
  print(a == b) # => true, a was overwrite

Signed-off-by: Jean Privat <jean@pryen.org>

src/compiling/compiling_methods.nit

index c823b83..3e20f95 100644 (file)
@@ -1323,8 +1323,10 @@ redef class ASuperstringExpr
                for ne in n_exprs do
                        var e = v.ensure_var(v.compile_expr(ne), "super-string element")
                        if ne.stype != stype then
-                               v.add_assignment(e, meth_to_s.compile_call(v, [e]))
+                               v.cfc.free_var(e)
+                               e = meth_to_s.compile_call(v, [e])
                        end
+                       v.cfc.free_var(e)
                        meth_add.compile_call(v, [array, e])
                end