Skip to content

Commit 30c462a

Browse files
committed
Mark @as used early in constructor declarations, and turn on unused check.
A couple of test files were mis-using `@as`.
1 parent fb0fc96 commit 30c462a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

jscomp/frontend/bs_ast_invariant.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
*)
2929
let is_bs_attribute txt =
3030
match txt with
31-
(* TODO #6636: | "as "| "int" *)
32-
| "bs" | "config" | "ignore" | "optional" | "string" | "uncurry" | "unwrap" ->
31+
(* TODO #6636: "int" *)
32+
| "as" | "bs" | "config" | "ignore" | "optional" | "string" | "uncurry" | "unwrap" ->
3333
true
3434
| _ -> false
3535

@@ -113,6 +113,10 @@ let emit_external_warnings : iterator =
113113
super.label_declaration self lbl);
114114
constructor_declaration =
115115
(fun self ({pcd_name = {txt; loc}} as ctr) ->
116+
let _ =
117+
Ast_untagged_variants.process_tag_type
118+
ctr.pcd_attributes (* mark @as used in variant cases *)
119+
in
116120
(match txt with
117121
| "false" | "true" | "()" ->
118122
Location.raise_errorf ~loc "%s can not be redefined " txt

jscomp/test/AsInUncurriedExternals.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ let mo = makeOptions
1212

1313
let options = mo(~name="foo", ())
1414

15-
let shouldNotFail: (~objectMode: @as(json`false`) _, ~name: string) => int = (~objectMode, ~name) =>
15+
let shouldNotFail: (~objectMode: _, ~name: string) => int = (~objectMode, ~name) =>
1616
3

jscomp/test/polyvar_convert.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type t = [
2-
| @as("x") #a
2+
| #a
33
| #b
44
]
55

0 commit comments

Comments
 (0)