Upgrading Hugo gives "Can’t give argument to non-function"

I’m upgrading from Hugo .70 to 74.1 and I suddenly get a “Can’t give argument to non-function”.

I read some other posts that is related to the update of Go which fixed a bug which now correctly marked logical errors.

The logic I have is:

{{ if (and (($driver_standing) (or (lt $season.year .Site.Params.current_season) (and (eq $season.year .Site.Params.current_season) (.Site.Params.drivers_championship.current_year_awarded))))) }}

Now the error is related to the $driver_standing:

70:18": execute of template failed: template: seasons/list.html:70:18: executing "foot" at <($driver_standing) (or (lt $season.year .Site.Params.current_season) (and (eq $season.year .Site.Params.current_season) (.Site.Params.drivers_championship.current_year_awarded)))>: can't give argument to non-function $driver_standing

When I remove the ($driver_standing) at the beginning of the condition it works.
I’ve that in to check if that var is not empty.
Is there another way then to check this?

Here’s a simplified representation of your logic:

if (and ((true) (or (true) (and (true) (true)))))

Simplified further:

if (and ((true) (or (true) (true)) ))

Simplified further:

if (and ((true) (true)) )

Simplified further:

if and ((true) (true))

Problem: you are only only passing one (malformed) condition to and.


if and (true) (true)

Or, in your case:

{{ if and ($driver_standing) (or (lt $season.year .Site.Params.current_season) (and (eq $season.year .Site.Params.current_season) (.Site.Params.drivers_championship.current_year_awarded))) }}

1 Like

Thanks @jmooring !