Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
78fa0667
Commit
78fa0667
authored
May 14, 2014
by
Pietro Abate
Browse files
Merge branch 'typing-test' into master-merge
parents
bf2fe4ef
47b65c38
Changes
15
Hide whitespace changes
Inline
Side-by-side
compile/compile.ml
View file @
78fa0667
...
...
@@ -73,7 +73,11 @@ and compile_aux env = function
|
Typed
.
Var
x
->
Var
(
find
x
env
)
|
Typed
.
TVar
x
->
let
v
=
find
x
env
in
let
polyvars
=
Var
.
Set
.
inter
(
domain
(
env
.
sigma
))
(
Types
.
all_vars
(
Types
.
descr
(
IdMap
.
assoc
x
env
.
gamma
)))
in
let
polyvars
=
Var
.
Set
.
inter
(
domain
(
env
.
sigma
))
(
Types
.
all_vars
(
Types
.
descr
(
IdMap
.
assoc
x
env
.
gamma
)))
in
if
Var
.
Set
.
is_empty
polyvars
then
Var
(
v
)
else
TVar
(
v
,
env
.
sigma
)
|
Typed
.
Subst
(
e
,
sl
)
->
compile
{
env
with
sigma
=
`Comp
(
env
.
sigma
,
`List
sl
)
}
e
...
...
tests/typed/src/main.ml
View file @
78fa0667
...
...
@@ -44,17 +44,15 @@ end
let
run_test_typer
msg
expected
totest
=
let
parse_expr
s
=
let
astexpr
=
Parser
.
expr
(
Stream
.
of_string
s
)
in
Format
.
printf
"aaa
\n
"
;
let
texpr
=
fst
(
Typer
.
type_expr
BIN
.
env
astexpr
)
in
Format
.
printf
"bbb
\n
"
;
Format
.
printf
"Cduce Typed -> %a%!@."
Printer
.
pp_typed
texpr
;
Format
.
printf
"Cduce Typed -> %s%!@."
(
Printer
.
typed_to_string
texpr
);
texpr
in
let
parse_typed
s
=
try
let
expr
=
Parse
.
ExprParser
.
of_string_no_file
s
in
let
env
,
texpr
=
Compute
.
to_typed
expr
in
Format
.
printf
"Expected Typed -> %
a
%!@."
Printer
.
pp_
typed
texpr
;
Format
.
printf
"Expected Typed -> %
s
%!@."
(
Printer
.
typed
_to_string
texpr
)
;
texpr
with
|
Compute
.
Error
->
exit
3
...
...
@@ -70,6 +68,35 @@ let run_test_typer msg expected totest =
let
expected
=
(
parse_typed
expected
)
in
let
totest
=
(
parse_expr
totest
)
in
assert_equal
~
msg
:
msg
~
printer
:
(
fun
x
->
Printer
.
typed_to_string
x
)
expected
totest
(*
"match" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.match.hard failed"
~printer:(fun x -> x) (load_file "tests/match/hard.ref")
(run_test "(fun ((Int -> Int) -> Int) | f ->
(match f 0 with | 0 -> 0 | _ -> 1)) (fun (Int -> Int) | x -> x+2)");
assert_equal ~msg:"Test CDuce.runtime.match.medium failed"
~printer:(fun x -> x) (load_file "tests/match/medium.ref")
(run_test "(fun (Int -> Int) | x ->
(match x with | 1 -> 3 | x -> x)) 2");
assert_equal ~msg:"Test CDuce.runtime.match.simple failed"
~printer:(fun x -> x) (load_file "tests/match/simple.ref")
(run_test "(fun (Int -> Int) | x -> (match x with | _ -> x)) 2");
);
"list" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.list.fold failed"
~printer:(fun x -> x) (load_file "tests/list/fold.ref")
(run_test "fun (Int -> [Int*] -> [Int*])
| x -> (fun ([Int*] -> [Int*])
| y -> [x] @ y)");
assert_equal ~msg:"Test CDuce.runtime.list.is_empty failed"
~printer:(fun x -> x) (load_file "tests/list/is_empty.ref")
(run_test "fun ([Int*] -> Bool) | [] -> `true | _ -> `false");
assert_equal ~msg:"Test CDuce.runtime.list.tail failed"
~printer:(fun x -> x) (load_file "tests/list/tail.ref")
(run_test "fun ([Int*] -> [Int*]) | [_ (rest::(Int*)
)]
->
rest
|
[]
->
[]
");
);
*)
(* (message, typed expr - expected, cduce expr) *)
let tests_typer_list = [
...
...
tests/typed/src/printer.ml
View file @
78fa0667
...
...
@@ -62,6 +62,7 @@ and pp_typed_aux ppf e =
Format
.
fprintf
ppf
"Match(%a,%a)"
pp_typed
e
pp_branches
b
|
Typed
.
Subst
(
e
,
s
)
->
Format
.
fprintf
ppf
"Subst(%a,[%a])"
pp_typed
e
pp_typedsigma
s
|
Typed
.
Op
(
s
,
i
,
l
)
->
Format
.
fprintf
ppf
"(%s, %d, "
s
i
;
(
print_lst
pp_typed
ppf
l
);
Format
.
fprintf
ppf
")"
|
_
->
assert
false
and
pp_abst
ppf
abstr
=
...
...
tests/typed/src/printer.mli
0 → 100644
View file @
78fa0667
val
typed_to_string
:
Typed
.
texpr
->
string
val
print_env
:
Lambda
.
var_loc
Ident
.
Env
.
t
->
unit
val
print_value
:
Value
.
t
->
unit
val
value_to_string
:
Value
.
t
->
string
val
lambda_to_string
:
Lambda
.
expr
->
string
tests/typed/tests/abstr/identity.ref
View file @
78fa0667
{typ:Int; descr=({typ:Int -> Int; descr=Abstraction(name:<none>,
iface:[(Int, Int)],
{typ: Int; descr= ({typ: Int -> Int; descr= Abstraction(name:<none>,
iface:[(
Int, Int)],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Var(0, x)}}}], typ:Int -> Int, fv:[])}).({typ:Int; descr=Integer(2)})}
pat:{id:3; descr:[x]; accept:[id:176; descr:
Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ: Int; descr= Var(0,x)}}}], typ:
Int -> Int, fv:[])}).({typ: Int; descr= Integer(2)})}
tests/typed/tests/list/fold.ref
View file @
78fa0667
{typ:Int -> X1 -> X1 where X1 = [ Int* ]; descr=Abstraction(name:<none>,
iface:[(Int, X1 -> X1 where X1 = [ Int* ])],
{typ: Int -> X1 -> X1 where X1 = [ Int* ]; descr= Abstraction(name:<none>,
iface:[(
Int, X1 -> X1 where X1 = [ Int* ])],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:178; descr:Any]; fv:[(0, x)]};
body:{typ:X1 -> X1 where X1 = [ Int* ], descr:{typ:X1 -> X1 where X1 = [ Int* ]; descr=Abstraction(name:<none>,
iface:[([ Int* ], [ Int* ])],
pat:{id:3; descr:[x]; accept:[id:178; descr:
Any]; fv:[(0, x)]};
body:{typ:X1 -> X1 where X1 = [ Int* ], descr:{typ:
X1 -> X1 where X1 = [ Int* ]; descr= Abstraction(name:<none>,
iface:[(
[ Int* ], [ Int* ])],
body:[typ:[ Int* ], accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Any; [(0, y)]; Capture(0, y)]; accept:[id:179; descr:Any]; fv:[(0, y)]};
body:{typ:[ Int* ], descr:{typ:[ Int* ]; descr=Op(@, 0, [{typ:[ Int* ]; descr=({typ:Int; descr=Var(0, x)}, {typ:[ Int* ]; descr=Atom(nil)})}; {typ:[ Int* ]; descr=Var(0, y)}])}}}], typ:X1 -> X1 where X1 = [ Int* ], fv:[(0, x)])}}}], typ:Int -> X1 -> X1 where X1 = [ Int* ], fv:[])}
pat:{id:4; descr:[y]; accept:[id:179; descr:
Any]; fv:[(0, y)]};
body:{typ:[ Int* ], descr:{typ: [ Int* ]; descr= (@, 0, {typ:
[ Int* ]; descr= ({typ: Int; descr= Var(0,x)}, {typ: [ Int* ]; descr= Atom(nil)})} ,{typ:
[ Int* ]; descr= Var(0,y)})}}}], typ:X1 -> X1 where X1 = [ Int* ], fv:[(0, x)])}}}], typ:
Int -> X1 -> X1 where X1 = [ Int* ], fv:[])}
tests/typed/tests/list/is_empty.ref
View file @
78fa0667
{typ:[ Int ] -> Bool; descr=Abstraction(name:<none>,
iface:[([ Int ], Bool)],
body:[typ:[ Int ], accept:Any, branches:
{used:false; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[[ ]; []; Constr([ ])]; accept:[id:179; descr:[ ]]; fv:[]};
body:{typ:Empty, descr:{typ:Empty; descr=Atom(true)}}},
{typ: [ Int* ] -> Bool; descr= Abstraction(name:<none>,
iface:[([ Int* ],
Bool)],
body:[typ:[ Int* ], accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Any; []; Constr(Any)]; accept:[id:180; descr:Any]; fv:[]};
body:{typ:Bool, descr:{typ:Bool; descr=Atom(false)}}}], typ:[ Int ] -> Bool, fv:[])}
pat:{id:3; descr:[
[ ]]; accept:[id:178; descr:[ ]]; fv:[]};
body:{typ:Bool, descr:{typ:
Bool; descr= Atom(true)}}} ,
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[
Any]; accept:[id:179; descr:Any]; fv:[]};
body:{typ:Bool, descr:{typ:
Bool; descr= Atom(false)}}}], typ:[ Int* ] -> Bool, fv:[])}
tests/typed/tests/list/tail.ref
View file @
78fa0667
{typ:X1 -> X1 where X1 = [ Int* ]; descr=Abstraction(name:<none>,
iface:[([ Int* ], [ Int* ])],
{typ: X1 -> X1 where X1 = [ Int* ]; descr= Abstraction(name:<none>,
iface:[(
[ Int* ], [ Int* ])],
body:[typ:[ Int* ], accept:[ (Any Int*)? ], branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[[ Any Int* ]; [(0, rest)]; Times({id:5; descr:[Any; []; Constr(Any)]; accept:[id:179; descr:Any]; fv:[]}, {id:4; descr:[[ Int* ]; [(0, rest)]; Cap([Any; [(0, rest)]; Capture(0, rest)], [[ Int* ]; []; Constr([ Int* ])])]; accept:[id:178; descr:[ Int* ]]; fv:[(0, rest)]})]; accept:[id:177; descr:[ Any Int* ]]; fv:[(0, rest)]};
body:{typ:[ Int* ], descr:{typ:[ Int* ]; descr=Var(0, rest)}}},
pat:{id:3; descr:[(
Any,(rest & [ Int* ]))]; accept:[id:177; descr:[ Any Int* ]]; fv:[(0, rest)]};
body:{typ:
[ Int* ], descr:{typ: [ Int* ]; descr= Var(0,rest)}}} ,
{used:true; ghost:false; br_vars_empty:[];
pat:{id:6; descr:[[ ]; []; Constr([ ])]; accept:[id:180; descr:[ ]]; fv:[]};
body:{typ:[ Int* ], descr:{typ:[ Int* ]; descr=Atom(nil)}}}], typ:X1 -> X1 where X1 = [ Int* ], fv:[])}
pat:{id:6; descr:[
[ ]]; accept:[id:180; descr:[ ]]; fv:[]};
body:{typ:[ Int* ], descr:{typ:
[ Int* ]; descr= Atom(nil)}}}], typ:X1 -> X1 where X1 = [ Int* ], fv:[])}
tests/typed/tests/match/hard.ref
0 → 100644
View file @
78fa0667
{typ: Int; descr= ({typ: (Int -> Int) -> Int; descr= Abstraction(name:<none>,
iface:[(
Int -> Int, Int)],
body:[typ:Int -> Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[f]; accept:[id:177; descr:
Any]; fv:[(0, f)]};
body:{typ:Int, descr:{typ: Int; descr= Match({typ:
Int; descr= ({typ: Int -> Int; descr= Var(0,f)}).({typ: Int; descr= Integer(0)})},typ:
Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[
0]; accept:[id:178; descr:0]; fv:[]};
body:{typ:Int, descr:{typ: Int; descr= Integer(0)}}} ,
{used:true; ghost:false; br_vars_empty:[];
pat:{id:5; descr:[
Any]; accept:[id:179; descr:Any]; fv:[]};
body:{typ:Int, descr:{typ:
Int; descr= Integer(1)}}})}}}], typ:(Int -> Int) -> Int, fv:[])}).({typ:
Int -> Int; descr= Abstraction(name:<none>,
iface:[(Int, Int)],
body:[typ:
Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:6; descr:[x]; accept:[id:180; descr:
Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ: Int; descr= (+, 0, {typ:
Int; descr= Var(0,x)} ,{typ: 2; descr= Integer(2)})}}}], typ:Int -> Int, fv:[])})}
tests/typed/tests/match/medium.ref
View file @
78fa0667
{typ:Int; descr=({typ:Int -> Int; descr=Abstraction(name:<none>,
iface:[(Int, Int)],
{typ: Int; descr= ({typ: Int -> Int; descr= Abstraction(name:<none>,
iface:[(
Int, Int)],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Match({typ:Int; descr=Var(0, x)},typ:Int, accept:Any, branches:
pat:{id:3; descr:[x]; accept:[id:176; descr:
Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ: Int; descr= Match({typ:
Int; descr= Var(0,x)},typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[1; []; Constr(1)]; accept:[id:177; descr:1]; fv:[]};
body:{typ:Int, descr:{typ:Int; descr=Integer(3)}}},
pat:{id:4; descr:[
1]; accept:[id:177; descr:1]; fv:[]};
body:{typ:Int, descr:{typ: Int; descr= Integer(3)}}} ,
{used:true; ghost:false; br_vars_empty:[];
pat:{id:5; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:178; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Var(0, x)}}})}}}], typ:Int -> Int, fv:[])}).({typ:Int; descr=Integer(2)})}
pat:{id:5; descr:[x]; accept:[id:178; descr:
Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ: Int; descr= Var(0,x)}}})}}}], typ:
Int -> Int, fv:[])}).({typ: Int; descr= Integer(2)})}
tests/typed/tests/match/simple.ref
View file @
78fa0667
{typ:Int; descr=({typ:Int -> Int; descr=Abstraction(name:<none>,
iface:[(Int, Int)],
{typ: Int; descr= ({typ: Int -> Int; descr= Abstraction(name:<none>,
iface:[(
Int, Int)],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Match({typ:Int; descr=Var(0, x)},typ:Int, accept:Any, branches:
pat:{id:3; descr:[x]; accept:[id:176; descr:
Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ: Int; descr= Match({typ:
Int; descr= Var(0,x)},typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Any; []; Constr(Any)]; accept:[id:177; descr:Any]; fv:[]};
body:{typ:Int, descr:{typ:Int; descr=Var(0, x)}}})}}}], typ:Int -> Int, fv:[])}).({typ:Int; descr=Integer(2)})}
pat:{id:4; descr:[
Any]; accept:[id:177; descr:Any]; fv:[]};
body:{typ:Int, descr:{typ:
Int; descr= Var(0,x)}}})}}}], typ:Int -> Int, fv:[])}).({typ: Int; descr= Integer(2)})}
tests/typed/tests/misc/firsts.ref
View file @
78fa0667
{typ:(Int,Int); descr=({typ:X1 -> X1 where X1 = (Int,Int); descr=({typ:X1 -> X1 -> X1 where X1 = (Int,Int); descr=Abstraction(name:<none>,
iface:[((Int,Int), X1 -> X1 where X1 = (Int,Int))],
body:[typ:(Int,Int), accept:Pair, branches:
{typ: (Int,Int); descr= ({typ: X1 -> X1 where X1 = (Int,Int); descr= ({typ:
X1 -> X1 -> X1 where X1 = (Int,Int); descr= Abstraction(name:<none>,
iface:[(
(Int,Int), X1 -> X1 where X1 = (Int,Int))],
body:[typ:(Int,Int), accept:
Pair, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Pair; [(0, x)]; Times({id:5; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:180; descr:Any]; fv:[(0, x)]}, {id:4; descr:[Any; []; Constr(Any)]; accept:[id:179; descr:Any]; fv:[]})]; accept:[id:178; descr:Pair]; fv:[(0, x)]};
body:{typ:X1 -> X1 where X1 = (Int,Int), descr:{typ:X1 -> X1 where X1 = (Int,Int); descr=Abstraction(name:<none>,
iface:[((Int,Int), (Int,Int))],
pat:{id:3; descr:[(x,
Any)]; accept:[id:178; descr:Pair]; fv:[(0, x)]};
body:{typ:X1 -> X1 where
X1 = (Int,Int), descr:{typ:
X1 -> X1 where X1 = (Int,Int); descr= Abstraction(name:<none>,
iface:[(
(Int,Int), (Int,Int))],
body:[typ:(Int,Int), accept:Pair, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:6; descr:[Pair; [(0, y)]; Times({id:7; descr:[Any; [(0, y)]; Capture(0, y)]; accept:[id:182; descr:Any]; fv:[(0, y)]}, {id:4; descr:[Any; []; Constr(Any)]; accept:[id:179; descr:Any]; fv:[]})]; accept:[id:181; descr:Pair]; fv:[(0, y)]};
body:{typ:(Int,Int), descr:{typ:(Int,Int); descr=({typ:Int; descr=Var(0, x)}, {typ:Int; descr=Var(0, y)})}}}], typ:X1 -> X1 where X1 = (Int,Int), fv:[(0, x)])}}}], typ:X1 -> X1 -> X1 where X1 = (Int,Int), fv:[])}).({typ:(Int,Int); descr=({typ:Int; descr=Integer(2)}, {typ:Int; descr=Integer(3)})})}).({typ:(Int,Int); descr=({typ:Int; descr=Integer(1)}, {typ:Int; descr=Integer(5)})})}
pat:{id:6; descr:[(y,
Any)]; accept:[id:181; descr:Pair]; fv:[(0, y)]};
body:{typ:(Int,Int), descr:{typ:
(Int,Int); descr= ({typ: Int; descr= Var(0,x)}, {typ: Int; descr= Var(0,y)})}}}], typ:
X1 -> X1 where X1 = (Int,Int), fv:[(0, x)])}}}], typ:X1 -> X1 -> X1 where
X1 = (Int,Int), fv:[])}).({typ:
(Int,Int); descr= ({typ: Int; descr= Integer(2)}, {typ: Int; descr= Integer(3)})})}).({typ:
(Int,Int); descr= ({typ: Int; descr= Integer(1)}, {typ: Int; descr= Integer(5)})})}
tests/typed/tests/union/is_string.ref
View file @
78fa0667
{typ:([ Char* ] | Int | `true | `false) -> Bool; descr=Abstraction(name:<none>,
iface:[([ Char* ] | Int | `true | `false, Bool)],
body:[typ:[ Char* ] | Int | `true | `false, accept:Any, branches:
{typ: ([ Char* ] | Int | `true | `false) -> Bool; descr= Abstraction(name:<none>,
iface:[(
[ Char* ] | Int | `true | `false, Bool)],
body:[typ:[ Char* ] | Int | `true |
`false, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[String; []; Constr(String)]; accept:[id:177; descr:String]; fv:[]};
body:{typ:Bool, descr:{typ:Bool; descr=Atom(true)}}},
pat:{id:3; descr:[
String]; accept:[id:177; descr:String]; fv:[]};
body:{typ:Bool, descr:{typ:
Bool; descr= Atom(true)}}} ,
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Any; []; Constr(Any)]; accept:[id:178; descr:Any]; fv:[]};
body:{typ:Bool, descr:{typ:Bool; descr=Atom(false)}}}], typ:([ Char* ] | Int | `true | `false) -> Bool, fv:[])}
pat:{id:4; descr:[
Any]; accept:[id:178; descr:Any]; fv:[]};
body:{typ:Bool, descr:{typ:
Bool; descr= Atom(false)}}}], typ:([ Char* ] | Int | `true | `false) -> Bool, fv:[])}
tests/typed/tests/union/match.ref
View file @
78fa0667
{typ:X1 -> X1 where X1 = [ Char* ] | Int; descr=Abstraction(name:<none>,
iface:[([ Char* ] | Int, [ Char* ] | Int)],
body:[typ:[ Char* ] | Int, accept:Any, branches:
{typ: X1 -> X1 where X1 = [ Char* ] | Int; descr= Abstraction(name:<none>,
iface:[(
[ Char* ] | Int, [ Char* ] | Int)],
body:[typ:[ Char* ] | Int, accept:
Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:[ Char* ] | Int, descr:{typ:[ Char* ] | Int; descr=Match({typ:[ Char* ] | Int; descr=Var(0, x)},typ:[ Char* ] | Int, accept:[ Char* ] | Int, branches:
pat:{id:3; descr:[x]; accept:[id:176; descr:
Any]; fv:[(0, x)]};
body:{typ:[ Char* ] | Int, descr:{typ: [ Char* ] | Int; descr= Match({typ:
[ Char* ] | Int; descr= Var(0,x)},typ:[ Char* ] | Int, accept:[ Char* ] | Int, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Int; []; Constr(Int)]; accept:[id:177; descr:Int]; fv:[]};
body:{typ:[ Char* ] | Int, descr:{typ:[ Char* ] | Int; descr=Integer(2)}}},
pat:{id:4; descr:[
Int]; accept:[id:177; descr:Int]; fv:[]};
body:{typ:[ Char* ] | Int, descr:{typ:
[ Char* ] | Int; descr= Integer(2)}}} ,
{used:true; ghost:false; br_vars_empty:[];
pat:{id:5; descr:[String; []; Constr(String)]; accept:[id:178; descr:String]; fv:[]};
body:{typ:[ Char* ] | Int, descr:{typ:[ Char* ] | Int; descr="Piece of cake"}}})}}}], typ:X1 -> X1 where X1 = [ Char* ] | Int, fv:[])}
pat:{id:5; descr:[
String]; accept:[id:178; descr:String]; fv:[]};
body:{typ:[ Char* ] | Int, descr:{typ:
[ Char* ] | Int; descr= "Piece of cake"}}})}}}], typ:X1 -> X1 where
X1 = [ Char* ] | Int, fv:[])}
typing/typer.ml
View file @
78fa0667
...
...
@@ -919,8 +919,8 @@ and type_check' loc env ed constr precise = match ed with
(
ed
,
localize
loc
(
flatten
(
type_map
loc
env
true
e
b
)
constr
)
precise
)
|
Apply
(
e1
,
e2
)
->
let
t1
=
type_check
env
e1
Types
.
Arrow
.
any
true
in
let
t1
=
Types
.
Arrow
.
get
t1
in
let
t1
_t
=
type_check
env
e1
Types
.
Arrow
.
any
true
in
let
t1
=
Types
.
Arrow
.
get
t1
_t
in
let
dom
=
Types
.
Arrow
.
domain
t1
in
let
res
=
if
Types
.
Arrow
.
need_arg
t1
then
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment