-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Ocaml parser error are not meaningfull most of the time #5270
Description
Original bug ID: 5270
Reporter: nicolas_boulay
Status: acknowledged (set by @damiendoligez on 2012-06-27T13:08:03Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.12.0
Category: lexing and parsing
Child of: #5068
Monitored by: @gasche
Bug description
Ocaml parser did not give enought precise informations on typo error. If you forget a ';' or a 'in', the compilation finish with a "syntax error" pointing to the end of the file. The code shown is an example of code that can make loose a lot of time to debug, compare to typical other langage like java under Eclipse.
Don't forget that humain makes stupid mistakes :) Most of the time, this kind of code is debugged by commenting the code until it compiles.
There is also a problem on the type checker that gives the position of the first incoherency and not the "definition" place, where the bug could be. Both informations is needed most of the time. To debug this, each the "definition" place should be guess and verified4.
This unfriendliness behavior of the tools is a real pain for beginners.
Additional information
type val_t =
| Int32 of Int32.t
| Int24 of int
| Int16 of int
| Int8 of int
| String of string
type df_t = {
mutable h: (val_t * string) list
mutable is_reverted: bool
}
(*
/!\ This list is used backward to be in 0(1) at the insertion. Then
everything as to be revert before printing.
*)
let add_last (ctx:df_t) (comment:string) (x:val_t) =
assert (not ctx.is_reverted);
ctx.is_reverted <- false;
ctx.h <- (x,comment)::ctx.h
let revert_before_printing (ctx:df_t) =
assert (not ctx.is_reverted);
ctx.is_reverted <- true;
ctx.h <- List.rev ctx.h
let add_df_footer ctx =
add_last ctx Int8(0x0E) "FOOTER";
add_last ctx Int24(0x000000) "UnusedPad"