forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix misplaced attribute warning when using external parser (and some …
…cleanup) (ocaml#101) * Attributes are now tracked for warning 53 even when using a ppx My previous rework of warning 53 actually made it so that, if using a serialized parsetree, NO attributes are tracked for this warning. * fix @poll and @noalloc to use the new misplaced attributes system
- Loading branch information
Showing
9 changed files
with
138 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Ast_mapper | ||
|
||
let replace_attr ({ Parsetree.attr_name; _} as attr) = | ||
{ attr with | ||
attr_name = | ||
if String.equal attr.attr_name.txt "test" then | ||
{ attr_name with txt = "immediate" } | ||
else attr_name | ||
} | ||
|
||
let () = | ||
register "test" (fun _ -> | ||
{ default_mapper with attribute = fun _ attr -> replace_attr attr }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
File "w53_with_ppx.ml", line 18, characters 13-17: | ||
18 | let x = 3 [@@test] | ||
^^^^ | ||
Warning 53 [misplaced-attribute]: the "immediate" attribute cannot appear in this context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(* TEST | ||
readonly_files = "w53_ppx.ml" | ||
include ocamlcommon | ||
* setup-ocamlc.byte-build-env | ||
** ocamlc.byte | ||
program = "${test_build_directory}/w53_ppx.exe" | ||
all_modules = "w53_ppx.ml" | ||
*** ocamlc.byte | ||
module = "w53_with_ppx.ml" | ||
flags = "-ppx ${program}" | ||
**** check-ocamlc.byte-output | ||
*) | ||
|
||
(* This test checks that compiler-builtin attributes inserted by a ppx still | ||
trigger the misplaced attribute warning if they are unused (and not if | ||
they are used). *) | ||
|
||
let x = 3 [@@test] | ||
|
||
type t = int [@@test] |