File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,14 @@ struct CmdFlakeInfo : CmdFlakeMetadata
252252 }
253253};
254254
255+ static bool argHasName (std::string_view arg, std::string_view expected)
256+ {
257+ return
258+ arg == expected
259+ || arg == " _"
260+ || (hasPrefix (arg, " _" ) && arg.substr (1 ) == expected);
261+ }
262+
255263struct CmdFlakeCheck : FlakeCommand
256264{
257265 bool build = true ;
@@ -346,14 +354,14 @@ struct CmdFlakeCheck : FlakeCommand
346354 auto checkOverlay = [&](const std::string & attrPath, Value & v, const Pos & pos) {
347355 try {
348356 state->forceValue (v, pos);
349- if (!v.isLambda () || v. lambda . fun -> hasFormals () ||
350- ( std::string ( v.lambda .fun ->arg ) != " final " &&
351- std::string (v.lambda .fun ->arg ) != " _final " ))
357+ if (!v.isLambda ()
358+ || v.lambda .fun ->hasFormals ()
359+ || ! argHasName (v.lambda .fun ->arg , " final " ))
352360 throw Error (" overlay does not take an argument named 'final'" );
353361 auto body = dynamic_cast <ExprLambda *>(v.lambda .fun ->body );
354- if (!body || body-> hasFormals () ||
355- ( std::string ( body->arg ) != " prev " &&
356- std::string (body->arg ) != " _prev " ))
362+ if (!body
363+ || body->hasFormals ()
364+ || ! argHasName (body->arg , " prev " ))
357365 throw Error (" overlay does not take an argument named 'prev'" );
358366 // FIXME: if we have a 'nixpkgs' input, use it to
359367 // evaluate the overlay.
You can’t perform that action at this time.
0 commit comments