-
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
Generated code does not compile if Conjure definition references type in a package where last element is of the form "v[0-9]+" #405
Comments
I've determined the cause is the following:
The result is that, on the first generation, there is no import for packages of the form However, when the generator is run again (with the non-compiling generated code still present), at step 4, searching for the package locally does yield a result (because the package has been generated), and then the import code finds the proper package name and does not remove the import. The result is that, when run a second time, the import is not removed and the code compiles. The proper fix here is to set the |
Makes it such that the "ptimports.Process" call on generated code does not add or remove imports. Fixes an issue where generated code would not include imports that referenced packages where the last component of the package path was of the form "v[0-9]+". Fixes #405
Follow-up on the above. Setting "FormatOnly" to "true" does result in correct code being generated. However, when
For example, for the import The issue here is that, if the output of Taking all of this into account, the most effective approach is to run |
Re-opening this issue because the current solution ran into problems when deployed. Documenting the issues here so that the next attempt at a solution incorporates this. The solution in #406 works by updating the However, the "verify" functionality of Basically, the usage in The most ideal solution would be to formalize this contract and fix the behavior of The other solution would be to declare that it cannot be assumed that the output of |
What happened?
When I generated Conjure output files for a definition that defined a type in a package that ended in "v2" (
com.palantir.test.v2
) and an object in a different package that referenced that type, the generated code did not initially compile.Running the generator again (after the initial non-compiling code was generated) added the proper import statement, after which the code compiled as expected.
The initial behavior is incorrect (running the generator for a valid definition should create valid code), and the fact that running the same Conjure generation operation again generates different code that fixes the issue is unintuitive (the generator is expected to be idempotent).
Example Conjure definition:
IR for the definition:
Initial lines of output of first run (at
common/structs.conjure.go
):Initial lines of output of second run (at
common/structs.conjure.go
):What did you want to happen?
The output of the first run should produce compiling code (have the proper imports) and running the command multiple times should not change the generated code.
The text was updated successfully, but these errors were encountered: