summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-09-28 10:59:16 +0200
committerGitHub <noreply@github.com>2018-09-28 10:59:16 +0200
commit99a874cc8af70db58da0f3e5e00c318488c6c3ea (patch)
tree0ade0e6c8182731d44d16ac834fe38dc3fab6ca7
parent07748dba68a2edba4163e8dfbdf7b09251e8cc30 (diff)
parenta1083d7c43e34fddd9097f7d0122db08092a13ac (diff)
downloadNim-99a874cc8af70db58da0f3e5e00c318488c6c3ea.tar.gz
Merge pull request #9099 from LemonBoy/fix-9098
Fix codegen for some set operations
-rw-r--r--compiler/ccgexprs.nim2
-rw-r--r--tests/ccgbugs/t9098.nim12
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index a1365ce07..1789ce4f1 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1732,7 +1732,7 @@ proc genSetOp(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
       getTemp(p, getSysType(p.module.g.graph, unknownLineInfo(), tyInt), i) # our counter
       initLocExpr(p, e.sons[1], a)
       initLocExpr(p, e.sons[2], b)
-      if d.k == locNone: getTemp(p, a.t, d)
+      if d.k == locNone: getTemp(p, setType, d)
       lineF(p, cpsStmts,
            "for ($1 = 0; $1 < $2; $1++) $n" &
            "  $3[$1] = $4[$1] $6 $5[$1];$n", [
diff --git a/tests/ccgbugs/t9098.nim b/tests/ccgbugs/t9098.nim
new file mode 100644
index 000000000..e1dbb6883
--- /dev/null
+++ b/tests/ccgbugs/t9098.nim
@@ -0,0 +1,12 @@
+discard """
+  targets: "c cpp js"
+  output: '''
+{'a', 'b'}
+'''
+"""
+
+var x = new(ref set[char])
+var y = new(ref set[char])
+x[] = {'a'}
+y[] = {'b'}
+echo x[] + y[]