Skip to content

Commit

Permalink
Add suffix check for select filenames
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Nov 7, 2019
1 parent 1365e26 commit 7bc3b78
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/dune/lib_dep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Select = struct
[ Pp.textf "(<[!]libraries>... -> <file>) expected" ]
| Some (loc_file, file) ->
let () =
if dune_version >= (2, 0) then
if dune_version >= (2, 0) then (
let prefix =
( match String.lsplit2 result_fn ~on:'.' with
| None -> result_fn
Expand All @@ -42,7 +42,18 @@ module Select = struct
[ Pp.textf
"The prefix for files in this select branch must be %S"
prefix
]
];
String.rsplit2 result_fn ~on:'.'
|> Option.iter ~f:(fun (_, suffix) ->
let suffix = "." ^ suffix in
if not (String.is_suffix result_fn ~suffix) then
User_error.raise ~loc:loc_file
[ Pp.textf
"The suffix for files in this select branch \
must be %S"
suffix
])
)
in
let rec loop required forbidden = function
| [] ->
Expand Down

0 comments on commit 7bc3b78

Please sign in to comment.