@@ -189,9 +189,7 @@ fn ty_to_str(@ty typ) -> str {
189
189
}
190
190
191
191
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) + ">" ;
195
193
}
196
194
}
197
195
@@ -392,7 +390,7 @@ fn ann_to_type(&ast.ann ann) -> @ty {
392
390
alt ( ann ) {
393
391
case ( ast. ann_none ) {
394
392
// 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
396
394
}
397
395
case ( ast. ann_type ( ?ty) ) {
398
396
ret ty;
@@ -463,7 +461,7 @@ fn unify(@ty expected, @ty actual) -> unify_result {
463
461
alt ( result) {
464
462
case ( ures_ok( ?result_sub) ) {
465
463
ret ures_ok( plain_ty( ty_box( result_sub) ) ) ;
466
- }
464
+ }
467
465
case ( _) {
468
466
ret result;
469
467
}
@@ -720,6 +718,55 @@ fn check_expr(&@env e, &@ty_table locals, @ast.expr expr) -> @ast.expr {
720
718
ast. expr_lit ( lit, ast. ann_type ( ty) ) ) ;
721
719
}
722
720
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
+
723
770
case ( _) {
724
771
// TODO
725
772
ret expr;
0 commit comments