-
Notifications
You must be signed in to change notification settings - Fork 15
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
Integer should be generated as an int32 #113
Comments
Thanks for filing this issue. In short, what you said is correct, and this is something that we were aware of when writing @bmoylan and I discussed this and determined there was a balance between correctness and usability, and initially opted on the side of usability. Generally, numeric values in a codebase are overwhelmingly of the type It was our opinion that, even if we made the generated type for a Conjure "integer" However, certainly open to updating the decision based on feedback/data. However, even if we do implement this, it will need to be opt-in until a major version change, as generated code will encounter compile failures if we change this. |
The issue is that for all numbers above This issue isn't one of aesthetics. If we e.g. wrap the encoding to generate the correct signed value for values > 2^31 that's fine. I don't have an opinion on code-base internals. But the generated wire format must match up. |
Chatted with @raiju directly. The most correct solution would certainly be to generate We could also consider a solution that would address just the wire format part for clients/servers. For example:
The set of those 3 steps together should be sufficient to ensure that our generated code never produces or accepts an out-of-bounds int over the wire. Note that this solution is also somewhat similar to #123 (comment), in that it involves generating custom marshal/unmarshal code that performs stricter verification against the standard. |
What happened?
The
integer
conjure type refers to a 32-bit signed integer. Go generates theint
type, which is a platform/arch dependent keyword. When run on a 64 bit system, it's usually equivalent toint64
(see https://tour.golang.org/basics/11).See the example yaml and the generated go code
What did you want to happen?
Generate an
int32
instead.The text was updated successfully, but these errors were encountered: