Commit 15c75c1eecd50a43979574cb3b1f4aeb7aec0697

Thomas de Grivel 2023-10-21T14:00:36

wip operators

diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index d208fc4..72509dd 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -245,7 +245,8 @@ sw buf_inspect_call (s_buf *buf, const s_call *call)
   s8 op_precedence;
   sw r;
   sw result = 0;
-  if (call->ident.sym == sym_1("[]"))
+  if (operator_find(&call->ident) &&
+      operator_symbol(&call->ident) == sym_1("[]"))
     return buf_inspect_call_brackets(buf, call);
   if (call->ident.sym == sym_1("cast"))
     return buf_inspect_cast(buf, call);
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 36850bc..092ff93 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -407,7 +407,6 @@ sw buf_parse_brackets (s_buf *buf, s_call *dest)
   assert(dest);
   buf_save_init(buf, &save);
   call_init(&tmp);
-  ident_init(&tmp.ident, NULL, sym_1("[]"));
   tmp.arguments = list_new(NULL, list_new(NULL, NULL));
   arg_addr = &(list_next(tmp.arguments)->tag);
   if ((r = buf_parse_tag_primary(buf, &tmp.arguments->tag)) <= 0)
@@ -442,6 +441,11 @@ sw buf_parse_brackets (s_buf *buf, s_call *dest)
   arg_addr->type = TAG_ARRAY;
   if (! list_to_array(addr, sym_1("Uw"), &arg_addr->data.array))
     goto restore;
+  ident_init(&tmp.ident, NULL, sym_1("[]"));
+  if (! operator_resolve(&tmp.ident, 2, &tmp.ident)) {
+    warnx("buf_parse_brackets: could not resolve operator []");
+    goto restore;
+  }
   *dest = tmp;
   r = result;
   goto clean;