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
Closed

Camlp4 erases unused optional arguments #4522

vicuna opened this issue Mar 19, 2008 · 3 comments
Milestone

Comments

@vicuna
Copy link

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
Copy link
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 (camlp4o parses [3 lsl /2] as legal #4603, gramlib parses illegal input for recursive rules #4330,Preprocessor drops illegally used operators #4551, Camlp4 accepts incorrect syntax #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 (CamlP4 does not like patterns like: ?x:_ #4939) which was fixed in
    http://caml.inria.fr/cgi-bin/viewvc.cgi?view=revision&revision=11034

-- Max Mouratov

@vicuna
Copy link
Author

vicuna commented Aug 22, 2012

Comment author: @bobzhang

Should this be closed? I can not reproduce it

@vicuna
Copy link
Author

vicuna commented Sep 15, 2012

Comment author: @damiendoligez

As Max said, the problem is fixed since 3.12.0

@vicuna vicuna closed this as completed 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
dra27 pushed a commit to dra27/ocaml that referenced this issue Feb 27, 2021
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