-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix hash used by Attribute.get
#460
Conversation
Signed-off-by: Carl Eastlund <[email protected]>
Signed-off-by: Carl Eastlund <[email protected]>
Signed-off-by: Carl Eastlund <[email protected]>
Signed-off-by: Carl Eastlund <[email protected]>
Signed-off-by: Carl Eastlund <[email protected]>
a69431a
to
4a4198b
Compare
Signed-off-by: Carl Eastlund <[email protected]>
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!
Just to make sure I understand this correctly, this isn't specific to flags is it? The issue is that if an attribute present in the source tree was "ghosted" by a first ppx but consumed by a second one it wasn't correctly marked as seen because Attribute_table.remove
wouldn't find it.
Out of curiosity, what was the ppx chain that lead you to this bug? |
You are correct that this is not specific to flags. Flags just had a test that was easy to use for this purpose. As for what lead to this, someone here at jane street was working with a ppx, and if they ghosted their locations they got an attribute not used error, but if they didn't ghost the locations they got a location check error. So it was a catch 22, and this change is needed to resolve it. |
Signed-off-by: Carl Eastlund <[email protected]>
CHANGES: - Fix `Longident.parse` so it properly handles unparenthesized dotted operators such as `+.` or `*.`. (ocaml-ppx/ppxlib#111, @rgrinberg, @NathanReb) - raising an exception does no longer cancel the whole context free phase(ocaml-ppx/ppxlib#453, @Burnleydev1) - Sort embedded errors that are appended to the AST by location so the compiler reports the one closer to the beginning of the file first. (ocaml-ppx/ppxlib#463, @NathanReb) - Update `Attribute.get` to ignore `loc_ghost`. (ocaml-ppx/ppxlib#460, @ceastlund) - Add API to manipulate attributes that are used as flags (ocaml-ppx/ppxlib#408, @dianaoigo) - Update changelog to use ISO 8061 date format: YYYY-MM-DD. (ocaml-ppx/ppxlib#445, @ceastlund) - Replace `Caml` with `Stdlib`. (ocaml-ppx/ppxlib#427, @ceastlund) - When a transformation raises, the last valid AST is used as input to the upcoming transformations. All such errors are collected and appended as extension nodes to the final AST (ocaml-ppx/ppxlib#447, @Burnleydev1) - Fix a small mistake in the man pages: Embededding errors is done by default with `-as-pp`, not with `-dump-ast` (ocaml-ppx/ppxlib#464, @pitag-ha) - Set appropriate binary mode when writing to `stdout` especially for Windows compatibility. (ocaml-ppx/ppxlib#466, @jonahbeckford)
CHANGES: - Add an optional `embed_errors` argument to `Context_free.map_top_down` that controls how to deal with exceptions thrown by context-free rules. (ocaml-ppx/ppxlib#468, @NathanReb) - Fix `Longident.parse` so it properly handles unparenthesized dotted operators such as `+.` or `*.`. (ocaml-ppx/ppxlib#111, @rgrinberg, @NathanReb) - raising an exception does no longer cancel the whole context free phase(ocaml-ppx/ppxlib#453, @Burnleydev1) - Sort embedded errors that are appended to the AST by location so the compiler reports the one closer to the beginning of the file first. (ocaml-ppx/ppxlib#463, @NathanReb) - Update `Attribute.get` to ignore `loc_ghost`. (ocaml-ppx/ppxlib#460, @ceastlund) - Add API to manipulate attributes that are used as flags (ocaml-ppx/ppxlib#408, @dianaoigo) - Update changelog to use ISO 8061 date format: YYYY-MM-DD. (ocaml-ppx/ppxlib#445, @ceastlund) - Replace `Caml` with `Stdlib`. (ocaml-ppx/ppxlib#427, @ceastlund) - When a transformation raises, the last valid AST is used as input to the upcoming transformations. All such errors are collected and appended as extension nodes to the final AST (ocaml-ppx/ppxlib#447, @Burnleydev1) - Fix a small mistake in the man pages: Embededding errors is done by default with `-as-pp`, not with `-dump-ast` (ocaml-ppx/ppxlib#464, @pitag-ha) - Set appropriate binary mode when writing to `stdout` especially for Windows compatibility. (ocaml-ppx/ppxlib#466, @jonahbeckford)
CHANGES: - Add an optional `embed_errors` argument to `Context_free.map_top_down` that controls how to deal with exceptions thrown by context-free rules. (ocaml-ppx/ppxlib#468, @NathanReb) - Fix `Longident.parse` so it properly handles unparenthesized dotted operators such as `+.` or `*.`. (ocaml-ppx/ppxlib#111, @rgrinberg, @NathanReb) - raising an exception does no longer cancel the whole context free phase(ocaml-ppx/ppxlib#453, @Burnleydev1) - Sort embedded errors that are appended to the AST by location so the compiler reports the one closer to the beginning of the file first. (ocaml-ppx/ppxlib#463, @NathanReb) - Update `Attribute.get` to ignore `loc_ghost`. (ocaml-ppx/ppxlib#460, @ceastlund) - Add API to manipulate attributes that are used as flags (ocaml-ppx/ppxlib#408, @dianaoigo) - Update changelog to use ISO 8061 date format: YYYY-MM-DD. (ocaml-ppx/ppxlib#445, @ceastlund) - Replace `Caml` with `Stdlib`. (ocaml-ppx/ppxlib#427, @ceastlund) - When a transformation raises, the last valid AST is used as input to the upcoming transformations. All such errors are collected and appended as extension nodes to the final AST (ocaml-ppx/ppxlib#447, @Burnleydev1) - Fix a small mistake in the man pages: Embededding errors is done by default with `-as-pp`, not with `-dump-ast` (ocaml-ppx/ppxlib#464, @pitag-ha) - Set appropriate binary mode when writing to `stdout` especially for Windows compatibility. (ocaml-ppx/ppxlib#466, @jonahbeckford)
Updated
Attribute.get
andAttribute.has_flag
to ignoreloc_ghost
field of attribute locations. This allows flags to be used in code that is manipulated by other ppxes and hasloc_ghost
set tofalse
along the way, when the original attribute in the source file hadloc_ghost
set totrue
.The diff to the tests is probably slightly more readable commit-by-commit.