Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion compiler/ml/parmatch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ let extract_fields omegas arg =

let all_record_args lbls =
match lbls with
| [] -> []
| (_, {lbl_all}, _, opt) :: _ ->
let t =
Array.map
Expand Down Expand Up @@ -560,7 +561,6 @@ let all_record_args lbls =
t.(lbl.lbl_pos) <- x)
lbls;
Array.to_list t
| _ -> fatal_error "Parmatch.all_record_args"

(* Build argument list when p2 >= p1, where p1 is a simple pattern *)
let rec simple_match_args p1 p2 =
Expand Down
7 changes: 7 additions & 0 deletions tests/build_tests/parmatch_empty_record_pattern/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @ts-check

import { setup } from "#dev/process";

const { execBuild } = setup(import.meta.dirname);

await execBuild();
5 changes: 5 additions & 0 deletions tests/build_tests/parmatch_empty_record_pattern/rescript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "parmatch_empty_record_pattern",
"sources": ["src"],
"dependencies": []
}
41 changes: 41 additions & 0 deletions tests/build_tests/parmatch_empty_record_pattern/src/repro.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions tests/build_tests/parmatch_empty_record_pattern/src/repro.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type method_ = Post | Get

type body = Json(JSON.t)

type request = {
method: method_,
url: string,
headers: dict<string>,
body: body,
}

let classify = request =>
switch request {
| {
method: Post,
url,
headers: dict{"Authorization": "Token"},
body: Json(JSON.Object(dict{
"request": JSON.String("READ"),
"payload": JSON.Object(dict{
"list-a": JSON.Object(dict{"last_known_events": JSON.Object(dict{})}),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the empty dict is a little buried in this example.

}),
})),
} if url->String.includes("/todo/events") => 1
| _ => 0
}
Loading