diff --git a/lib/kc3/0.1/kc3.facts b/lib/kc3/0.1/kc3.facts
index 84bec95..350a688 100644
--- a/lib/kc3/0.1/kc3.facts
+++ b/lib/kc3/0.1/kc3.facts
@@ -180,14 +180,14 @@ add {KC3, :operator, KC3.operator_and}
replace {KC3.operator_and, :is_a, :operator}
replace {KC3.operator_and, :sym, :&&}
replace {KC3.operator_and, :arity, 2}
-replace {KC3.operator_and, :symbol_value, cfn_macro Bool "kc3_and" (Tag, Tag, Result)}
+replace {KC3.operator_and, :symbol_value, cfn_macro Tag "kc3_and" (Tag, Tag, Result)}
replace {KC3.operator_and, :operator_precedence, 5}
replace {KC3.operator_and, :operator_associativity, :left}
add {KC3, :operator, KC3.operator_or}
replace {KC3.operator_or, :is_a, :operator}
replace {KC3.operator_or, :sym, :||}
replace {KC3.operator_or, :arity, 2}
-replace {KC3.operator_or, :symbol_value, cfn_macro Bool "kc3_or" (Tag, Tag, Result)}
+replace {KC3.operator_or, :symbol_value, cfn_macro Tag "kc3_or" (Tag, Tag, Result)}
replace {KC3.operator_or, :operator_precedence, 4}
replace {KC3.operator_or, :operator_associativity, :left}
add {KC3, :operator, KC3.operator_assign}
diff --git a/libkc3/env.c b/libkc3/env.c
index 0b2935d..dcdc0a4 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -94,7 +94,7 @@ s_tag * env_and (s_env *env, s_tag *a, s_tag *b, s_tag *dest)
assert(dest);
if (! env_eval_tag(env, a, &eval))
return NULL;
- if (! bool_init_cast(&p, &type, &eval)) {
+ if (! bool_init_cast(&p, &sym_Bool, &eval)) {
tag_clean(&eval);
return NULL;
}
@@ -103,7 +103,7 @@ s_tag * env_and (s_env *env, s_tag *a, s_tag *b, s_tag *dest)
if (p) {
if (! env_eval_tag(env, b, &eval))
return NULL;
- if (! bool_init_cast(&p, &type, &eval)) {
+ if (! bool_init_cast(&p, &sym_Bool, &eval)) {
tag_clean(&eval);
return NULL;
}
@@ -3660,34 +3660,38 @@ const s_sym ** env_operator_symbol (s_env *env, const s_ident *op,
return result;
}
-bool * env_or (s_env *env, s_tag *a, s_tag *b, bool *dest)
+s_tag * env_or (s_env *env, s_tag *a, s_tag *b, s_tag *dest)
{
s_tag eval;
- bool tmp;
- const s_sym *type;
+ bool p;
+ const s_sym *sym_Bool = &g_sym_Bool;
assert(env);
assert(a);
assert(b);
assert(dest);
- type = &g_sym_Bool;
if (! env_eval_tag(env, a, &eval))
return NULL;
- if (! bool_init_cast(&tmp, &type, &eval)) {
+ if (! bool_init_cast(&p, &sym_Bool, &eval)) {
tag_clean(&eval);
return NULL;
}
+ if (p) {
+ *dest = eval;
+ return dest;
+ }
tag_clean(&eval);
- if (! tmp) {
- if (! env_eval_tag(env, b, &eval))
- return NULL;
- if (! bool_init_cast(&tmp, &type, &eval)) {
- tag_clean(&eval);
- return NULL;
- }
+ if (! env_eval_tag(env, b, &eval))
+ return NULL;
+ if (! bool_init_cast(&p, &sym_Bool, &eval)) {
tag_clean(&eval);
+ return NULL;
}
- *dest = tmp;
- return dest;
+ if (p) {
+ *dest = eval;
+ return dest;
+ }
+ tag_clean(&eval);
+ return tag_init_bool(dest, false);
}
void env_pop_error_handler (s_env *env)
diff --git a/test/ikc3/facts_with.out.expected b/test/ikc3/facts_with.out.expected
index 0185d4f..cdafbcb 100644
--- a/test/ikc3/facts_with.out.expected
+++ b/test/ikc3/facts_with.out.expected
@@ -55,7 +55,7 @@ operator_and :is_a :operator
operator_and :operator_associativity :left
operator_and :operator_precedence 5
operator_and :sym :&&
-operator_and :symbol_value cfn Bool "kc3_and" (Tag, Tag, Result)
+operator_and :symbol_value cfn Tag "kc3_and" (Tag, Tag, Result)
operator_assign :arity 2
operator_assign :is_a :operator
operator_assign :operator_associativity :left
@@ -182,7 +182,7 @@ operator_or :is_a :operator
operator_or :operator_associativity :left
operator_or :operator_precedence 4
operator_or :sym :||
-operator_or :symbol_value cfn Bool "kc3_or" (Tag, Tag, Result)
+operator_or :symbol_value cfn Tag "kc3_or" (Tag, Tag, Result)
operator_paren :arity 1
operator_paren :is_a :operator
operator_paren :operator_associativity :left