-
Notifications
You must be signed in to change notification settings - Fork 44
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
Constants-merging produces incorrect top-level module #227
Comments
@jparise I'm not able to reproduce this yet. I added the following test to binary_protocol_test.exs and it passes:
(Also tried swapping the order of the two files - still passes) |
OK, I'm getting somewhere. I can get the includee to generate constant macros where it should not, but it's still not overwriting anything else. Updated test case:
The last |
I can try to come up with a simple-ish fix here, but I think the underlying problem is more complex. We end up writing out code for every time that a particular file is parsed. It was never a problem before because the operation is basically idempotent - if we parsed a file that defined I think. I'm still trying to fully grok the parse/generate code, but I know that if I put some debug printing in the generate functions, they get triggered multiple times with the same constants but originating from multiple files. This could also explain what you're seeing, @jparise, it could depend on how the list of files gets ordered. It seems like the real solution would be to make a single pass over the files and generate a single unified schema, but that would be a pretty big change. I think I can fix this particular problem by only generating constants when the |
I'm in the same situation with regard to fully understanding the parser and generator, to be honest. But I also definitely encountered the same issue where included files are (re)written multiple times based on the set of input files. You can see that explicitly when you run I would like us to address this at a fundamental level, which may mean a redesign of the |
Also, my more immediate concern is about the constants being written to the including file's module. In my test case, we wouldn't have written anything to that module anyway, so the "overwrite" case might be a distraction and ultimately more of a systematic issue with the way we (re)write output files. |
So what I'm hearing is "yes, there is an underlying issue here but let's at least try to fix the reported bug first"? I'm good with that as long as we make a ticket to capture the underlying issue.
… On Feb 10, 2017, at 3:37 PM, Jon Parise ***@***.***> wrote:
Also, my more immediate concern is about the constants being written to the including file's module. In my test case, we wouldn't have written anything to that module anyway, so the "overwrite" case might be a distraction and ultimately more of a systematic issue with the way we (re)write output files.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I believe the constants-merging code from #224 might be breaking the generation of code that follows this pattern:
a.thrift
defines a bunch of things, including structs and a service.a.thrift
also includesb.thrift
.b.thrift
defines some constants.This results in the top-level module produced by
a.thrift
(A
) containing only the constants fromb.thrift
.This results in an
a.ex
(defmodule(A)
) containing the constant and afoo.ex
containingstruct Foo
. I would have expected the constant to be written to ab.ex
(defmodule(B)
) instead.The text was updated successfully, but these errors were encountered: