Teach ty and typeck about pat_lit.
This commit is contained in:
parent
f951b52e91
commit
c9956a65b4
@ -656,6 +656,7 @@ fn block_ty(&ast.block b) -> @t {
|
||||
fn pat_ty(@ast.pat pat) -> @t {
|
||||
alt (pat.node) {
|
||||
case (ast.pat_wild(?ann)) { ret ann_to_type(ann); }
|
||||
case (ast.pat_lit(_, ?ann)) { ret ann_to_type(ann); }
|
||||
case (ast.pat_bind(_, _, ?ann)) { ret ann_to_type(ann); }
|
||||
case (ast.pat_tag(_, _, _, ?ann)) { ret ann_to_type(ann); }
|
||||
}
|
||||
|
@ -807,6 +807,10 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
|
||||
auto t = demand(fcx, pat.span, expected, ann_to_type(ann));
|
||||
p_1 = ast.pat_wild(ast.ann_type(t));
|
||||
}
|
||||
case (ast.pat_lit(?lit, ?ann)) {
|
||||
auto t = demand(fcx, pat.span, expected, ann_to_type(ann));
|
||||
p_1 = ast.pat_lit(lit, ast.ann_type(t));
|
||||
}
|
||||
case (ast.pat_bind(?id, ?did, ?ann)) {
|
||||
auto t = demand(fcx, pat.span, expected, ann_to_type(ann));
|
||||
fcx.locals.insert(did, t);
|
||||
@ -1093,6 +1097,9 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
|
||||
case (ast.pat_wild(_)) {
|
||||
new_pat = ast.pat_wild(ast.ann_type(next_ty_var(fcx.ccx)));
|
||||
}
|
||||
case (ast.pat_lit(?lt, _)) {
|
||||
new_pat = ast.pat_lit(lt, ast.ann_type(check_lit(lt)));
|
||||
}
|
||||
case (ast.pat_bind(?id, ?def_id, _)) {
|
||||
auto ann = ast.ann_type(next_ty_var(fcx.ccx));
|
||||
new_pat = ast.pat_bind(id, def_id, ann);
|
||||
|
Loading…
x
Reference in New Issue
Block a user