Skip to content

Commit bbfd8f2

Browse files
authored
print valid syntax for the corner case (1).a (#2653)
Not that I need this syntax, but I was wondering if my use of ocamlformat was adding parens properly, tried this as a tricky example, only to realize that ocamlformat doesn't handle it correctly in the first place. Considering this is handled correctly for Pexp_index_op 5 lines above, might as well handle it here as well.
1 parent 5cc318b commit bbfd8f2

15 files changed

+25
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ profile. This started with version 0.26.0.
1717
- Fixed the AST generated for bindings of the form `let pattern : type = function ...`
1818
(#2651, @v-gb)
1919

20+
- Print valid syntax for the corner case (1).a (#2653, @v-gb)
21+
2022
## 0.27.0
2123

2224
### Highlight

lib/Ast.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,10 @@ end = struct
23382338
when exp == lhs ->
23392339
true
23402340
| ( Exp {pexp_desc= Pexp_field (e, _); _}
2341-
, {pexp_desc= Pexp_construct _ | Pexp_cons _; _} )
2341+
, { pexp_desc=
2342+
( Pexp_construct _ | Pexp_cons _
2343+
| Pexp_constant {pconst_desc= Pconst_integer (_, None); _} )
2344+
; _ } )
23422345
when e == exp ->
23432346
true
23442347
| ( Exp {pexp_desc= Pexp_function (_, _, Pfunction_body e); _}

test/passing/refs.default/record-402.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ let foo
7878

7979
let x = (A B).a
8080
let x = A (B).a
81+
let x = (1).a

test/passing/refs.default/record-loose.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ let foo
7878

7979
let x = (A B).a
8080
let x = A (B).a
81+
let x = (1).a

test/passing/refs.default/record-tight_decl.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ let foo
7878

7979
let x = (A B).a
8080
let x = A (B).a
81+
let x = (1).a

test/passing/refs.default/record.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ let foo
7878

7979
let x = (A B).a
8080
let x = A (B).a
81+
let x = (1).a

test/passing/refs.janestreet/record-402.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ let foo
102102

103103
let x = (A B).a
104104
let x = A (B).a
105+
let x = (1).a

test/passing/refs.janestreet/record-loose.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ let foo
102102

103103
let x = (A B).a
104104
let x = A (B).a
105+
let x = (1).a

test/passing/refs.janestreet/record-tight_decl.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ let foo
102102

103103
let x = (A B).a
104104
let x = A (B).a
105+
let x = (1).a

test/passing/refs.janestreet/record.ml.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ let foo
102102

103103
let x = (A B).a
104104
let x = A (B).a
105+
let x = (1).a

0 commit comments

Comments
 (0)