From e73c90113549c1fed3aa2513fc50217be5d81b51 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Mon, 30 Dec 2019 15:16:22 -0600 Subject: [PATCH] Show 'deepest' location for errors --- src/bin/expect_tests/typer_error_tests.ml | 2 +- src/main/display.ml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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