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
feat(compiler)!: Remove arbitrary per-file compiler flags, add acceptable options as module attributes #1804
Conversation
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.
Im loving how much cleaner this looks, looks like you forgot to run the formatter thats why the tests are failing the attribute looks a lot cleaner then the comment though.
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.
This is great ❤️ No shocker that I have opinions on the API. I'd also like to know if you can apply this to submodules in a file, since I think that would be :chefs-kiss:
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.
One comment and one question, but otherwise this looks good!
c035ccc
to
5f06640
Compare
3667416
to
685cb5f
Compare
74083da
to
667e25a
Compare
667e25a
to
85ca98e
Compare
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 to me :), one small question.
85ca98e
to
a6664bf
Compare
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.
@alex-snezhko this needs to be updated for the new formatter. We'll probably need locations on the module attributes to handle comments between them too.
86edd36
to
c3e4c0a
Compare
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.
Had a few questions, but overall looks great
// Comment after first attr | ||
@runtimeMode | ||
// Comment after second attr | ||
|
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.
Should this newline be removed so attributes are always "hugging" the module?
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.
This is the behavior for attributes on other items as well, maybe can address in a followup?
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.
Please open an issue
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.
Wait, you've added the formatter changes. You can just change the line ending. Right? We still need a follow up to fix the other ones though.
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.
Looked into this and I think it would require making some invasive changes to the print_comment_range
function to disallow double-breaks. I think we can just defer to #2055
@alex-snezhko since the location fix was landed in @ospencer's PR. Can you back out your changes/resolve conflicts here? |
6b8a360
to
1d7bad3
Compare
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.
Few more things
dc87d08
to
c20f159
Compare
c20f159
to
39aa39d
Compare
enter_attribute: (attribute, attribute_context) => unit, | ||
leave_attribute: (attribute, attribute_context) => unit, |
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.
I don't like that you removed these. We might want to iter attributes at some point
compiler/src/formatting/fmt.re
Outdated
~none=hardline, | ||
~lead=space, | ||
~trail=hardline, |
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.
I'm pretty sure that the ~none
and/or ~trail
being hardline here are causing your extra newline in the attributes.
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.
Doesn't look like that fixed it; I think it's the fact that print_comment_range
inserts phatom_hardline ++ phantom_hardline
since line_delta
> 1 between the comment and module header
enter_attribute: attribute => unit, | ||
leave_attribute: attribute => unit, |
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.
Can you put these back please? I don't see a reason to remove them
@@ -87,6 +83,7 @@ let iter_attributes = (hooks, attrs) => { | |||
|
|||
let rec iter_parsed_program = (hooks, {statements} as program) => { | |||
hooks.enter_parsed_program(program); | |||
iter_attributes(hooks, program.attributes); |
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.
What's going on here?
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.
What do you mean? It's iterating over the attributes in the same way done with expressions and toplevels
@@ -1,3 +1,9 @@ | |||
// Comment before first attr | |||
/* Block comment before attr */@noPervasives // Line comment on attr |
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.
This is wrong. It needs to have a space between */
and @
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 like in other places it actually puts the block comment on its own line, which I think I prefer here
Closes #1625