diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index f12e93bb7727..d4caf9bc03d7 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -1048,10 +1048,24 @@ fn do_nothing(_f: &_fn, _tp: &[ty_param], _sp: &span, _i: &fn_ident, } -fn args_to_constr_args(sp: &span, args: &[arg]) -> [@constr_arg_use] { +fn args_to_constr_args(tcx: &ty::ctxt, args: &[arg], + indices:&[@sp_constr_arg]) -> [@constr_arg_use] { let actuals: [@constr_arg_use] = []; - for a: arg in args { - actuals += [@respan(sp, carg_ident({ident: a.ident, node: a.id}))]; + let num_args = vec::len(args); + for a:@sp_constr_arg in indices { + actuals += [@respan(a.span, alt a.node { + carg_base. { carg_base } + carg_ident(i) { + if i < num_args { + carg_ident({ident: args[i].ident, node:args[i].id}) + } + else { + tcx.sess.span_bug(a.span, ~"Index out of bounds in \ + constraint arg"); + } + } + carg_lit(l) { carg_lit(l) } + })]; } ret actuals; } @@ -1060,7 +1074,7 @@ fn ast_constr_to_ts_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) -> tsconstr { let tconstr = ty::ast_constr_to_constr(tcx, c); ret npred(tconstr.node.path, tconstr.node.id, - args_to_constr_args(tconstr.span, args)); + args_to_constr_args(tcx, args, tconstr.node.args)); } fn ast_constr_to_sp_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) -> diff --git a/src/test/run-pass/bug-862.rs b/src/test/run-pass/bug-862.rs new file mode 100644 index 000000000000..e3cddda3f8a8 --- /dev/null +++ b/src/test/run-pass/bug-862.rs @@ -0,0 +1,11 @@ +pure fn p(j: int) -> bool { true } + +fn f(i: int, j: int) : p(j) -> int { j } + +fn g(i: int, j: int) : p(j) -> int { f(i, j) } + +fn main() { + let x = 1; + check p(x); + log g(x, x); +} \ No newline at end of file