Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermixed output of Ocaml toplevel #7317

Closed
vicuna opened this issue Aug 4, 2016 · 1 comment
Closed

Intermixed output of Ocaml toplevel #7317

vicuna opened this issue Aug 4, 2016 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Aug 4, 2016

Original bug ID: 7317
Reporter: kosik
Status: resolved (set by @damiendoligez on 2016-11-08T10:43:41Z)
Resolution: won't fix
Priority: low
Severity: tweak
Version: 4.03.0
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: tools (ocaml{lex,yacc,dep,debug,...})

Bug description

In the shell, when I type:

echo 'module M1 =
struct
type t1 =
| V0
| V1
| V2
| V3
| V4
| V5
| V6
| V7
| V8
| V9
end

module M2 =
struct
type t2 = M1.t1 =
| V0
| V1
| V2
| V3
| V4
| V5
| V6
| V7777
| V8
| V9
end;;' | ocaml

I see this:

struct
type t1 = # module M1 =
structV0
type t1 =
| V0
| V1
| V2
| V3
| V4
| V5
| V6
| V7
| V8
| V9
endule M2 =
struct
module M2 = M1.t1 =
structV0
type t2 = M1.t1 =
| V0
| V1
| V2
| V3
| V4
| V5777
| V6
| V7777
| V8 ocaml
| V9l version 4.03.0
end;;
Error: This variant or record definition does not match that of type M1.t1
Fields number 8 have different names, V7 and V7777.

Which is strange.
It may be bug in my terminal
(I am able to reproduce this in "i3" as well as in "gnome-terminal")
or it may be a bug in the Ocaml toplevel itself
(if there is a correctly implemented terminal on which Ocaml toplevel's output looks properly).

Strange details are:

(1)

Why only first two lines are marked with ">" prefix?

(2)

Why do I see the following lines in the output:

  structV0

  | V5777

  | V8 ocaml

  | V9l version 4.03.0

?
@vicuna
Copy link
Author

vicuna commented Nov 8, 2016

Comment author: @damiendoligez

There is no bug here.

When the toplevel displays an error message, it does so by moving the cursor back up into the input to print underlined characters in the right place. This assumes that the input is already displayed in the terminal, but you are violating this assumption by using a pipe.

If you want to supply input to ocaml with a pipe instead of a terminal, I suggest that you set the TERM environment variable to "dumb", which will prevent ocaml from trying to overwrite its input on the display:

echo 'module M1 = ...
...' | TERM=dumb ocaml

@vicuna vicuna closed this as completed Nov 8, 2016
@vicuna vicuna added this to the 4.05.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant