about summary refs log tree commit diff
path: root/src/comp/syntax/parse/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
-rw-r--r--src/comp/syntax/parse/parser.rs7
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))