Skip to content

driver: don't expect nodes to exist when checking paths between them

Magnus requested to merge MangoIV/ghc:mangoiv/module-graph-panic into master

In mgQueryZero, previously node lookups were expected to never fail, i.e. it was expected that when calculating the path between two nodes in a zero level import graph, both nodes would always exist. This is not the case, e.g. in some situations involving exact names (see the test-case). The fix is to first check whether the node is present in the graph at all, instead of panicking, just to report that there is no path.

@sheaf recommended doing two lookups to not change the semantics of mgQueryZero but I think that this is an actual improvement of the logic and in accordance of what the documentation describes this function is supposed to do - the code path that was causing the panic here is also the only code path that calls this function at all, so it should be extra okay.

Closes #26568 (closed)

Merge request reports

Loading