summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-06-02 01:02:56 +0800
committerGitHub <noreply@github.com>2023-06-01 19:02:56 +0200
commit8e35b3d577cb0a6b216b16668ff5f34a86cfbbab (patch)
tree44ad31ebd03e66217a9c8d63ba0542ee7588f296
parentb3e1892eb7f4cb8b2090be7ad12286cc54506e91 (diff)
downloadNim-8e35b3d577cb0a6b216b16668ff5f34a86cfbbab.tar.gz
fixes #21974; fixes sameConstant fieldDefect (#21981)
* fixes #21974; fixes sameConstant fieldDefect

* add a test case
-rw-r--r--compiler/injectdestructors.nim2
-rw-r--r--tests/arc/tarc_orc.nim30
2 files changed, 31 insertions, 1 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim
index 56ca8f605..3275c1abc 100644
--- a/compiler/injectdestructors.nim
+++ b/compiler/injectdestructors.nim
@@ -1016,7 +1016,7 @@ proc p(n: PNode; c: var Con; s: var Scope; mode: ProcessMode; tmpFlags = {sfSing
 
 proc sameLocation*(a, b: PNode): bool =
   proc sameConstant(a, b: PNode): bool =
-    a.kind in nkLiterals and a.intVal == b.intVal
+    a.kind in nkLiterals and b.kind in nkLiterals and a.intVal == b.intVal
 
   const nkEndPoint = {nkSym, nkDotExpr, nkCheckedFieldExpr, nkBracketExpr}
   if a.kind in nkEndPoint and b.kind in nkEndPoint:
diff --git a/tests/arc/tarc_orc.nim b/tests/arc/tarc_orc.nim
index 2fbb2e792..387baa28f 100644
--- a/tests/arc/tarc_orc.nim
+++ b/tests/arc/tarc_orc.nim
@@ -59,3 +59,33 @@ proc bug(): seq[Obj] =
 # bug #19990
 let s = bug()
 doAssert s[0] == (value: 1, arr: @[1])
+
+block: # bug #21974
+  type Test[T] = ref object
+      values : seq[T]
+      counter: int
+
+  proc newTest[T](): Test[T] =
+      result         = new(Test[T])
+      result.values  = newSeq[T](16)
+      result.counter = 0
+
+  proc push[T](self: Test[T], value: T) =
+      self.counter += 1
+      if self.counter >= self.values.len:
+          self.values.setLen(self.values.len * 2)
+      self.values[self.counter - 1] = value
+
+  proc pop[T](self: Test[T]): T =
+      result         = self.values[0]
+      self.values[0] = self.values[self.counter - 1] # <--- This line
+      self.counter  -= 1
+
+
+  type X = tuple
+      priority: int
+      value   : string
+
+  var a = newTest[X]()
+  a.push((1, "One"))
+  doAssert a.pop.value == "One"
lt;garbeam@gmail.com> 2007-09-23 11:24:12 +0200 renamed config.h into config.def.h, config.h will be created if not present, this seems less annoying after all' href='/acidbong/suckless/dwm/commit/Makefile?h=6.4&id=17d39ee01458025a5b9f5087168f258933f0ccd9'>17d39ee ^
e94774d ^

17d39ee ^
650a1fb ^
3d48f33 ^

1076f2b

4d55eee ^
db876f9 ^
dbf7e03 ^

4d55eee ^

d477fb6 ^
f806a17 ^
4d55eee ^


dbf7e03 ^

4d55eee ^
dbf7e03 ^
4d55eee ^


dbf7e03 ^
ad4962c ^
4d55eee ^
dbf7e03 ^

4d55eee ^



dc5c070 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60