-
Notifications
You must be signed in to change notification settings - Fork 49
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
len attribute should be an int literal #265
Conversation
Closes mirage#264 This rejects things like `[@len ""]` and `[@len 1l]` which were previously silently ignored.
ppxlib has some combinators to avoid this kind of boilerplate - might be worth investigating if we split the ppx out of the main cstruct package. |
I'd be delighted to get a ppx/ppxlib port of ppx_cstruct.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except the request to tighten up the length parsing (unless that is done later -- in which case just having a test case for a negative length attribute would be great)
; _}])] -> | ||
Some (int_of_string sz) | ||
| [{txt = "len"; loc}, _ ] -> | ||
loc_err loc "[@len] argument should be an integer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loc_err loc "[@len] argument should be an integer" | |
loc_err loc "[@len] argument should be a positive, non-zero integer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are two check sites so I used this more specific version only when needed, how does that look?
Looks good to me! Unrelated to this PR, but the tests fail on 4.08 since ppx_cstruct generates references to stdlib. I'll fix that in a separate PR. |
Yes that's #263 - the environment variable should do it. Thanks! |
…uct-sexp and cstruct-lwt (5.1.0) CHANGES: - Do not issue deprecation warnings when using OCaml 4.08.0 and cstruct-ppx with enums due to `Pervasives` (mirage/ocaml-cstruct#269 @cypheon @hannesm) - Tighten parsing of the `[@len]` attribute to ensure it is a valid, positive integer (mirage/ocaml-cstruct#265 @emillon) - Update JavaScript bindings to latest `Js_of_ocaml` 3.5.0 interfaces (@hhugo mirage/ocaml-cstruct#268)
Closes #264
This rejects things like
[@len ""]
and[@len 1l]
which were previously silently ignored.