Commit 9a7a5fe3b577c2f6bf18f472e614ee4e608d4b02

Thomas de Grivel 2023-10-01T19:50:23

fixed (List) arrays

diff --git a/libc3/array.c b/libc3/array.c
index 155bc10..d2921d2 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -486,6 +486,8 @@ f_copy array_type_to_copy (const s_sym *type)
     return (f_copy) ident_copy;
   if (type == sym_1("Integer"))
     return (f_copy) integer_copy;
+  if (type == sym_1("List"))
+    return (f_copy) list_copy;
   if (type == sym_1("Sw"))
     return (f_copy) sw_copy;
   if (type == sym_1("S64"))
@@ -506,8 +508,6 @@ f_copy array_type_to_copy (const s_sym *type)
     return (f_copy) u64_copy;
   if (type == sym_1("Uw"))
     return (f_copy) uw_copy;
-  if (type == sym_1("List"))
-    return (f_copy) list_copy;
   if (type == sym_1("Ptag"))
     return (f_copy) ptag_copy;
   if (type == sym_1("Quote"))
diff --git a/libc3/list.c b/libc3/list.c
index eb79024..e98b2c9 100644
--- a/libc3/list.c
+++ b/libc3/list.c
@@ -65,6 +65,7 @@ s_list ** list_cast (const s_tag *tag, s_list **list)
 s_list ** list_copy (const s_list **src, s_list **dest)
 {
   s_list **i;
+  s_list *next;
   const s_list *s;
   assert(src);
   assert(dest);
@@ -74,7 +75,8 @@ s_list ** list_copy (const s_list **src, s_list **dest)
   while (s) {
     *i = list_new(NULL, NULL);
     tag_copy(&s->tag, &(*i)->tag);
-    if ((s = list_next(s))) {
+    if ((next = list_next(s))) {
+      s = next;
       i = &(*i)->next.data.list;
     }
     else {
diff --git a/libc3/tag.c b/libc3/tag.c
index 27fa1f5..9a8065a 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -3851,9 +3851,9 @@ void * tag_to_pointer (s_tag *tag, e_tag_type type)
   case TAG_UW:
     return &tag->data.uw;
   case TAG_LIST:
-    return tag->data.list;
+    return &tag->data.list;
   case TAG_PTAG:
-    return (void *) tag->data.ptag;
+    return &tag->data.ptag;
   case TAG_QUOTE:
     return &tag->data.quote;
   case TAG_STR:
diff --git a/test/ic3/array.in b/test/ic3/array.in
index 1771f72..31a73eb 100644
--- a/test/ic3/array.in
+++ b/test/ic3/array.in
@@ -107,8 +107,8 @@ l = (Integer) { 1000000000000000000000000000000001,
                 2000000000000000000000000000000002 }
 l[0]
 l[1]
-quote (List) { (1, 2), (3, 4) }
-(List) { (1, 2), (3, 4) }
-m = (List) { (1, 2), (3, 4) }
+quote (List) {(1, 2), (3, 4)}
+(List) {(1, 2), (3, 4)}
+m = (List) {(1, 2), (3, 4)}
 m[0]
 m[1]
diff --git a/test/ic3/array.out.expected b/test/ic3/array.out.expected
index 068e559..a510d31 100644
--- a/test/ic3/array.out.expected
+++ b/test/ic3/array.out.expected
@@ -93,3 +93,8 @@ d[1][1][1][1]
 (Integer) {1000000000000000000000000000000001, 2000000000000000000000000000000002}
 1000000000000000000000000000000001
 2000000000000000000000000000000002
+(List) {(1, 2), (3, 4)}
+(List) {(1, 2), (3, 4)}
+(List) {(1, 2), (3, 4)}
+(1, 2)
+(3, 4)