better errors
This commit is contained in:
parent
b37962dee2
commit
4492c9b3ea
1 changed files with 6 additions and 9 deletions
|
@ -126,7 +126,7 @@ and synth_apply
|
|||
let given = synth_expression tenv x in
|
||||
check_equal_types x.position ~expected ~given;
|
||||
droit
|
||||
| _ -> failwith "Error: apply"
|
||||
| _ -> HopixTypes.type_error f.position "Can't apply"
|
||||
|
||||
and synth_record
|
||||
: HopixTypes.typing_environment
|
||||
|
@ -167,7 +167,7 @@ and synth_sequence
|
|||
=
|
||||
fun tenv elist ->
|
||||
match elist with
|
||||
| [] -> failwith "Error: sequence"
|
||||
| [] -> HopixTypes.type_error Position.dummy "Invalid sequence"
|
||||
| [ x ] -> synth_expression tenv x
|
||||
| x :: l ->
|
||||
let given = synth_expression tenv x in
|
||||
|
@ -261,12 +261,9 @@ and check_expression
|
|||
: HopixTypes.typing_environment -> HopixAST.expression Position.located
|
||||
-> HopixTypes.aty -> unit
|
||||
=
|
||||
fun env (Position.{ value = e; position = pos } as exp) expected ->
|
||||
match e with
|
||||
| Fun df -> failwith "Students! This is your job! (check_expression | Fun)"
|
||||
| _ ->
|
||||
let given = synth_expression env exp in
|
||||
check_equal_types pos ~expected ~given
|
||||
fun env (Position.{ position = pos } as exp) expected ->
|
||||
let given = synth_expression env exp in
|
||||
check_equal_types pos ~expected ~given
|
||||
|
||||
and check_value_definition
|
||||
: HopixTypes.typing_environment -> HopixAST.value_definition
|
||||
|
@ -275,7 +272,7 @@ and check_value_definition
|
|||
fun env -> function
|
||||
| SimpleValue (id, ty, ex) ->
|
||||
(match ty with
|
||||
| None -> failwith "A type is missing."
|
||||
| None -> HopixTypes.type_error ex.position "Type is missing"
|
||||
| Some ty' ->
|
||||
let tys, tenv = Position.located_pos (check_type_scheme env) ty' in
|
||||
check_expression tenv ex (HopixTypes.instantiate_type_scheme tys []);
|
||||
|
|
Reference in a new issue