X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fexpressions%2Fparse.c;h=2b78b0b14b41491cc172fc301ac4476fdf0765ba;hb=d3c96903451307e60d1d4a680ecf58c86cac7eaa;hp=3b18be72ddf81bce64bfbd9c23be0547259b0b42;hpb=e3d8aa9d9873e60ba0e84e814c28f94a92ad0352;p=pspp diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index 3b18be72dd..2b78b0b14b 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -593,10 +593,7 @@ parse_binary_operators__ (struct lexer *lexer, struct expression *e, return NULL; struct expr_node *node = expr_allocate_binary (e, optype, lhs, rhs); - bool lhs_ok = type_coercion (e, node, 0); - bool rhs_ok = type_coercion (e, node, 1); - - if (!lhs_ok || !rhs_ok) + if (!is_coercible (node, 0) || !is_coercible (node, 1)) { bool both = false; for (size_t i = 0; i < n_ops; i++) @@ -615,15 +612,18 @@ parse_binary_operators__ (struct lexer *lexer, struct expression *e, _("Both operands of %s must be strings."), name); msg_at (SN, expr_location (e, node->args[0]), - _("The left-hand operand of %s has type '%s'."), - name, atom_type_name (expr_node_returns (node->args[0]))); + _("This operand has type '%s'."), + atom_type_name (expr_node_returns (node->args[0]))); msg_at (SN, expr_location (e, node->args[1]), - _("The right-hand operand of %s has type '%s'."), - name, atom_type_name (expr_node_returns (node->args[1]))); + _("This operand has type '%s'."), + atom_type_name (expr_node_returns (node->args[1]))); return NULL; } + if (!type_coercion (e, node, 0) || !type_coercion (e, node, 1)) + NOT_REACHED (); + lhs = node; } } @@ -1400,7 +1400,11 @@ static const char * atom_type_name (atom_type type) { assert (is_atom (type)); - return operations[type].name; + + /* The Boolean type is purely an internal concept that the documentation + doesn't mention, so it might confuse users if we talked about them in + diagnostics. */ + return type == OP_boolean ? "number" : operations[type].name; } struct expr_node *