Merge branch 'fix-negative-pos-error' into 'dev'
Improve error handling of negative start positions. See merge request ligolang/ligo!321
This commit is contained in:
commit
3cfbd60cd2
@ -33,15 +33,22 @@ module Errors = struct
|
|||||||
file
|
file
|
||||||
in
|
in
|
||||||
let message () = str in
|
let message () = str in
|
||||||
let loc = Region.make
|
let loc = if start.pos_cnum = -1 then
|
||||||
|
Region.make
|
||||||
|
~start: Pos.min
|
||||||
|
~stop:(Pos.from_byte end_)
|
||||||
|
else
|
||||||
|
Region.make
|
||||||
~start:(Pos.from_byte start)
|
~start:(Pos.from_byte start)
|
||||||
~stop:(Pos.from_byte end_)
|
~stop:(Pos.from_byte end_)
|
||||||
in
|
in
|
||||||
let data = [
|
let data =
|
||||||
|
[
|
||||||
("parser_loc",
|
("parser_loc",
|
||||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc
|
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc
|
||||||
)
|
)
|
||||||
] in
|
]
|
||||||
|
in
|
||||||
error ~data title message
|
error ~data title message
|
||||||
|
|
||||||
let unrecognized_error source (start: Lexing.position) (end_: Lexing.position) lexbuf =
|
let unrecognized_error source (start: Lexing.position) (end_: Lexing.position) lexbuf =
|
||||||
|
@ -62,15 +62,22 @@ module Errors = struct
|
|||||||
file
|
file
|
||||||
in
|
in
|
||||||
let message () = str in
|
let message () = str in
|
||||||
let loc = Region.make
|
let loc = if start.pos_cnum = -1 then
|
||||||
|
Region.make
|
||||||
|
~start: Pos.min
|
||||||
|
~stop:(Pos.from_byte end_)
|
||||||
|
else
|
||||||
|
Region.make
|
||||||
~start:(Pos.from_byte start)
|
~start:(Pos.from_byte start)
|
||||||
~stop:(Pos.from_byte end_)
|
~stop:(Pos.from_byte end_)
|
||||||
in
|
in
|
||||||
let data = [
|
let data =
|
||||||
|
[
|
||||||
("parser_loc",
|
("parser_loc",
|
||||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc
|
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc
|
||||||
)
|
)
|
||||||
] in
|
]
|
||||||
|
in
|
||||||
error ~data title message
|
error ~data title message
|
||||||
|
|
||||||
let unrecognized_error source (start: Lexing.position) (end_: Lexing.position) lexbuf =
|
let unrecognized_error source (start: Lexing.position) (end_: Lexing.position) lexbuf =
|
||||||
|
@ -44,15 +44,22 @@ module Errors = struct
|
|||||||
file
|
file
|
||||||
in
|
in
|
||||||
let message () = str in
|
let message () = str in
|
||||||
let loc = Region.make
|
let loc = if start.pos_cnum = -1 then
|
||||||
|
Region.make
|
||||||
|
~start: Pos.min
|
||||||
|
~stop:(Pos.from_byte end_)
|
||||||
|
else
|
||||||
|
Region.make
|
||||||
~start:(Pos.from_byte start)
|
~start:(Pos.from_byte start)
|
||||||
~stop:(Pos.from_byte end_)
|
~stop:(Pos.from_byte end_)
|
||||||
in
|
in
|
||||||
let data = [
|
let data =
|
||||||
("location",
|
[
|
||||||
|
("parser_loc",
|
||||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc
|
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc
|
||||||
)
|
)
|
||||||
] in
|
]
|
||||||
|
in
|
||||||
error ~data title message
|
error ~data title message
|
||||||
|
|
||||||
let unrecognized_error source (start: Lexing.position) (end_: Lexing.position) lexbuf =
|
let unrecognized_error source (start: Lexing.position) (end_: Lexing.position) lexbuf =
|
||||||
|
Loading…
Reference in New Issue
Block a user