mill icon indicating copy to clipboard operation
mill copied to clipboard

Let `Task`-macros fail if their return value has a `Task`-type

Open lefou opened this issue 6 months ago • 0 comments

Since I again ran into an issue where we forgot to call the .apply() of a Task.Command, I think returning a Task from a Task should be always an error.

Offending erroneous task:

def myRun(args: Seq[String]): Task[Unit] = Task.Anon {
  run(Task.Anon(Args(args)))
}

The fix:

def myRun(args: Seq[String]): Task[Unit] = Task.Anon {
-  run(Task.Anon(Args(args)))
+  run(Task.Anon(Args(args)))()
}

We could enhance our Task-macros to detect a return value of (sub-)type Task, in which case we should simply fail the compilation.

lefou avatar Jun 06 '25 08:06 lefou