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

message to message alias #27

Open
ygrek opened this issue Jul 8, 2017 · 3 comments
Open

message to message alias #27

ygrek opened this issue Jul 8, 2017 · 3 comments

Comments

@ygrek
Copy link
Contributor

ygrek commented Jul 8, 2017

It appears extprot accepts message alias to message, but generates bad code. This possibility is not documented afaik, not sure if it should be fixed or forbidden, I stumbled on this accidentaly.
Consider :

$ cat a.proto 
message m1 = { a : int }
message m2 = M1.m1
$ ./compiler/extprotc a.proto -o /dev/stdout   |grep M1
module M1 =
        [ ("M1.a", (Extprot.Pretty_print.pp_field (fun t -> t.a) Extprot.Pretty_print.pp_int)) ] pp;;
    type _m2 = M1.M1.m1;;
    type m2 = M1.M1.m1;;
    let m2_default = ref (fun () -> !M1.M1.m1_default ());;
    let pp_m2 pp = M1.M1.pp_m1 pp;;
    let read_m2 s = M1.M1.read_m1 s;;
    let io_read_m2 s = M1.M1.io_read_m1 s;;
    let write_m2 b msg = M1.M1.write_m1 b msg;;
@mfp
Copy link
Owner

mfp commented Jul 8, 2017 via email

@ygrek
Copy link
Contributor Author

ygrek commented Jul 9, 2017

I am confused because there is Message_alias in Ptypes.message_expr which is only produced by <UIDENT>+.<LIDENT> rule, but then generates this slightly broken code. And there is nothing about aliases in doc, but there is some code to handle them.
I would expect a syntax of message m1 = xxx message m2 = m1 to work, but this currently only works when m1 is a type. This is not a big problem by itself, because can be workarounded with type t1 = xxx message m1 = t1 message m2 = t1, it is just that types in code make me think it was intended to be another way.

@mfp
Copy link
Owner

mfp commented Jul 11, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants