Skip to content

Commit 1866147

Browse files
[bugfix] fix crash with inline record type variable (#2710)
* fix crash with inline record type variable * update changelog * promote tests
1 parent 354bd47 commit 1866147

19 files changed

+39
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ profile. This started with version 0.26.0.
7171
contexts like `a ; fun ...`. A check for the syntax `let a = fun ... in ...`
7272
was made more precise. (#2705, @EmileTrotignon)
7373

74+
- Fix a crash on `type 'a t = A : 'a. {a: 'a} -> 'a t`. (#2710, @EmileTrotignon)
75+
7476
### Changed
7577

7678
- `|> begin`, `~arg:begin`, `begin if`, `lazy begin`, `begin match`,

lib/Fmt_ast.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3649,6 +3649,9 @@ and fmt_constructor_arguments ?vars c ctx ~pre = function
36493649
in
36503650
pre $ vars $ typs
36513651
| Pcstr_record (loc, lds) ->
3652+
let vars =
3653+
match vars with Some vars -> space_break $ vars | None -> noop
3654+
in
36523655
let p = Params.get_record_type c.conf in
36533656
let fmt_ld ~first ~last x =
36543657
fmt_if (not first) p.sep_before
@@ -3658,7 +3661,7 @@ and fmt_constructor_arguments ?vars c ctx ~pre = function
36583661
(str " ")
36593662
$ fmt_if (not last) p.sep_after
36603663
in
3661-
pre
3664+
pre $ vars
36623665
$ Cmts.fmt c loc ~pro:(break 1 0) ~epi:noop
36633666
@@ wrap p.docked_before p.docked_after
36643667
@@ wrap p.break_before p.break_after

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ let x = (A B).a
119119
let x = A (B).a
120120

121121
let x = (1).a
122+
123+
type 'a t = A : 'b. { a : 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ let x = (A B).a
119119
let x = A (B).a
120120

121121
let x = (1).a
122+
123+
type 'a t = A : 'b. { a : 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ let x = (A B).a
119119
let x = A (B).a
120120

121121
let x = (1).a
122+
123+
type 'a t = A : 'b. { a: 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ let x = (A B).a
119119
let x = A (B).a
120120

121121
let x = (1).a
122+
123+
type 'a t = A : 'b. { a: 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ let foo
7979
let x = (A B).a
8080
let x = A (B).a
8181
let x = (1).a
82+
83+
type 'a t = A : 'b. { a : 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ let foo
7979
let x = (A B).a
8080
let x = A (B).a
8181
let x = (1).a
82+
83+
type 'a t = A : 'b. { a : 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ let foo
7979
let x = (A B).a
8080
let x = A (B).a
8181
let x = (1).a
82+
83+
type 'a t = A : 'b. { a: 'a } -> 'a t

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ let foo
7979
let x = (A B).a
8080
let x = A (B).a
8181
let x = (1).a
82+
83+
type 'a t = A : 'b. { a: 'a } -> 'a t

0 commit comments

Comments
 (0)