diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 9c1a51b..bc6da1d 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -171,3 +171,10 @@ replace {C3.operator23, :cfn, cfn Tag "tag_equal" (Tag, Tag, Result)}
replace {C3.operator23, :operator_precedence, 13}
replace {C3.operator23, :operator_associativity, :right}
replace {C3.break, :cfn, cfn Void "c3_break" ()}
+replace {C3, :symbol, C3.first}
+replace {C3.first, :fn, fn {
+ ((a | _b)) { a }
+ ({a, _b}) { a }
+ ({a, _b, _c}) { a }
+ ({a, _b, _c, _d}) { a }
+}}
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index 61c5e36..d208fc4 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -418,7 +418,7 @@ sw buf_inspect_call_op_unary (s_buf *buf, const s_call *call)
{
sw r;
sw result = 0;
- if (call->ident.sym == sym_1("()"))
+ if (operator_symbol(&call->ident) == sym_1("()"))
return buf_inspect_call_paren(buf, call);
if ((r = buf_inspect_ident(buf, &call->ident)) < 0)
return r;
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 02c39b4..36850bc 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -699,14 +699,14 @@ sw buf_parse_call_op_rec (s_buf *buf, s_call *dest, u8 min_precedence)
break;
}
r = buf_parse_ident_peek(buf, &next_op);
- if (r > 0) {
- if (! operator_resolve(&next_op, 2, &next_op))
- break;
- if ((next_op_precedence = operator_precedence(&next_op)) < 0)
- break;
+ if (r > 0 &&
+ (! operator_resolve(&next_op, 2, &next_op) ||
+ (next_op_precedence = operator_precedence(&next_op)) < 0)) {
+ r = 0;
+ break;
}
}
- if (r <= 0 || (op_precedence = next_op_precedence) < min_precedence)
+ if (r <= 0)
break;
call_init_op(&tmp3);
tmp3.ident = op;
@@ -766,11 +766,16 @@ sw buf_parse_call_paren (s_buf *buf, s_call *dest)
s_call tmp;
s_buf_save save;
call_init_op_unary(&tmp);
- ident_init_1(&tmp.ident, "()");
buf_save_init(buf, &save);
if ((r = buf_read_1(buf, "(")) <= 0)
goto restore;
result += r;
+ ident_init_1(&tmp.ident, "()");
+ if (! operator_resolve(&tmp.ident, 1, &tmp.ident)) {
+ assert(! "buf_parse_call_paren: could not resolve operator ()");
+ r = -1;
+ goto restore;
+ }
if ((r = buf_ignore_spaces(buf)) < 0)
goto restore;
result += r;
diff --git a/libc3/env.c b/libc3/env.c
index 7afaf61..e5fc80d 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -797,7 +797,10 @@ s_ident * env_operator_ident (s_env *env, const s_ident *op,
assert(env);
assert(op);
assert(dest);
- dest->module = op->module;
+ if (env->current_module == op->module)
+ dest->module = NULL;
+ else
+ dest->module = op->module;
dest->sym = env_operator_symbol(env, op);
return dest;
}
diff --git a/test/ic3/op.in b/test/ic3/op.in
index 1247df2..edb8553 100644
--- a/test/ic3/op.in
+++ b/test/ic3/op.in
@@ -1,10 +1,12 @@
-quote 1 + 2
-quote 1 + 2 / 3
-quote 1 + 2 / 3 * 4
-quote 1 + 2 / 3 * 4 - 5
-1 + 2
-1 + 2 / 3
+quote 1 + 20
+1 + 20
+quote 1 + 20 / 3
+1 + 20 / 3
+quote 1 + 20 / 3 * 4
1 + 2 / 3 * 4
+quote 1 + 20 / 3 * 4 - 5
1 + 2 / 3 * 4 - 5
-(1 + 2)
-a = (1 + 2)
+quote (1 + 20)
+(1 + 20)
+quote a = (1 + 20)
+a = (1 + 20)
diff --git a/test/ic3/op.out.expected b/test/ic3/op.out.expected
index 7759641..4300433 100644
--- a/test/ic3/op.out.expected
+++ b/test/ic3/op.out.expected
@@ -1,10 +1,12 @@
-1 + 2
-1 + 2 / 3
-1 + 2 / 3 * 4
-1 + 2 / 3 * 4 - 5
-3
-1
-1
--4
-3
-3
+1 + 20
+21
+1 + 20 / 3
+7
+1 + 20 / 3 * 4
+25
+1 + 20 / 3 * 4 - 5
+20
+(1 + 20)
+21
+a = (1 + 20)
+21