Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when format run on a project containing a subproject #2077

Closed
paulcadman opened this issue May 10, 2023 · 0 comments · Fixed by #2078
Closed

error when format run on a project containing a subproject #2077

paulcadman opened this issue May 10, 2023 · 0 comments · Fixed by #2078
Assignees
Milestone

Comments

@paulcadman
Copy link
Collaborator

Say you have a juvix project like:

.
├── Format.juvix
├── juvix.yaml
└── sub
    ├── SubFormat.juvix
    └── juvix.yaml

i.e an outer juvix project containing an inner subproject.

The file Format.juvix should be processed when running juvix format . from the root of the outer project and SubFormat.juvix should not be processed as it is a member of the inner project. The current behaviour is that the subproject sub is traversed. This causes an error because the file SubProject.juvix is scoped as a member of the outer project:

 error:
The top module SubProject is defined in the file:
/sub/SubProject.juvix
But it should be in the file:
/SubProject.juvix

The format command should not recurse into directories which contain a juvix.yaml file.

@paulcadman paulcadman self-assigned this May 10, 2023
@paulcadman paulcadman added this to the 0.3.4 milestone May 10, 2023
paulcadman added a commit that referenced this issue May 10, 2023
This PR fixes the behaviour of the `format` command when run on a
project that contains subprojects. Files in subprojects must not be
processed by the formatter.

The format issue was caused by a bug in the `walkDirRel` function that
is used to traverse a file system tree:


https://github.com/anoma/juvix/blob/9a64184253eb9129d2ac36d538d0c5f55cc46d35/src/Juvix/Data/Effect/Files.hs#L36

In this function, the passed handler can return a function that
determines if a candidate subdirectory should be traversed. The first
argument of this function indicates if the candidate subdirectory
contains a juvix.yaml file. In the formatter and the path resolver we
use this argument to exclude such subdirectories from the traversal.

Previously the first argument was calculated from the files in the
current directory instead of the candidate subdirectory - which was the
source of the bug.

The callers of walkDirRel are also fixed to match the updated behaviour.

* Closes #2077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant