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

camlp4r loops when printing package type #5167

Closed
vicuna opened this issue Oct 19, 2010 · 4 comments
Closed

camlp4r loops when printing package type #5167

vicuna opened this issue Oct 19, 2010 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Oct 19, 2010

Original bug ID: 5167
Reporter: @garrigue
Assigned to: @xclerc
Status: closed (set by @xavierleroy on 2012-09-25T18:06:17Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.13.0+dev
Fixed in version: 3.12.1+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Monitored by: @hcarty

Bug description

When printing a package type, camlp4r enters an infinite loop.
The example here uses a branch, but the same error occurs with
vanilla 3.12.

tet-garrigue> ocaml dynlink.cma camlp4r.cma
Objective Caml version 3.13.0+dev2 (2010-10-18)

Camlp4 Parsing version 3.13.0+dev2 (2010-10-18)

module type S = sig type t; value x : t ; end;

module type S = sig type t = ; value x : t; end

value f (module M : S) = ();

value f :
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

@vicuna
Copy link
Author

vicuna commented Oct 27, 2010

Comment author: ertai

I don't know how to reproduce it with 3.12, all the following works well:

camlp4r -printer r -str '(module M : S);'
camlp4r -printer r -str '(module M : S.T with type t = u);'
camlp4r -printer r -str 'type t = (module S);'

Actually I just built the trunk (where you merged your branch) and this works fine:

./_build/camlp4/camlp4r.byte -printer r -str 'value f (module M : S) = ();'
value f ((module M) : (module S)) = ();

While it could be prettier by adding a special case for (module M : S).

@vicuna
Copy link
Author

vicuna commented Oct 27, 2010

Comment author: @garrigue

Using 3.12 syntax:

tet-garrigue> ocaml dynlink.cma camlp4r.cma
Objective Caml version 3.12.1+dev4 (2010-09-03)

Camlp4 Parsing version 3.12.1+dev4 (2010-09-03)

module type S = sig type t; value x : t ; end;

module type S = sig type t = ; value x : t; end

value f m = let module M = (value m : S) in ();

value f :
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

@vicuna
Copy link
Author

vicuna commented Oct 28, 2010

Comment author: ertai

Oh, I got it the bug is not in the Camlp4 pretty-printer as defined in Camlp4/Printers/OCamlr?.ml but in the toplevel value printer in Caml4Top/Rprint.ml. This module has two main flaws:

1/ it redefines a printer even if we already have one,
converting to the Camlp4 AST and then calling the pretty-printer would:

  • reuse code, to have only one pretty-printer in Camlp4
  • be less brittle w.r.t. changes in this data type.

2/ In the mean time, having at least one exhaustive pattern-matching
per syntactic class would help avoiding this problem again.

@vicuna
Copy link
Author

vicuna commented Feb 10, 2011

Comment author: @xclerc

fixed in branch "version/3.12"

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