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 fails to preprocess correctly valid object oriented OCaml #4673

Closed
vicuna opened this issue Dec 16, 2008 · 3 comments
Closed

camlp4 fails to preprocess correctly valid object oriented OCaml #4673

vicuna opened this issue Dec 16, 2008 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Dec 16, 2008

Original bug ID: 4673
Reporter: avaron
Assigned to: @xclerc
Status: closed (set by @xavierleroy on 2012-09-25T18:06:17Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11.0+beta
Fixed in version: 3.12.1+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Duplicate of: #5144
Monitored by: delroth avaron @ygrek @yallop @hcarty "Richard Jones"

Bug description

The following tiny file:


(* test.ml *)

class test (x : int) = object
val a = x;
val b = x;
method clone = ({< a = x; b = x>})
end

compiles correctly with OCaml 3.10.2, OCaml 3.11.0, and when the preprocessor is camlp4 3.10.2.

However, when the preprocessors is camlp4 3.11.0 it fails:

samson:~ andres$ ocamlc -pp 'camlp4orf pa_extend.cmo' test.ml
File "test.ml", line 4, characters 27-28:
Warning S: this expression should have type unit.
File "test.ml", line 4, characters 30-35:
Error: This expression has type bool but is here used with type int

The problem is the {< ...; .... >} which is valid. A single assignment as in {< x = 4 >} would be preprocessed correctly.

File attachments

@vicuna
Copy link
Author

vicuna commented Dec 16, 2008

Comment author: avaron

The following is the way camlp4 is interpreting the class definition:

samson:~ andres$ camlp4orf pr_r.cmo test.ml
class test (x : int) =
object value a = x; value b = x; method clone = {< a = (x; b = x); >}; end;

@vicuna
Copy link
Author

vicuna commented Jun 1, 2009

Comment author: bluestorm

I attached a tentative bugfix, wich I also uploaded at http://bluestorm.info/camlp4/objcopy-fix/Camlp4OCamlRevisedParser.ml.diff

I also wrote a small extension for a quick workaround : http://bluestorm.info/camlp4/objcopy-fix/list.php

@vicuna
Copy link
Author

vicuna commented Feb 15, 2011

Comment author: @xclerc

Provided patch tested and applied -- thanks.

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