Commit 46637b09 authored by Julien Lopez's avatar Julien Lopez
Browse files

[TESTS][LAMBDA] Fix on environment; fix test match_error_simple

parent 2d1979cf
......@@ -9,9 +9,9 @@ let rec to_typed expr =
let loc = `File(Loc.file_name loc),
Loc.start_off loc - Loc.start_bol loc,
Loc.stop_off loc - Loc.start_bol loc in
let env1, e1 = to_typed e1 in
let _, e1 = to_typed e1 in
let _, e2 = to_typed e2 in
env1, { exp_loc=loc; exp_typ=Types.empty; exp_descr=Apply(e1, e2) }
env, { exp_loc=loc; exp_typ=Types.empty; exp_descr=Apply(e1, e2) }
| Abstr (loc, fun_name, params, return_type, body) ->
parse_abstr env loc fun_name params return_type body
| Match (loc, e, b) ->
......@@ -51,32 +51,26 @@ and parse_abstr env loc fun_name params return_type body =
let loc = `File(Loc.file_name loc),
Loc.start_off loc - Loc.start_bol loc,
Loc.stop_off loc - Loc.start_bol loc in
let node = Patterns.make [] in
let brloc = get_loc body in
let brloc = `File(Loc.file_name brloc),
Loc.start_off brloc - Loc.start_bol brloc,
Loc.stop_off brloc - Loc.start_bol brloc in
let fv, iface = parse_iface params [] 0 [] env in
let node = Patterns.make fv in
let br = { br_loc=brloc; br_used=true; br_ghost=false;
br_vars_empty=[]; br_pat=node;
br_body=snd(to_typed body) } in
let brs = { br_typ=Types.empty; br_accept=Types.empty;
br_branches=[br] } in
let new_env = { cu=None; vars=Ident.Env.empty; stack_size=0;
max_stack=ref 1000; global_size=env.global_size } in
let iface, fv, new_env = parse_iface params [] [] new_env 0 in
let abstr = { fun_name=Some (0, fun_name); fun_iface=iface; fun_body=brs;
fun_typ=Types.empty; fun_fv=fv } in
new_env, { exp_loc=loc; exp_typ=Types.empty; exp_descr=Abstraction(abstr) }
fun_typ=Types.empty; fun_fv=[] } in
env, { exp_loc=loc; exp_typ=Types.empty; exp_descr=Abstraction(abstr) }
and parse_iface params iface fv env nb = match params with
and parse_iface params fv nb iface env = match params with
| (_, pname, _) :: rest ->
let vars = Ident.Env.add (nb, pname) (Lambda.Local nb) env.vars in
let env = { cu=env.cu; vars=vars; stack_size=nb + 1;
max_stack=env.max_stack;
global_size=env.global_size + nb + 1 } in
parse_iface rest (iface @ [Types.empty, Types.empty]) (fv @ [nb, pname])
env (nb+1)
| [] -> iface, fv, env
parse_iface rest (fv @ [nb, pname]) (nb + 1)
(iface @ [Types.empty, Types.empty]) env
| [] -> fv, iface
and parse_branches brs res = match brs with
| (loc, p, e) :: rest ->
......
File ./tests/eval/tests/match_error_simple.test, line 1, characters 6-7:
Unbound identifier x
Runtime error.
Fatal error: exception Failure("Compile: cannot find a")
match x with | (a : Int,b : Int) -> a
match x with | (a : Int, b : Int) -> a
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment