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
|
let given = synth_expression tenv x in
|
||||||
check_equal_types x.position ~expected ~given;
|
check_equal_types x.position ~expected ~given;
|
||||||
droit
|
droit
|
||||||
| _ -> failwith "Error: apply"
|
| _ -> HopixTypes.type_error f.position "Can't apply"
|
||||||
|
|
||||||
and synth_record
|
and synth_record
|
||||||
: HopixTypes.typing_environment
|
: HopixTypes.typing_environment
|
||||||
|
@ -167,7 +167,7 @@ and synth_sequence
|
||||||
=
|
=
|
||||||
fun tenv elist ->
|
fun tenv elist ->
|
||||||
match elist with
|
match elist with
|
||||||
| [] -> failwith "Error: sequence"
|
| [] -> HopixTypes.type_error Position.dummy "Invalid sequence"
|
||||||
| [ x ] -> synth_expression tenv x
|
| [ x ] -> synth_expression tenv x
|
||||||
| x :: l ->
|
| x :: l ->
|
||||||
let given = synth_expression tenv x in
|
let given = synth_expression tenv x in
|
||||||
|
@ -261,10 +261,7 @@ and check_expression
|
||||||
: HopixTypes.typing_environment -> HopixAST.expression Position.located
|
: HopixTypes.typing_environment -> HopixAST.expression Position.located
|
||||||
-> HopixTypes.aty -> unit
|
-> HopixTypes.aty -> unit
|
||||||
=
|
=
|
||||||
fun env (Position.{ value = e; position = pos } as exp) expected ->
|
fun env (Position.{ 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
|
let given = synth_expression env exp in
|
||||||
check_equal_types pos ~expected ~given
|
check_equal_types pos ~expected ~given
|
||||||
|
|
||||||
|
@ -275,7 +272,7 @@ and check_value_definition
|
||||||
fun env -> function
|
fun env -> function
|
||||||
| SimpleValue (id, ty, ex) ->
|
| SimpleValue (id, ty, ex) ->
|
||||||
(match ty with
|
(match ty with
|
||||||
| None -> failwith "A type is missing."
|
| None -> HopixTypes.type_error ex.position "Type is missing"
|
||||||
| Some ty' ->
|
| Some ty' ->
|
||||||
let tys, tenv = Position.located_pos (check_type_scheme env) ty' in
|
let tys, tenv = Position.located_pos (check_type_scheme env) ty' in
|
||||||
check_expression tenv ex (HopixTypes.instantiate_type_scheme tys []);
|
check_expression tenv ex (HopixTypes.instantiate_type_scheme tys []);
|
||||||
|
|
Reference in a new issue