Skip to content

Commit

Permalink
Upgrade ocamlformat and add more error messages for functor paths
Browse files Browse the repository at this point in the history
  • Loading branch information
clarus committed Jan 29, 2024
1 parent 4170adb commit 3efbed0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
ocaml-version: ${{ matrix.ocaml-version }}

- run: opam install ocamlformat.0.22.4
- run: opam install ocamlformat.0.24.1
- run: opam exec -- make fmt-check
- run: opam pin add coq ${{ matrix.coq-version }}
- run: opam pin add coq-of-ocaml.dev . --no-action
Expand Down
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.22.4
version=0.24.1
18 changes: 12 additions & 6 deletions src/pathName.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,29 @@ let of_path_without_convert (is_value : bool) (path : Path.t) : t Monad.t =
aux path >>= fun (path, base) ->
Name.of_string is_value field >>= fun field ->
return (base :: path, field)
| Path.Papply _ -> failwith "Unexpected functor path application"
| Path.Papply _ ->
let name = Path.name path in
raise ([], Name.Make name) Unexpected
("Unexpected functor path application " ^ Path.name path)
in
aux path >>= fun (path, base) -> return (of_name (List.rev path) base)

let of_path_with_convert (is_value : bool) (path : Path.t) : t Monad.t =
of_path_without_convert is_value path >>= fun path -> convert path

let of_path_and_name_with_convert (path : Path.t) (name : Name.t) : t Monad.t =
let rec aux p : (Name.t list * Name.t) Monad.t =
match p with
let rec aux path : (Name.t list * Name.t) Monad.t =
match path with
| Path.Pident x ->
let* path, base = split_ident false x in
return (path @ [ base ], name)
| Path.Pdot (p, s) ->
aux p >>= fun (path, base) ->
| Path.Pdot (path, s) ->
aux path >>= fun (path, base) ->
Name.of_string false s >>= fun s -> return (path @ [ s ], base)
| Path.Papply _ -> failwith "Unexpected functor path application"
| Path.Papply _ ->
let name = Path.name path in
raise ([], Name.Make name) Unexpected
("Unexpected functor path application " ^ Path.name path)
in
aux path >>= fun (path, base) -> convert (of_name path base)

Expand Down

0 comments on commit 3efbed0

Please sign in to comment.