utop icon indicating copy to clipboard operation
utop copied to clipboard

UTop rejects line/filename directive

Open drvink opened this issue 7 years ago • 3 comments

In the standard OCaml toplevel, the following works, and is very useful when debugging e.g. ppx-related issues:

# # 123 "blarg"
;;
# (* lexer has set line/position and filename as of now *)

UTop rejects this, even with UTop.smart_accept := false. I've looked over the OCaml toplevel vs. UTop's code for a few hours now and I don't have the slightest clue how to make this work, even though it's obvious from looking at parsing/lexer.mll where the OCaml lexer handles this.

drvink avatar Jan 21 '18 18:01 drvink

~Never mind. It works if you do this in UTop:~

utop[0]# # 123 "blarg"
;;
utop[1]# (* success ! *)

drvink avatar Jan 21 '18 19:01 drvink

Wait, no, I was right the first time. It doesn't work. The file name reported by e.g. ppx_expect when I use let%expect_test at the toplevel uses my value in the OCaml toplevel, but not in UTop. (I have modified the code to some of the Jane Street ppx stuff to make this work, and I would like to contribute it or discuss it later, but in the meantime, this UTop issue needs fixing.)

drvink avatar Jan 21 '18 19:01 drvink

Yes, utop behaves differently in this regard. It has been so long I can't remember the details.

(I have modified the code to some of the Jane Street ppx stuff to make this work, and I would like to contribute it or discuss it later, but in the meantime, this UTop issue needs fixing.)

Ah, we are currently working with @rgrinberg on adding support for inline/expect tests in dune (https://github.com/ocaml/dune/pull/338). I started some work in the jbuilder branch of janestreet/ppx_inline_test and janestreet/ppx_expect to fix some issues. It might be worth comparing what we have.

ghost avatar Jan 22 '18 11:01 ghost