Make resolve and the typechecker check for a main fn of the
correct type This means if a non-library program leaves out the main program, the error gets caught earlier than link. Closes #626.
This commit is contained in:
parent
196753e4c3
commit
f26ca025de
9 changed files with 89 additions and 10 deletions
|
|
@ -361,7 +361,7 @@ fn build_session(@session::options sopts) -> session::session {
|
|||
auto cstore = cstore::mk_cstore();
|
||||
ret session::session(target_cfg, sopts, cstore,
|
||||
@rec(cm=codemap::new_codemap(), mutable next_id=0),
|
||||
0u);
|
||||
none, 0u);
|
||||
}
|
||||
|
||||
fn parse_pretty(session::session sess, &str name) -> pp_mode {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
import syntax::ast;
|
||||
import syntax::ast::node_id;
|
||||
import syntax::codemap;
|
||||
import codemap::span;
|
||||
import syntax::ast::ty_mach;
|
||||
|
|
@ -49,6 +50,8 @@ obj session(@config targ_cfg,
|
|||
@options opts,
|
||||
metadata::cstore::cstore cstore,
|
||||
parse_sess parse_sess,
|
||||
// For a library crate, this is always none
|
||||
mutable option::t[node_id] main_fn,
|
||||
mutable uint err_count) {
|
||||
fn get_targ_cfg() -> @config { ret targ_cfg; }
|
||||
fn get_opts() -> @options { ret opts; }
|
||||
|
|
@ -110,6 +113,10 @@ obj session(@config targ_cfg,
|
|||
fn span_str(span sp) -> str {
|
||||
ret codemap::span_to_str(sp, self.get_codemap());
|
||||
}
|
||||
fn set_main_id(node_id d) {
|
||||
main_fn = some(d);
|
||||
}
|
||||
fn get_main_id() -> option::t[node_id] { main_fn }
|
||||
}
|
||||
// Local Variables:
|
||||
// fill-column: 78;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue