mill icon indicating copy to clipboard operation
mill copied to clipboard

Filter out non-modules when trying to instantiate a module

Open lihaoyi opened this issue 3 weeks ago • 3 comments

Fixes https://github.com/com-lihaoyi/mill/issues/6303

lihaoyi avatar Dec 03 '25 09:12 lihaoyi

Is filtering / ignoring the right solution? Shouldn't we either error our or require the user to not mix-in MainModule (which is currently not configurable)?

If we just filter out, what is the correct behavior for mill init in the example given in #6303?

lefou avatar Dec 03 '25 11:12 lefou

I'm not sure TBH, but we already have an init module in the Mill codebase that would conflict with the init task that Mill comes bundled with, so presumably it won't be uncommon to have such collisions and if we could make it work without error that would be nice

lihaoyi avatar Dec 03 '25 13:12 lihaoyi

I'm not sure TBH, but we already have an init module in the Mill codebase that would conflict with the init task that Mill comes bundled with, so presumably it won't be uncommon to have such collisions and if we could make it work without error that would be nice

I think the init module we have is libs.init and not a top-level module, so it won't collide with MainModule.init.

I think there is no room to gracefully handle collisions, if we speak about CLI and API modelling the same name space. E.g. a init module implementing DefaultTaskModule already collides on the CLI. But using some build.init.compile() task via API has to collide when compiling it, if build.init is aleady a task inherited from MainModule.

lefou avatar Dec 03 '25 15:12 lefou