Skip to content

Commit 487851f

Browse files
committed
---
yaml --- r: 929 b: refs/heads/master c: 79a3811 h: refs/heads/master i: 927: 755cb7e v: v3
1 parent 48bb855 commit 487851f

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 77670e84de5edec73883218f5da3005952b53ea8
2+
refs/heads/master: 79a3811ab81ee14810fa9b7fe86ba0f0501c7399

trunk/src/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
517517

518518
TEST_XFAILS_SELF := $(filter-out \
519519
$(addprefix test/run-pass/, \
520+
arith-0.rs \
521+
arith-2.rs \
520522
bool-not.rs \
523+
char.rs \
521524
dead-code-one-arm-if.rs \
522525
hello.rs \
523526
int.rs \

trunk/src/comp/middle/typeck.rs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ fn ty_to_str(@ty typ) -> str {
189189
}
190190

191191
case (ty_var(?v)) {
192-
// FIXME: wrap around in the case of many variables
193-
auto ch = ('T' as u8) + (v as u8);
194-
s = _str.from_bytes(vec(ch));
192+
s = "<T" + util.common.istr(v) + ">";
195193
}
196194
}
197195

@@ -392,7 +390,7 @@ fn ann_to_type(&ast.ann ann) -> @ty {
392390
alt (ann) {
393391
case (ast.ann_none) {
394392
// shouldn't happen, but can until the typechecker is complete
395-
ret plain_ty(ty_var(0)); // FIXME: broken, broken, broken
393+
ret plain_ty(ty_var(-1)); // FIXME: broken, broken, broken
396394
}
397395
case (ast.ann_type(?ty)) {
398396
ret ty;
@@ -463,7 +461,7 @@ fn unify(@ty expected, @ty actual) -> unify_result {
463461
alt (result) {
464462
case (ures_ok(?result_sub)) {
465463
ret ures_ok(plain_ty(ty_box(result_sub)));
466-
}
464+
}
467465
case (_) {
468466
ret result;
469467
}
@@ -720,6 +718,55 @@ fn check_expr(&@env e, &@ty_table locals, @ast.expr expr) -> @ast.expr {
720718
ast.expr_lit(lit, ast.ann_type(ty)));
721719
}
722720

721+
722+
case (ast.expr_binary(?binop, ?lhs, ?rhs, _)) {
723+
auto lhs_1 = check_expr(e, locals, lhs);
724+
auto rhs_1 = check_expr(e, locals, rhs);
725+
auto lhs_t = type_of(lhs_1);
726+
auto rhs_t = type_of(rhs_1);
727+
// FIXME: Binops have a bit more subtlety than this.
728+
demand(e, expr.span, lhs_t, rhs_t);
729+
auto t = lhs_t;
730+
alt (binop) {
731+
case (ast.eq) { t = plain_ty(ty_bool); }
732+
case (ast.lt) { t = plain_ty(ty_bool); }
733+
case (ast.le) { t = plain_ty(ty_bool); }
734+
case (ast.ne) { t = plain_ty(ty_bool); }
735+
case (ast.ge) { t = plain_ty(ty_bool); }
736+
case (ast.gt) { t = plain_ty(ty_bool); }
737+
}
738+
ret @fold.respan[ast.expr_](expr.span,
739+
ast.expr_binary(binop, lhs_1, rhs_1,
740+
ast.ann_type(t)));
741+
}
742+
743+
744+
case (ast.expr_unary(?unop, ?oper, _)) {
745+
auto oper_1 = check_expr(e, locals, oper);
746+
auto oper_t = type_of(oper_1);
747+
// FIXME: Unops have a bit more subtlety than this.
748+
ret @fold.respan[ast.expr_](expr.span,
749+
ast.expr_unary(unop, oper_1,
750+
ast.ann_type(oper_t)));
751+
}
752+
753+
case (ast.expr_name(?name, ?defopt, _)) {
754+
auto ty = @rec(struct=ty_nil, cname=none[str]);
755+
alt (option.get[ast.def](defopt)) {
756+
case (ast.def_arg(?id)) { ty = locals.get(id); }
757+
case (ast.def_local(?id)) { ty = locals.get(id); }
758+
case (_) {
759+
// FIXME: handle other names.
760+
e.sess.unimpl("definition variant for: "
761+
+ name.node.ident);
762+
fail;
763+
}
764+
}
765+
ret @fold.respan[ast.expr_](expr.span,
766+
ast.expr_name(name, defopt,
767+
ast.ann_type(ty)));
768+
}
769+
723770
case (_) {
724771
// TODO
725772
ret expr;

0 commit comments

Comments
 (0)