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

Camlp4 erases unused optional arguments #4522

Closed
vicuna opened this Issue Mar 19, 2008 · 3 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

vicuna commented Mar 19, 2008

Original bug ID: 4522
Reporter: @mmottl
Status: closed (set by @damiendoligez on 2012-09-15T10:31:05Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.1
Target version: 4.00.1+dev
Fixed in version: 3.12.0
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Monitored by: @murmour @mmottl

Bug description

The following valid code cannot be compiled when preprocessed with Camlp4:

module type S = sig val f : ?x : 'a -> unit -> unit end
module M : S = struct let f ?x:_ () = () end

Compiler output (with ocamlc -pp camlp4o foo.ml):

File "foo.ml", line 2, characters 15-44:
Signature mismatch:
Modules do not match: sig val f : 'a -> unit -> unit end is not included in S
Values do not match:
val f : 'a -> unit -> unit
is not included in
val f : ?x:'a -> unit -> unit

The label of the ignored optional argument obviously got deleted by Camlp4 as evidenced by the output when pretty-printing with "camlp4o -printer o foo.ml":

module type S = sig val f : ?x: 'a -> unit -> unit end
module M : S = struct let f _ () = () end

Regards,
Markus

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 15, 2012

Comment author: @murmour

The problem with optional arguments in the original syntax is fixed in OCaml 3.12 and was caused by:

  1. An old bug in the camlp4 parsing engine (#4603, #4330,#4551, #4513) which was fixed by ertai in
    http://caml.inria.fr/cgi-bin/viewvc.cgi?view=revision&revision=9053
  2. A bug in Camlp4OCamlParser.ml (#4939) which was fixed in
    http://caml.inria.fr/cgi-bin/viewvc.cgi?view=revision&revision=11034

-- Max Mouratov

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Aug 22, 2012

Comment author: @bobzhang

Should this be closed? I can not reproduce it

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Sep 15, 2012

Comment author: @damiendoligez

As Max said, the problem is fixed since 3.12.0

@vicuna vicuna closed this Sep 15, 2012

@vicuna vicuna added the camlp4 label Mar 14, 2019

@vicuna vicuna added this to the 4.00.1 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.