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

Detect when resolve needs ModuleRef when likely cyclic references #3878

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

myyk
Copy link
Contributor

@myyk myyk commented Oct 31, 2024

This completes #3715 with all the cycle cases I could think of.

It also touches resolveDirectChildren where I made some changes that I would help with readability. I thought I was going to need to build on those but didn't. These can be reverted if it's unwanted.

}

if (seenModules.contains(cls)) {
Left(s"Cyclic module reference detected: ${cls.getName}, it's required to wrap it in ModuleRef. See documentation: https://mill-build.org/mill/0.12.1/fundamentals/modules.html#_abstract_modules_references")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if this link used the MILL_VERSION or I could not give the link. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the full link should be injected and generated in build.sc, since page refactoring happens now and then, and we could feed it to our link-checker when generating the docs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say let's just leave out the documentation link for now; we don't really have this convention in other error messages, and I feel like it would need a bit more thought to do properly (ensuring it's the right version, ensuring we don't have broken links, etc.)

@myyk myyk changed the title Resolve need moduleref Detect when resolve needs ModuleRef when likely cyclic references Oct 31, 2024
Comment on lines +1155 to +1161
test("moduleRefCycle") {
val check = new Checker(TestGraphs.ModuleRefCycle)
test - check(
"__",
Right(Set(_.foo))
)
}
Copy link
Member

@lihaoyi lihaoyi Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a few test cases for non-transitive resolves, both by normal wildcard foo.bar._ or foo.bar._.qux, as well as no-wildcard-at-all foo.bar.qux. In these cases, we should raise an error if we detect a cycle. That would keep the behavior consistent with the transitive case even if there isn't a risk of stackoverflow.

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

Successfully merging this pull request may close these issues.

3 participants