diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index 94bf009..3cbb0cf 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -887,6 +887,7 @@ sw buf_inspect_integer_size (const s_integer *x)
sw buf_inspect_list (s_buf *buf, const s_list *x)
{
+ uw count = 0;
const s_list *i;
sw r;
sw result = 0;
@@ -899,6 +900,7 @@ sw buf_inspect_list (s_buf *buf, const s_list *x)
if ((r = buf_inspect_tag(buf, &i->tag)) < 0)
return r;
result += r;
+ count++;
switch (i->next.type) {
case TAG_LIST:
if (i->next.data.list) {
@@ -907,6 +909,11 @@ sw buf_inspect_list (s_buf *buf, const s_list *x)
result += r;
}
i = i->next.data.list;
+ if (! i && count == 1) {
+ if ((r = buf_write_1(buf, " | ()")) < 0)
+ return r;
+ result += r;
+ }
continue;
default:
if ((r = buf_write_1(buf, " | ")) < 0)
@@ -926,6 +933,7 @@ sw buf_inspect_list (s_buf *buf, const s_list *x)
sw buf_inspect_list_size (const s_list *list)
{
+ uw count = 0;
const s_list *i;
sw r;
sw result = 0;
@@ -935,11 +943,14 @@ sw buf_inspect_list_size (const s_list *list)
if ((r = buf_inspect_tag_size(&i->tag)) < 0)
return r;
result += r;
+ count++;
switch (i->next.type) {
case TAG_LIST:
if (i->next.data.list)
result += strlen(", ");
i = i->next.data.list;
+ if (! i && count == 1)
+ result += strlen(" | ()");
continue;
default:
result += strlen(" | ");
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 29ee7f2..5816481 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -1342,6 +1342,7 @@ sw buf_parse_ident (s_buf *buf, s_ident *dest)
goto restore;
result += r;
str_to_ident(&str, dest);
+ dest->module_name = module_name;
str_clean(&str);
r = result;
goto clean;
@@ -2203,7 +2204,8 @@ sw buf_parse_tag_primary (s_buf *buf, s_tag *dest)
goto restore;
result += r;
}
- if ((r = buf_parse_tag_call_paren(buf, dest)) != 0 ||
+ if ((r = buf_parse_tag_array(buf, dest)) != 0 ||
+ (r = buf_parse_tag_call_paren(buf, dest)) != 0 ||
(r = buf_parse_tag_call_op_unary(buf, dest)) != 0 ||
(r = buf_parse_tag_bool(buf, dest)) != 0 ||
(r = buf_parse_tag_character(buf, dest)) != 0)
@@ -2212,15 +2214,14 @@ sw buf_parse_tag_primary (s_buf *buf, s_tag *dest)
tag_integer_reduce(dest);
goto end;
}
- if ((r = buf_parse_tag_array(buf, dest)) != 0 ||
- (r = buf_parse_tag_list(buf, dest)) != 0 ||
- (r = buf_parse_tag_str(buf, dest)) != 0 ||
+ if ((r = buf_parse_tag_str(buf, dest)) != 0 ||
(r = buf_parse_tag_tuple(buf, dest)) != 0 ||
(r = buf_parse_tag_quote(buf, dest)) != 0 ||
(r = buf_parse_tag_cfn(buf, dest)) != 0 ||
(r = buf_parse_tag_fn(buf, dest)) != 0 ||
- (r = buf_parse_tag_call(buf, dest)) != 0 ||
(r = buf_parse_tag_ident(buf, dest)) != 0 ||
+ (r = buf_parse_tag_list(buf, dest)) != 0 ||
+ (r = buf_parse_tag_call(buf, dest)) != 0 ||
(r = buf_parse_tag_sym(buf, dest)) != 0)
goto end;
goto restore;
diff --git a/test/buf_inspect_test.c b/test/buf_inspect_test.c
index 9b4a734..f6e254a 100644
--- a/test/buf_inspect_test.c
+++ b/test/buf_inspect_test.c
@@ -389,8 +389,7 @@ TEST_CASE(buf_inspect_tag)
BUF_INSPECT_TEST_TAG(tag_integer_1(&tag, "-0x10000000000000000"), "-18446744073709551616");
BUF_INSPECT_TEST_TAG(tag_integer_1(&tag, "0x10000000000000000"), "18446744073709551616");
BUF_INSPECT_TEST_TAG(tag_list(&tag, NULL), "()");
- BUF_INSPECT_TEST_TAG(tag_list_1(&tag, "(() | ())"), "(())");
- BUF_INSPECT_TEST_TAG(tag_list_1(&tag, "(())"), "(())");
+ BUF_INSPECT_TEST_TAG(tag_list_1(&tag, "(() | ())"), "(() | ())");
BUF_INSPECT_TEST_TAG(tag_list_1(&tag, "()"), "()");
BUF_INSPECT_TEST_TAG(tag_s16(&tag, -0x100), "-256");
BUF_INSPECT_TEST_TAG(tag_s32(&tag, -0x10000), "-65536");
diff --git a/test/ic3/list.in b/test/ic3/list.in
index 06076de..9ffd0cc 100644
--- a/test/ic3/list.in
+++ b/test/ic3/list.in
@@ -12,7 +12,7 @@
(() | ((), (), () | ()))
(((), ()) | ((), ()))
((() | ()) | (() | ()))
-(a)
+(a | ())
(a, b)
(a, b, c)
(a | b)
diff --git a/test/ic3/list.out.expected b/test/ic3/list.out.expected
index c512c93..91ffee3 100644
--- a/test/ic3/list.out.expected
+++ b/test/ic3/list.out.expected
@@ -1,5 +1,5 @@
()
-(())
+(() | ())
((), ())
((), (), ())
((), (), (), ())
@@ -11,8 +11,8 @@
((), (), ())
((), (), (), ())
(((), ()), (), ())
-((()), ())
-(a)
+((() | ()), ())
+(a | ())
(a, b)
(a, b, c)
(a | b)
diff --git a/test/list_test.c b/test/list_test.c
index afbc3e1..5875993 100644
--- a/test/list_test.c
+++ b/test/list_test.c
@@ -67,7 +67,7 @@ TEST_CASE_END(list_1)
TEST_CASE(list_inspect)
{
LIST_TEST_INSPECT("()", "()");
- LIST_TEST_INSPECT("(() | ())", "(())");
+ LIST_TEST_INSPECT("(() | ())", "(() | ())");
LIST_TEST_INSPECT("((), () | ())", "((), ())");
}
TEST_CASE_END(list_inspect)