projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
improve error messages
[pspp]
/
src
/
language
/
expressions
/
parse.c
diff --git
a/src/language/expressions/parse.c
b/src/language/expressions/parse.c
index 3b18be72ddf81bce64bfbd9c23be0547259b0b42..2b78b0b14b41491cc172fc301ac4476fdf0765ba 100644
(file)
--- 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);
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++)
{
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]),
_("Both operands of %s must be strings."), name);
msg_at (SN, expr_location (e, node->args[0]),
- _("Th
e left-hand operand of %s
has type '%s'."),
-
name,
atom_type_name (expr_node_returns (node->args[0])));
+ _("Th
is operand
has type '%s'."),
+ atom_type_name (expr_node_returns (node->args[0])));
msg_at (SN, expr_location (e, node->args[1]),
msg_at (SN, expr_location (e, node->args[1]),
- _("Th
e right-hand operand of %s
has type '%s'."),
-
name,
atom_type_name (expr_node_returns (node->args[1])));
+ _("Th
is operand
has type '%s'."),
+ atom_type_name (expr_node_returns (node->args[1])));
return NULL;
}
return NULL;
}
+ if (!type_coercion (e, node, 0) || !type_coercion (e, node, 1))
+ NOT_REACHED ();
+
lhs = node;
}
}
lhs = node;
}
}
@@
-1400,7
+1400,11
@@
static const char *
atom_type_name (atom_type type)
{
assert (is_atom (type));
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 *
}
struct expr_node *