diff --git a/src/bin/expect_tests/typer_error_tests.ml b/src/bin/expect_tests/typer_error_tests.ml index 6ecae91e7..45146c911 100644 --- a/src/bin/expect_tests/typer_error_tests.ml +++ b/src/bin/expect_tests/typer_error_tests.ml @@ -20,6 +20,6 @@ let%expect_test _ = [%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]"} |} ] ; + [%expect {| ligo: in file "error_typer_7.mligo", line 4, characters 18-48. 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]"} |} ] ; diff --git a/src/main/display.ml b/src/main/display.ml index 991f7c2cc..9bea4ca56 100644 --- a/src/main/display.ml +++ b/src/main/display.ml @@ -34,12 +34,12 @@ let rec error_pp ?(dev = false) out (e : error) = | x -> [ x ] in let location = let opt = e |> member "data" |> member "location" |> string in - let aux prec cur = + let aux cur prec = match prec with | None -> cur |> member "data" |> member "location" |> string | Some s -> Some s in - match List.fold_left aux opt infos with + match List.fold_right aux infos opt with | None -> "" | Some s -> s ^ ". " in diff --git a/src/passes/1-parser/reasonligo.ml b/src/passes/1-parser/reasonligo.ml index 77c2e8e42..dbf28b756 100644 --- a/src/passes/1-parser/reasonligo.ml +++ b/src/passes/1-parser/reasonligo.ml @@ -24,7 +24,7 @@ module Errors = struct let message () = "" in let expression_loc = AST.expr_to_region expr in let data = [ - ("expression_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ expression_loc) ] in error ~data title message @@ -37,7 +37,7 @@ module Errors = struct ~stop:(Pos.from_byte end_) in let data = [ - ("parser_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ loc ) ] in @@ -51,7 +51,7 @@ module Errors = struct ~stop:(Pos.from_byte end_) in let data = [ - ("unrecognized_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ loc ) ] in diff --git a/src/passes/2-simplify/cameligo.ml b/src/passes/2-simplify/cameligo.ml index 7dbb027d7..5be02f4bf 100644 --- a/src/passes/2-simplify/cameligo.ml +++ b/src/passes/2-simplify/cameligo.ml @@ -32,7 +32,7 @@ module Errors = struct in let data = [ ("expected", fun () -> expected_name); - ("actual_loc" , fun () -> Format.asprintf "%a" Location.pp_lift @@ Raw.pattern_to_region actual) + ("location" , fun () -> Format.asprintf "%a" Location.pp_lift @@ Raw.pattern_to_region actual) ] in error ~data title message @@ -43,7 +43,7 @@ module Errors = struct List.fold_left (fun a p -> Region.cover a (Raw.pattern_to_region p)) Region.ghost patterns in let data = [ - ("loc", fun () -> Format.asprintf "%a" Location.pp_lift @@ patterns_loc) + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ patterns_loc) ] in error ~data title message @@ -52,7 +52,7 @@ module Errors = struct let message () = Format.asprintf "unknown predefined type \"%s\"" name.Region.value in let data = [ - ("typename_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ name.Region.region) ] in error ~data title message @@ -63,7 +63,7 @@ module Errors = struct Format.asprintf "untyped function parameters are not supported yet" in let param_loc = var.Region.region in let data = [ - ("param_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ param_loc) ] in error ~data title message @@ -74,7 +74,7 @@ module Errors = struct Format.asprintf "tuple patterns are not supported yet" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -85,7 +85,7 @@ module Errors = struct Format.asprintf "constant constructors are not supported yet" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -97,7 +97,7 @@ module Errors = struct are not supported yet" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -119,7 +119,7 @@ module Errors = struct Format.asprintf "currently, only constructors are supported in patterns" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -130,7 +130,7 @@ module Errors = struct Format.asprintf "currently, only empty lists and constructors (::) \ are supported in patterns" in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ region) ] in error ~data title message diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index 0707ee85a..4f9e92deb 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -72,7 +72,7 @@ module Errors = struct Format.asprintf "constant constructors are not supported yet" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -104,7 +104,7 @@ module Errors = struct let message () = Format.asprintf "unknown predefined type \"%s\"" name.Region.value in let data = [ - ("typename_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ name.Region.region) ] in error ~data title message @@ -116,7 +116,7 @@ module Errors = struct are not supported yet" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -127,7 +127,7 @@ module Errors = struct Format.asprintf "currently, only constructors are supported in patterns" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -138,7 +138,7 @@ module Errors = struct Format.asprintf "tuple patterns are not supported yet" in let pattern_loc = Raw.pattern_to_region p in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ; (** TODO: The labelled arguments should be flowing from the CLI. *) ("pattern", @@ -154,7 +154,7 @@ module Errors = struct in patterns are supported" in let pattern_loc = Raw.pattern_to_region pattern in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ pattern_loc) ] in error ~data title message @@ -165,7 +165,7 @@ module Errors = struct Format.asprintf "currently, only empty lists and x::y \ are supported in patterns" in let data = [ - ("pattern_loc", + ("location", fun () -> Format.asprintf "%a" Location.pp_lift @@ cons.Region.region) ] in error ~data title message @@ -174,7 +174,7 @@ module Errors = struct let title () = "unexpected anonymous function" in let message () = "you provided a function declaration without name" in let data = [ - ("loc" , fun () -> Format.asprintf "%a" Location.pp @@ loc) + ("location" , fun () -> Format.asprintf "%a" Location.pp @@ loc) ] in error ~data title message @@ -182,7 +182,7 @@ module Errors = struct let title () = "unexpected named function" in let message () = "you provided a function expression with a name (remove it)" in let data = [ - ("loc" , fun () -> Format.asprintf "%a" Location.pp @@ loc) + ("location" , fun () -> Format.asprintf "%a" Location.pp @@ loc) ] in error ~data title message