All typer errors in ast_typed/misc.ml are covered it seems.
This commit is contained in:
parent
f7616b7b49
commit
e5acdc4228
@ -16,4 +16,10 @@ let%expect_test _ =
|
|||||||
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_5.mligo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_5.mligo" ; "main" ] ;
|
||||||
[%expect {| ligo: unbound type variable: {"variable":"boolean","in":"- E[]\tT[] ]","did_you_mean":"bool"} |} ] ;
|
[%expect {| ligo: unbound type variable: {"variable":"boolean","in":"- E[]\tT[] ]","did_you_mean":"bool"} |} ] ;
|
||||||
|
|
||||||
|
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_6.mligo" ; "main" ] ;
|
||||||
|
[%expect {| ligo: in file "error_typer_6.mligo", line 1, characters 30-64. different type constructors: Expected these two constant type constructors to be the same, but they're different {"a":"string","b":"bool"} |} ] ;
|
||||||
|
|
||||||
|
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_7.mligo" ; "main" ] ;
|
||||||
|
[%expect {| ligo: in file "error_typer_7.mligo", line 4, characters 17-56. records have different sizes: Expected these two types to be the same, but they're different (both are records, but with a different number of arguments) {"a":"record[b -> string , a -> int]","b":"record[c -> bool , b -> string , a -> int]"} |} ] ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ module Errors = struct
|
|||||||
|
|
||||||
let different_types name a b () =
|
let different_types name a b () =
|
||||||
let title () = name ^ " are different" in
|
let title () = name ^ " are different" in
|
||||||
let message () = "" in
|
let message () = "Expected these two types to be the same, but they're different" in
|
||||||
let data = [
|
let data = [
|
||||||
("a" , fun () -> Format.asprintf "%a" PP.type_value a) ;
|
("a" , fun () -> Format.asprintf "%a" PP.type_value a) ;
|
||||||
("b" , fun () -> Format.asprintf "%a" PP.type_value b )
|
("b" , fun () -> Format.asprintf "%a" PP.type_value b )
|
||||||
@ -321,7 +321,7 @@ let rec assert_type_value_eq (a, b: (type_value * type_value)) : unit result = m
|
|||||||
| TC_big_map (ka,va), TC_big_map (kb,vb) -> ok @@ ([ka;va] ,[kb;vb])
|
| TC_big_map (ka,va), TC_big_map (kb,vb) -> ok @@ ([ka;va] ,[kb;vb])
|
||||||
| _,_ -> fail @@ different_operators opa opb
|
| _,_ -> fail @@ different_operators opa opb
|
||||||
in
|
in
|
||||||
trace (different_types "constant sub-expression" a b)
|
trace (different_types "arguments to type operators" a b)
|
||||||
@@ bind_list_iter (fun (a,b) -> assert_type_value_eq (a,b) )(List.combine lsta lstb)
|
@@ bind_list_iter (fun (a,b) -> assert_type_value_eq (a,b) )(List.combine lsta lstb)
|
||||||
)
|
)
|
||||||
| T_operator _, _ -> fail @@ different_kinds a b
|
| T_operator _, _ -> fail @@ different_kinds a b
|
||||||
|
3
src/test/contracts/negative/error_typer_6.mligo
Normal file
3
src/test/contracts/negative/error_typer_6.mligo
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let foo : (int, string) map = (Map.literal [] : (int, bool) map)
|
||||||
|
let main (p:int) (storage : int) =
|
||||||
|
(([] : operation list) , p)
|
7
src/test/contracts/negative/error_typer_7.mligo
Normal file
7
src/test/contracts/negative/error_typer_7.mligo
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
type toto = { a : int ; b : string }
|
||||||
|
type tata = { a : int ; }
|
||||||
|
|
||||||
|
let foo : tata = ({a = 1 ; b = "foo" ; c = true} : toto)
|
||||||
|
|
||||||
|
let main (p:int) (storage : int) =
|
||||||
|
(([] : operation list) , p + foo.a)
|
Loading…
Reference in New Issue
Block a user