-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect deps that have already been invoked (#346)
* Detect deps that have already been invoked Detect when a dependency was accidentally already invoked mg.Deps(MyDep()) Normally this causes a nil pointer panic when we invoke the function Error: runtime error: invalid memory address or nil pointer dereference Now it will print the following as soon as its detected Error: A dependency of the current target was defined improperly, with parenthesis. Dependencies should be defined as mg.Deps(MyDep), not mg.Deps(MyDep()) I have applied this change to checkfn so that it applies to serial and parallel deps. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com> * Fix nil checks and improve error message The new mg.F function is the root of the nil-pointer error that can happen when someone accidentally calls mg.Deps(TargetA()). I have fixed the check for whether a function was passed so that it won't panic and included the usage for mg.F in the error message. I then added a similar check, is the target a function, to Deps/SerialDeps/CxtSerialDeps functions so that we can give a better error message when it's passed a non-function. The error message otherwise will reference mg.F which I don't think will help point people to the real problem, which is how they called mg.Deps/SerialDeps. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com> Co-authored-by: Nate Finch <nate.finch@gmail.com>
- Loading branch information
Showing
4 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters