Skip to content
New issue

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

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

Already on GitHub? # to your account

T.inputs are evaluated twice #2946

Closed
lolgab opened this issue Jan 5, 2024 · 1 comment · Fixed by #2952
Closed

T.inputs are evaluated twice #2946

lolgab opened this issue Jan 5, 2024 · 1 comment · Fixed by #2952
Labels
bug The issue represents an bug
Milestone

Comments

@lolgab
Copy link
Member

lolgab commented Jan 5, 2024

Reproduction

import mill._

def foo = T.input{ println("bla") }

Current behavior

mill foo
[1/1] foo 
bla
bla

Expected behavior

It should print bla once:

mill foo
[1/1] foo 
bla
@lolgab lolgab added the bug The issue represents an bug label Jan 5, 2024
@lefou
Copy link
Member

lefou commented Jan 5, 2024

Without any investigation of any kind, I remember some strange Scala behavior back from the 2.x times (where x < 10), that resulted in the compiler (?) executing a closure prematurely at definition time to get the actual return type. This is some dark memory, and I may totally reproduce it wrong, but I wanted to mention it at least once. If I find any reference to that issue, I will add it later...

lolgab added a commit that referenced this issue Jan 6, 2024
lolgab added a commit that referenced this issue Jan 7, 2024
Fixes #2946

In `evaluateNamed`, after evaluating `Task`s we are matching for
`ImputImpl[_]` instances to construct a `Watchable`.
A `Watchable` instance contains a `hashCode` for the current result and
a callback to evaluate it again and get the next result.
Instead of using the current result which was contained in `TaskResult`,
we were already calling the `recalc` callback, which executes again the
`T.input`s and performs their side effects twice.
Now we are returning the hashCode for the already computed result, so we
don't execute the `recalc` callback right away.

Pull Request: #2952
@lolgab lolgab added this to the 0.11.7 milestone Jan 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug The issue represents an bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants