-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Change Error message @checkOverlay #5147
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -333,11 +333,15 @@ struct CmdFlakeCheck : FlakeCommand | |
| auto checkOverlay = [&](const std::string & attrPath, Value & v, const Pos & pos) { | ||
| try { | ||
| state->forceValue(v, pos); | ||
| if (!v.isLambda() || v.lambda.fun->matchAttrs || std::string(v.lambda.fun->arg) != "final") | ||
| throw Error("overlay does not take an argument named 'final'"); | ||
| if (!v.isLambda()) | ||
| throw Error("Expected a lambda for the overlay attribute, but got something else"); | ||
| if (v.lambda.fun->matchAttrs) | ||
| throw Error("By convention the attribute 'overlay' is expected to be a simple lambda starting with 'final: ', not an attribute set matching lambda"); | ||
| if (std::string(v.lambda.fun->arg) != "final") | ||
| throw Error("By convention the attribute 'overlay' expects the argument 'final' not '" + std::string(v.lambda.fun->arg) + "'"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This message isn't right for "matchAttrs" type lambdas, such as
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @roberth Do you have a proposal for what error it should throw?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By convention the attribute 'overlay' is expected to be a simple lambda starting with 'final: ', not an attribute set matching lambda. I guess you could add a representation of it too, but a source position
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Position info is already added to the error context by the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will crash if
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the new commit the |
||
| auto body = dynamic_cast<ExprLambda *>(v.lambda.fun->body); | ||
| if (!body || body->matchAttrs || std::string(body->arg) != "prev") | ||
| throw Error("overlay does not take an argument named 'prev'"); | ||
| throw Error("By convention the attribute 'overlay' expects the argument 'prev' not '" + std::string(body->arg) + "'"); | ||
| // FIXME: if we have a 'nixpkgs' input, use it to | ||
| // evaluate the overlay. | ||
| } catch (Error & e) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a convention but a requirement. Also instead of "lambda" it's better to say "function".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is responsible for this "requirement"?
Assuming we do need this, why say "function", a general term, when the value must be provided by a lambda? Or does Nix have another implementation of "function" that is acceptable here, but is not a lambda?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact check is the requirement.