propagate source-code locations to ast_typed

This commit is contained in:
Galfour 2019-05-28 17:02:40 +00:00
parent 5b42d72e41
commit 79af0abab3
4 changed files with 16 additions and 7 deletions

View File

@ -2,7 +2,13 @@ open Trace
open Types
let make_t type_value' simplified = { type_value' ; simplified }
let make_a_e expression type_annotation environment = { expression ; type_annotation ; dummy_field = () ; environment }
let make_a_e ?(location = Location.generated) expression type_annotation environment = {
expression ;
type_annotation ;
dummy_field = () ;
environment ;
location ;
}
let make_n_e name a_e = { name ; annotated_expression = a_e }
let make_n_t type_name type_value = { type_name ; type_value }

View File

@ -37,6 +37,7 @@ and annotated_expression = {
expression : expression ;
type_annotation : tv ;
environment : full_environment ;
location : Location.t ;
dummy_field : unit ;
}

View File

@ -204,7 +204,8 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a
match tv_opt with
| None -> ok ()
| Some tv' -> O.assert_type_value_eq (tv' , tv) in
ok @@ make_a_e expr tv e in
let location = Location.get_location ae in
ok @@ make_a_e ~location expr tv e in
let main_error =
let title () = "typing expression" in
let content () = Format.asprintf "Expression: %a\nLog: %s\n" I.PP.expression ae (L.get()) in

View File

@ -30,6 +30,7 @@ type 'a wrap = {
}
let wrap ?(loc = generated) wrap_content = { wrap_content ; location = loc }
let get_location x = x.location
let unwrap { wrap_content ; _ } = wrap_content
let map f x = { x with wrap_content = f x.wrap_content }
let pp_wrap f ppf { wrap_content ; _ } = Format.fprintf ppf "%a" f wrap_content