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

behavior of piqi tool and generated ocaml is inconsistent #9

Closed
eriklovlie opened this issue Feb 28, 2016 · 4 comments
Closed

behavior of piqi tool and generated ocaml is inconsistent #9

eriklovlie opened this issue Feb 28, 2016 · 4 comments
Labels

Comments

@eriklovlie
Copy link

Given this schema:

.record [
  .name foo
]

.record [
  .name bar
  .field [ .type int ]
]

.variant [
  .name e
  .option [ .type foo ]
  .option [ .type bar ]
]

.record [
  .name d
  .field [ .name name1 .type e ]
  .field [ .name name2 .type e ]
]

.list [
  .name c
  .type d
]

.record [
  .name thing
  .field [ .name items .type c ]
]

.list [
  .name root
  .type thing
]

And this input file:

[
[
  .items [
    [
      .foo
      .bar [ 0 ]
    ]
  ]
]
]

The following command does not report a problem.

piqi check --type path/to/schema/root test.piq

But ocaml code generated as follows produces the below exception:

piqic-ocaml -C path/to/schema --ext path/to/schema/root.piqi


Uncaught exception:

  Piqirun.Error(-1, "block expected")

Placing an empty pair of brackets after foo in the input file appears to resolve the problem. I've only just started using piqi, but I would think at least the inconsistent parsing behavior would be an issue worthy of a look.

@eriklovlie
Copy link
Author

I should say that I'm using piqic-ocaml version 0.7.4, installed from opam.

@alavrik
Copy link
Owner

alavrik commented Feb 29, 2016

This is a bug. Thanks for reporting it. This input is invalid without extra brackets after .foo. piqi convert should have failed as well. Give me a day or two and I'll get it fixed. Once fixed the obscure uncaught exception should go away.

@alavrik alavrik added the bug label Feb 29, 2016
@eriklovlie
Copy link
Author

No problem. I'm not blocked by this so no rush. In fact I think what I really wanted for the foo variant option was just a .option [ .name foo ], since there's no data associated with it anyway. That removes the need for an empty list and everything seems fine.

@alavrik
Copy link
Owner

alavrik commented Jun 2, 2016

the fix is included in piqilib-0.6.13 and avilable via opam

@alavrik alavrik closed this as completed Jun 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants