andrejbauer / plzoo

Programming Languages Zoo
MIT License
1.46k stars 80 forks source link

Lexer reports incorrect line numbers #22

Closed co-dan closed 5 years ago

co-dan commented 5 years ago

I think that the lexer in many languages does not handle line numbers correctly. For example, if I run miniml on the following program

let f = fun f (x : int) : int is x + 1 ;;
f false ;;

it reports

$ ./miniml.native test 
f : int -> int = <fun>
Type error at file "test", **line 1, charaters 44-49:**
This expression has type bool but is used as if it has type int

but the error is on the second line. To fix it, I believe, you need to manually update the line number in the lexbuf, as I've done in my fork of the repository. I can make a pull request if you agree that it's the right call to make this change in all the similar lexers.

andrejbauer commented 5 years ago

Yes please, submit a PR. This is a remnant of some very old code. Thanks!