Merge branch 'feature/deep-location' into 'dev'
Show 'deepest' location for errors See merge request ligolang/ligo!288
This commit is contained in:
commit
6b54f43f86
@ -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]"} |} ] ;
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user