这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/Normalize_std_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ let make_mapper conf ~ignore_doc_comments ~erase_jane_syntax =
| Pexp_extension ({txt= "src_pos"; loc}, _) when erase_jane_syntax ->
m.expr m (dummy_position ~loc)
| Pexp_stack expr when erase_jane_syntax -> m.expr m expr
| Pexp_unboxed_tuple es when erase_jane_syntax ->
Ast_mapper.default_mapper.expr m {exp with pexp_desc= Pexp_tuple es}
| Pexp_record_unboxed_product (es, e) when erase_jane_syntax ->
Ast_mapper.default_mapper.expr m
{exp with pexp_desc= Pexp_record (es, e)}
| Pexp_unboxed_field (e, l) when erase_jane_syntax ->
Ast_mapper.default_mapper.expr m
{exp with pexp_desc= Pexp_field (e, l)}
| _ -> Ast_mapper.default_mapper.expr m exp
in
let pat (m : Ast_mapper.mapper) pat =
Expand All @@ -295,6 +303,12 @@ let make_mapper conf ~ignore_doc_comments ~erase_jane_syntax =
[let _ : typ = exp] is represented as [let _ : typ = (exp :
typ)]. *)
m.pat m pat1
| Ppat_unboxed_tuple (ps, oc) when erase_jane_syntax ->
Ast_mapper.default_mapper.pat m
{pat with ppat_desc= Ppat_tuple (ps, oc)}
| Ppat_record_unboxed_product (ps, oc) when erase_jane_syntax ->
Ast_mapper.default_mapper.pat m
{pat with ppat_desc= Ppat_record (ps, oc)}
| _ -> Ast_mapper.default_mapper.pat m pat
in
let typ (m : Ast_mapper.mapper) typ =
Expand Down Expand Up @@ -350,6 +364,8 @@ let make_mapper conf ~ignore_doc_comments ~erase_jane_syntax =
| {ptyp_desc= Ptyp_poly (l, t); _} when erase_jane_syntax ->
let l = List.map l ~f:(fun (n, _) -> (n, None)) in
{typ with ptyp_desc= Ptyp_poly (l, t)}
| {ptyp_desc= Ptyp_unboxed_tuple ts; _} when erase_jane_syntax ->
{typ with ptyp_desc= Ptyp_tuple ts}
| _ -> typ
in
Ast_mapper.default_mapper.typ m typ
Expand Down Expand Up @@ -420,8 +436,14 @@ let make_mapper conf ~ignore_doc_comments ~erase_jane_syntax =
removed *)
|> if erase_jane_syntax then map_attributes_no_sort m else Fn.id
in
let ptype_kind =
match decl.ptype_kind with
| Ptype_record_unboxed_product lds when erase_jane_syntax ->
Ptype_record lds
| _ -> decl.ptype_kind
in
Ast_mapper.default_mapper.type_declaration m
{decl with ptype_attributes; ptype_jkind_annotation}
{decl with ptype_attributes; ptype_jkind_annotation; ptype_kind}
in
let modes (m : Ast_mapper.mapper) ms =
Ast_mapper.default_mapper.modes m
Expand Down
72 changes: 72 additions & 0 deletions test/passing/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12232,6 +12232,24 @@
(package ocamlformat)
(action (diff tests/unary_hash.ml.js-err unary_hash.ml.js-stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
(action
(with-stdout-to unboxed_record-erased.ml.stdout
(with-stderr-to unboxed_record-erased.ml.stderr
(run %{bin:ocamlformat} --margin-check --erase-jane-syntax --max-iter=3 %{dep:tests/unboxed_record.ml})))))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_record-erased.ml.ref unboxed_record-erased.ml.stdout)))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_record-erased.ml.err unboxed_record-erased.ml.stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
Expand Down Expand Up @@ -12268,6 +12286,24 @@
(package ocamlformat)
(action (diff tests/unboxed_record.ml.js-err unboxed_record.ml.js-stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
(action
(with-stdout-to unboxed_records_cmts_attrs-erased.ml.stdout
(with-stderr-to unboxed_records_cmts_attrs-erased.ml.stderr
(run %{bin:ocamlformat} --margin-check --erase-jane-syntax --max-iter=3 %{dep:tests/unboxed_records_cmts_attrs.ml})))))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_records_cmts_attrs-erased.ml.ref unboxed_records_cmts_attrs-erased.ml.stdout)))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_records_cmts_attrs-erased.ml.err unboxed_records_cmts_attrs-erased.ml.stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
Expand Down Expand Up @@ -12304,6 +12340,24 @@
(package ocamlformat)
(action (diff tests/unboxed_records_cmts_attrs.ml.js-err unboxed_records_cmts_attrs.ml.js-stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
(action
(with-stdout-to unboxed_tuples-erased.ml.stdout
(with-stderr-to unboxed_tuples-erased.ml.stderr
(run %{bin:ocamlformat} --margin-check --erase-jane-syntax --max-iter=3 %{dep:tests/unboxed_tuples.ml})))))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_tuples-erased.ml.ref unboxed_tuples-erased.ml.stdout)))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_tuples-erased.ml.err unboxed_tuples-erased.ml.stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
Expand Down Expand Up @@ -12340,6 +12394,24 @@
(package ocamlformat)
(action (diff tests/unboxed_tuples.ml.js-err unboxed_tuples.ml.js-stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
(action
(with-stdout-to unboxed_tuples_cmts_attrs-erased.ml.stdout
(with-stderr-to unboxed_tuples_cmts_attrs-erased.ml.stderr
(run %{bin:ocamlformat} --margin-check --erase-jane-syntax --max-iter=3 %{dep:tests/unboxed_tuples_cmts_attrs.ml})))))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_tuples_cmts_attrs-erased.ml.ref unboxed_tuples_cmts_attrs-erased.ml.stdout)))

(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/unboxed_tuples_cmts_attrs-erased.ml.err unboxed_tuples_cmts_attrs-erased.ml.stderr)))

(rule
(deps tests/.ocamlformat )
(package ocamlformat)
Expand Down
2 changes: 1 addition & 1 deletion test/passing/tests/stack-erased.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ let x = () :: []

let x = (1, 2)

let x = #(1, 2)
let x = (1, 2)

let x = (~x:1, ~y:2)

Expand Down
9 changes: 9 additions & 0 deletions test/passing/tests/unboxed_record-erased.ml.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Warning: tests/unboxed_record.ml:12 exceeds the margin
Warning: tests/unboxed_record.ml:18 exceeds the margin
Warning: tests/unboxed_record.ml:177 exceeds the margin
Warning: tests/unboxed_record.ml:186 exceeds the margin
Warning: tests/unboxed_record.ml:188 exceeds the margin
Warning: tests/unboxed_record.ml:198 exceeds the margin
Warning: tests/unboxed_record.ml:205 exceeds the margin
Warning: tests/unboxed_record.ml:206 exceeds the margin
Warning: tests/unboxed_record.ml:215 exceeds the margin
1 change: 1 addition & 0 deletions test/passing/tests/unboxed_record-erased.ml.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--erase-jane-syntax --max-iter=3
Loading
Loading