-
Notifications
You must be signed in to change notification settings - Fork 148
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
-dparsed
produces invalid BSV module function that takes another module as an argument
#663
Comments
Thanks for reporting these. There's been no effort to make sure that the pretty-printer for an entire BSV file will read back in correctly and identically, so I am not surprised if you find issues like this. The only concern was the printing of any snippets that appear in error messages to the user, which are usually just types, or IDs, or individual method calls. The The module type should be preserved. I assume that this is just a bug in
|
Thanks! And I certainly don't expect the pretty-printer to be 100% accurate in all cases. My use case is that I am generating very simple BSV code programmatically using the I'll give Line 165 in e4361d9
|
The BSV pretty-printer would print a function like this: ``` module [Module] helloWorld#(Module#(Empty) m)(Empty); let e <- m; endmodule ``` Without the `[Module]` bit, resulting in a function declaration that wouldn't typecheck. This patch makes a best-effort attempt to pretty-print this bit whenever possible. More specifically: * We check if the return type of a function is equal to `M ty`, where `M` is a type constructor like `Module`. If so, pretty-print `[M]`. * Otherwise, check if the return type is equal to `m ty`, where `m` is a type variable with a corresponding `IsModule#(m, c)` constraint. If so, pretty-print `[m]`. The `findModId` function is responsible for finding type variables like `m`. While investigating this issue, I noticed a bug in which `findModId` would drop the `IsModule#(m, c)` constraint in which `m` appears, which would cause the constraint not to be pretty-printed. I've fixed this bug as part of this patch. Fixes B-Lang-org#663.
Given this BSV code:
Compiling it with
bsc -dparsed=FooParsed.bsv Foo.bsv
yields:This is almost the same code, but there is one key difference: the
module
keyword lacks the[Module]
part after it. This change is significant enough to cause bsc to reject it:Any reason not to preserve the
[Module]
part?The text was updated successfully, but these errors were encountered: