Annotate FIXMEs in parser
Also, get rid of two FIXMEs by refactoring some code, and moving the call_expr check for be expressions into typeck, where it seems to make more sense.
This commit is contained in:
parent
cdc8722f95
commit
31ff64c62d
2 changed files with 30 additions and 31 deletions
|
@ -26,6 +26,9 @@ export parse_stmt;
|
||||||
export parse_ty;
|
export parse_ty;
|
||||||
|
|
||||||
// FIXME: #ast expects to find this here but it's actually defined in `parse`
|
// FIXME: #ast expects to find this here but it's actually defined in `parse`
|
||||||
|
// Fixing this will be easier when we have export decls on individual items --
|
||||||
|
// then parse can export this publicly, and everything else crate-visibly.
|
||||||
|
// (See #1893)
|
||||||
import parse_from_source_str;
|
import parse_from_source_str;
|
||||||
export parse_from_source_str;
|
export parse_from_source_str;
|
||||||
|
|
||||||
|
@ -224,8 +227,10 @@ fn parse_ty_fn(p: parser) -> ast::fn_decl {
|
||||||
let inputs =
|
let inputs =
|
||||||
parse_seq(token::LPAREN, token::RPAREN, seq_sep(token::COMMA),
|
parse_seq(token::LPAREN, token::RPAREN, seq_sep(token::COMMA),
|
||||||
parse_fn_input_ty, p);
|
parse_fn_input_ty, p);
|
||||||
// FIXME: there's no syntax for this right now anyway
|
// FIXME: constrs is empty because right now, higher-order functions
|
||||||
// auto constrs = parse_constrs(~[], p);
|
// can't have constrained types.
|
||||||
|
// Not sure whether that would be desirable anyway. See #34 for the
|
||||||
|
// story on constrained types.
|
||||||
let constrs: [@ast::constr] = [];
|
let constrs: [@ast::constr] = [];
|
||||||
let (ret_style, ret_ty) = parse_ret_ty(p);
|
let (ret_style, ret_ty) = parse_ret_ty(p);
|
||||||
ret {inputs: inputs.node, output: ret_ty,
|
ret {inputs: inputs.node, output: ret_ty,
|
||||||
|
@ -400,9 +405,9 @@ fn parse_ret_ty(p: parser) -> (ast::ret_style, @ast::ty) {
|
||||||
fn region_from_name(p: parser, s: option<str>) -> ast::region {
|
fn region_from_name(p: parser, s: option<str>) -> ast::region {
|
||||||
let r = alt s {
|
let r = alt s {
|
||||||
some (string) {
|
some (string) {
|
||||||
// FIXME: To be consistent with our type resolution the
|
// FIXME: To be consistent with our type resolution, the
|
||||||
// static region should probably be resolved during type
|
// static region should probably be resolved during type
|
||||||
// checking, not in the parser.
|
// checking, not in the parser. (Issue #2256)
|
||||||
if string == "static" {
|
if string == "static" {
|
||||||
ast::re_static
|
ast::re_static
|
||||||
} else {
|
} else {
|
||||||
|
@ -973,12 +978,8 @@ fn parse_bottom_expr(p: parser) -> pexpr {
|
||||||
hi = p.span.hi;
|
hi = p.span.hi;
|
||||||
} else if eat_word(p, "be") {
|
} else if eat_word(p, "be") {
|
||||||
let e = parse_expr(p);
|
let e = parse_expr(p);
|
||||||
|
hi = e.span.hi;
|
||||||
// FIXME: Is this the right place for this check?
|
ex = ast::expr_be(e);
|
||||||
if /*check*/ast_util::is_call_expr(e) {
|
|
||||||
hi = e.span.hi;
|
|
||||||
ex = ast::expr_be(e);
|
|
||||||
} else { p.fatal("non-call expression in tail call"); }
|
|
||||||
} else if eat_word(p, "copy") {
|
} else if eat_word(p, "copy") {
|
||||||
let e = parse_expr(p);
|
let e = parse_expr(p);
|
||||||
ex = ast::expr_copy(e);
|
ex = ast::expr_copy(e);
|
||||||
|
@ -2070,6 +2071,19 @@ fn parse_item_class(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_single_class_item(p: parser, privcy: ast::privacy)
|
||||||
|
-> @ast::class_member {
|
||||||
|
if eat_word(p, "let") {
|
||||||
|
let a_var = parse_instance_var(p, privcy);
|
||||||
|
expect(p, token::SEMI);
|
||||||
|
ret a_var;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let m = parse_method(p, privcy);
|
||||||
|
ret @{node: ast::class_method(m), span: m.span};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// lets us identify the constructor declaration at
|
// lets us identify the constructor declaration at
|
||||||
// parse time
|
// parse time
|
||||||
enum class_contents { ctor_decl(ast::fn_decl, ast::blk, codemap::span),
|
enum class_contents { ctor_decl(ast::fn_decl, ast::blk, codemap::span),
|
||||||
|
@ -2089,35 +2103,18 @@ fn parse_class_item(p:parser, class_name_with_tps:@ast::path)
|
||||||
let body = parse_block(p);
|
let body = parse_block(p);
|
||||||
ret ctor_decl(decl, body, ast_util::mk_sp(lo, p.last_span.hi));
|
ret ctor_decl(decl, body, ast_util::mk_sp(lo, p.last_span.hi));
|
||||||
}
|
}
|
||||||
// FIXME: refactor
|
|
||||||
else if eat_word(p, "priv") {
|
else if eat_word(p, "priv") {
|
||||||
expect(p, token::LBRACE);
|
expect(p, token::LBRACE);
|
||||||
let mut results = [];
|
let mut results = [];
|
||||||
while p.token != token::RBRACE {
|
while p.token != token::RBRACE {
|
||||||
if eat_word(p, "let") {
|
results += [parse_single_class_item(p, ast::priv)];
|
||||||
let a_var = parse_instance_var(p, ast::priv);
|
|
||||||
expect(p, token::SEMI);
|
|
||||||
results += [a_var];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let m = parse_method(p, ast::priv);
|
|
||||||
results += [@{node: ast::class_method(m), span: m.span}];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.bump();
|
p.bump();
|
||||||
ret members(results);
|
ret members(results);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Probably need to parse attrs
|
// Probably need to parse attrs
|
||||||
ret if eat_word(p, "let") {
|
ret members([parse_single_class_item(p, ast::pub)]);
|
||||||
let ivar = parse_instance_var(p, ast::pub);
|
|
||||||
expect(p, token::SEMI);
|
|
||||||
members([ivar])
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let m = parse_method(p, ast::pub);
|
|
||||||
members([@{node: ast::class_method(m), span: m.span}])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3160,8 +3160,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||||
fcx.write_bot(id);
|
fcx.write_bot(id);
|
||||||
}
|
}
|
||||||
ast::expr_be(e) {
|
ast::expr_be(e) {
|
||||||
// FIXME: prove instead of assert
|
if !ast_util::is_call_expr(e) {
|
||||||
assert (ast_util::is_call_expr(e));
|
tcx.sess.span_err(expr.span,
|
||||||
|
"non-call expression in tail call");
|
||||||
|
}
|
||||||
check_expr_with(fcx, e, fcx.ret_ty);
|
check_expr_with(fcx, e, fcx.ret_ty);
|
||||||
bot = true;
|
bot = true;
|
||||||
fcx.write_nil(id);
|
fcx.write_nil(id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue