Skip to content

ocamldep -sort returns success despite cyclic files warning #7710

Closed

Description

@vicuna

Original bug ID: 7710
Reporter: baileyparker
Status: resolved (set by @xavierleroy on 2018-02-11T13:55:42Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.06.0
Target version: 4.07.0+dev/beta2/rc1/rc2
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: tools (ocaml{lex,yacc,dep,debug,...})
Monitored by: @nojb @dbuenzli

Bug description

If you try running ocamldep on mli files that cyclicly reference eachother, you receive a warning printed to stderr, but ocamldep still prints an ordering and returns 0.

Given that cyclically referencing files are illegal, it should at least return a non-zero status (and probably shouldn't print an order since it is impossible to order cyclically referential files). Currently, when used in a scripting context, you have to (fragilely) search stderr for "Warning: cycle in dependencies." to determine if the output list is actually valid (because if you just try to ocamlc -c *.mli in the returned order you will get an unhelped message that B is unbound--not that there were cyclic references).

Steps to reproduce

a.mli:
type bill = { a : int }
val foo : B.baz -> int

b.mli:
type bar = { a : int; b : int }
val baz : bar -> A.bill -> int

  1. Place the above into files in the same directory
  2. Run ocamldep -sort a.mli b.mli
  3. Notice the "Warning: cycle in dependencies. End of list is not sorted."
  4. Notice echo $? is 0

Additional information

Relevant code:

ocaml/driver/makedepend.ml

Lines 466 to 467 in 8daa184

Format.fprintf Format.err_formatter
"@[Warning: cycle in dependencies. End of list is not sorted.@]@.";

Activity

  1. vicuna commented on Jan 22, 2018

    @vicuna
    Author

    Comment author: @xavierleroy

    I agree with your analysis. Fix in progress at #1578

  2. vicuna commented on Feb 11, 2018

    @vicuna
    Author

    Comment author: @xavierleroy

    Fix merged in trunk.

  3. added this to the 4.07.0 milestone on Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions