aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorTim Chevalier <[email protected]>2011-05-02 14:28:35 -0700
committerGraydon Hoare <[email protected]>2011-05-05 11:26:07 -0700
commit3060eadcbabba50fd6a5d633fea710b6b6bed614 (patch)
tree600e724e9e29f38bddd2861c006f4da49e7fa2ee /src/comp/middle
parentChange checks to asserts in test/bench files (diff)
downloadrust-3060eadcbabba50fd6a5d633fea710b6b6bed614.tar.xz
rust-3060eadcbabba50fd6a5d633fea710b6b6bed614.zip
Check well-formedness of constraints
Check that the operand in a constraint is an explicit name, and that the operands are all local variables or literals. Still need to check that the name refers to a pure function.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/typeck.rs29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index fd915108..e693fdf7 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -1964,12 +1964,29 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
literals or slots */
alt (e.node) {
case (ast.expr_call(?operator, ?operands, _)) {
- /* operator must be a pure function */
- /* FIXME: need more checking */
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_check(expr_t,
- plain_ann(fcx.ccx.tcx)));
-
+ alt (operator.node) {
+ case (ast.expr_path(?oper_name, ?d_id, _)) {
+
+ for (@ast.expr operand in operands) {
+ if (! ast.is_constraint_arg(operand)) {
+ fcx.ccx.sess.span_err(expr.span,
+ "Constraint args must be "
+ + "slot variables or literals");
+ }
+ }
+
+ /* operator must be a pure function */
+ /* FIXME: need more checking */
+ ret @fold.respan[ast.expr_]
+ (expr.span, ast.expr_check(expr_t,
+ plain_ann(fcx.ccx.tcx)));
+ }
+ case (_) {
+ fcx.ccx.sess.span_err(expr.span,
+ "In a constraint, expected the constraint name "
+ + "to be an explicit name");
+ }
+ }
}
case (_) {
fcx.ccx.sess.span_err(expr.span,