diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-09-16 12:42:18 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-09-16 12:42:18 +0200 |
| commit | d7587c1eda9b46b57b77585638fd775490ff836e (patch) | |
| tree | 36df18710389a28371d93a39f73269c54cac8f83 /src/comp/syntax/parse | |
| parent | 059b31f7a3a58193db1dc80a3bd32cbb36f00e1d (diff) | |
| download | rust-d7587c1eda9b46b57b77585638fd775490ff836e.tar.gz rust-d7587c1eda9b46b57b77585638fd775490ff836e.zip | |
Change convention for specifying referenced argument
It is now 1-based, rather than 0 based. (Seems more natural, and allows 0 to be used to refer to self and maybe to closure.) Also allows non-referenced args to be implicitly copied again. Issue #918
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 5e66ba88126..dffa10ff831 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -448,16 +448,19 @@ fn parse_ret_ty(p: parser, n_args: uint) -> (ast::ret_style, @ast::ty) { if n_args == 0u { p.fatal("can not return reference from argument-less fn"); } - let mut_root = eat(p, token::NOT), arg = 0u; + let mut_root = eat(p, token::NOT), arg = 1u; alt p.peek() { token::LIT_INT(val) { p.bump(); arg = val as uint; } _ { if n_args > 1u { p.fatal("must specify referenced parameter"); } } } - if arg >= n_args { + if arg > n_args { p.fatal("referenced argument does not exist"); } + if arg == 0u { + p.fatal("referenced argument can't be 0"); + } style = ast::return_ref(mut_root, arg); }; (style, parse_ty(p, false)) |
