summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-05-02 15:39:50 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-05-02 15:39:50 -0400
commit8c2327e430ca63349c28816b47d04147873c1aca (patch)
treeea8771d94fe7fa6656c6f6b3795b8c17acbc63a9 /types.c
parent5c1bc458fbeb1c65c5f39ad9f3389f5dcf1e0c8a (diff)
&&, ||
Diffstat (limited to 'types.c')
-rw-r--r--types.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/types.c b/types.c
index 9970d90..536ddf6 100644
--- a/types.c
+++ b/types.c
@@ -3038,6 +3038,24 @@ static Status types_expr(Typer *tr, Expression *e) {
break;
}
+ case BINARY_AND:
+ case BINARY_OR: {
+ bool success = true;
+ if (!type_can_be_truthy(lhs_type)) {
+ char *s = type_to_str(lhs_type);
+ success = false;
+ err_print(lhs->where, "Cannot use operator %s on type %s.", binary_op_to_str(o), s);
+ free(s);
+ }
+ if (!type_can_be_truthy(rhs_type)) {
+ char *s = type_to_str(rhs_type);
+ success = false;
+ err_print(lhs->where, "Cannot use operator %s on type %s.", binary_op_to_str(o), s);
+ free(s);
+ }
+ if (!success) return false;
+ t->kind = TYPE_BUILTIN; t->builtin = BUILTIN_BOOL;
+ } break;
case BINARY_AT_INDEX:
if (type_is_slicechar(rhs_type)) {
/* switch to BINARY_DOT (point["x"] => point.x) */