Skip to content

Commit

Permalink
Propagate parse errors correctly
Browse files Browse the repository at this point in the history
opam-file-format has not required a change since opam 2.1, which causes
it to report parse errors when opam-version is > 2.1 using a signal.
opam was using the format version instead of the client version to
determine if these errors are actually parse errors, and was therefore
reporting an unsupported format instead of a parse error.
  • Loading branch information
dra27 committed Sep 16, 2024
1 parent c09fc56 commit bbb8a42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/format/opamFile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ module SyntaxFile(X: SyntaxFileArg) : IO_FILE with type t := X.t = struct
let catch_future_syntax_error = function
| {file_contents = [{pelem = Variable({pelem = "opam-version"; _}, {pelem = String ver; _}); _ };
{pelem = Section {section_kind = {pelem = "#"; _}; _}; pos}]; _}
when OpamVersion.(compare (nopatch (of_string ver)) (nopatch X.format_version)) <= 0 ->
when OpamVersion.(compare (nopatch (of_string ver)) (nopatch OpamVersion.current)) <= 0 ->
raise (OpamPp.Bad_version (Some pos, "Parse error"))
| opamfile -> opamfile

Expand Down
8 changes: 4 additions & 4 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@ echo GARBAGE>>"$1"
# Return code 30 #
### sh junk.sh pin-at-two-two/pin-at-two-two.opam
### opam install ./pin-at-two-two
[ERROR] In ${BASEDIR}/pin-at-two-two/pin-at-two-two.opam:
unsupported or missing file format version; should be 2.0 or older
[ERROR] At ${BASEDIR}/pin-at-two-two/pin-at-two-two.opam:11:0-11:0::
Parse error
[ERROR] Strict mode: aborting
# Return code 30 #
### sh junk.sh pin-at-two-three/pin-at-two-three.opam
### opam install ./pin-at-two-three
[ERROR] In ${BASEDIR}/pin-at-two-three/pin-at-two-three.opam:
unsupported or missing file format version; should be 2.0 or older
[ERROR] At ${BASEDIR}/pin-at-two-three/pin-at-two-three.opam:11:0-11:0::
Parse error
[ERROR] Strict mode: aborting
# Return code 30 #
### sh junk.sh pin-at-future/pin-at-future.opam
Expand Down

0 comments on commit bbb8a42

Please sign in to comment.