Merge branch '123-unbound-variable-errors-are-hard-to-decipher' into 'dev'

Resolve "Unbound variable errors are hard to decipher"

Closes #123

See merge request ligolang/ligo!296
This commit is contained in:
Rémi Lesenechal 2020-01-03 16:14:19 +00:00
commit 90955c35b2
3 changed files with 8 additions and 6 deletions

View File

@ -327,9 +327,9 @@ let rec simpl_expression :
let%bind type_expr' = simpl_type_expression type_expr in
return @@ e_annotation ~loc expr' type_expr'
| EVar c ->
let c' = c.value in
let (c',loc) = r_split c in
(match constants c' with
| Error _ -> return @@ e_variable (Var.of_name c.value)
| Error _ -> return @@ e_variable ~loc (Var.of_name c.value)
| Ok (s,_) -> return @@ e_constant s [])
| ECall x -> (
let ((e1 , e2) , loc) = r_split x in

View File

@ -23,10 +23,11 @@ module Errors = struct
error ~data title message ()
let unbound_variable (e:environment) (n:I.expression_variable) (loc:Location.t) () =
let title = (thunk "unbound variable") in
let name () = Format.asprintf "%a" Stage_common.PP.name n in
let title = (thunk ("unbound variable "^(name ()))) in
let message () = "" in
let data = [
("variable" , fun () -> Format.asprintf "%a" Stage_common.PP.name n) ;
("variable" , name) ;
("environment" , fun () -> Format.asprintf "%a" Environment.PP.full_environment e) ;
("location" , fun () -> Format.asprintf "%a" Location.pp loc)
] in

View File

@ -30,10 +30,11 @@ module Errors = struct
error ~data title message ()
let unbound_variable (e:environment) (n:I.expression_variable) (loc:Location.t) () =
let title = (thunk "unbound variable") in
let name () = Format.asprintf "%a" Stage_common.PP.name n in
let title = (thunk ("unbound variable "^(name ()))) in
let message () = "" in
let data = [
("variable" , fun () -> Format.asprintf "%a" Stage_common.PP.name n) ;
("variable" , name) ;
("environment" , fun () -> Format.asprintf "%a" Environment.PP.full_environment e) ;
("location" , fun () -> Format.asprintf "%a" Location.pp loc)
] in