Browse Source

format

master
zapashcanon 4 years ago
parent
commit
95c846a378
Signed by: zapashcanon GPG Key ID: 8981C3C62D1D28F1
  1. 19
      src/type_analysis.ml
  2. 2
      test/test.ml

19
src/type_analysis.ml

@ -3,6 +3,7 @@ open Lang
module Make (M : sig
module Error : sig
exception Unbound_variable of string
exception Unbound_literal of Lang.literal
end
end) =
@ -10,17 +11,19 @@ struct
let tbl = Hashtbl.create 512
let literal = function
| Unit -> ()
| Bool _b -> ()
| Unit ->
()
| Bool _b ->
()
| Custom s ->
if not @@ Hashtbl.mem tbl s then raise @@ M.Error.Unbound_literal (Custom s)
if not @@ Hashtbl.mem tbl s then
raise @@ M.Error.Unbound_literal (Custom s)
let const = function
| Literal l -> literal l
| Var _id -> ()
let const = function Literal l -> literal l | Var _id -> ()
let rec expr = function
| Const c -> const c
| Const c ->
const c
| Bind (_p, e1, e2) ->
expr e1 ; expr e2
| Abstract (_b, _p, e) ->
@ -28,7 +31,7 @@ struct
| Apply (e1, e2) ->
expr e1 ; expr e2
| Match (_origin, match_expr, cases) ->
List.iter literal (List.map fst cases);
List.iter literal (List.map fst cases) ;
List.iter expr (match_expr :: List.map snd cases)
| Type (id, cons, e) ->
List.iter

2
test/test.ml

@ -105,7 +105,7 @@ let _ =
; "useless_match_matchexpr"
; "useless_match_onecase"
; "useless_match_expr"
; "unbound_literal"] ;
; "unbound_literal" ] ;
List.iter check_eval
[ "eunit"
; "eid"

Loading…
Cancel
Save