0.71.1 ERROR: Can't give argument to non-function

On a previously working theme, I now get an error saying : can't give argument to non-function $.Page.IsMenuCurrent "main" .

I checked my code, and the only call to .IsMenuCurrent is in the baseof.html file

{{- range .Site.Menus.main -}}
    <li class="nav-item {{ if ( $.Page.IsMenuCurrent "main" .) ( $.Page.HasMenuCurrent "main" .) }} active {{- end -}}"><a href="{{- .URL | absLangURL -}}" title="{{- .Post -}}" class="nav-link top-menu menu-click {{- .Identifier | urlize -}} ">{{- .Name | safeHTML -}}</a></li>
{{- end -}}  <!-- end range .Site.Menus.main -->

I didn’t find any breaking changes in this new version, but maybe I missed something?

We updated Go (or more accurate: The Go template package) which fixed a bug which now correctly marks this as a logical error:

 {{ if ( $.Page.IsMenuCurrent "main" .) ( $.Page.HasMenuCurrent "main" .) }} 

In short: The result of what’s inside parens can never be a function and should never have arguments.

I assume the above should be:

 {{ if (or ( $.Page.IsMenuCurrent "main" .) ( $.Page.HasMenuCurrent "main" .)) }} 
3 Likes

@bep

9 themes broke due to this upgrade in the latest deploy of Hugo Themes (3 were already broken for other reasons) .

Search for the string can't give argument to non-function in the deploy log if you want to see.

cc: @digitalcraftsman

EDIT
2 of these themes were already fixed. For the remaining 7 broken themes I notified theme authors here

1 Like

No, 9 themes got the chance to be fixed by this. They were broken before this upgrade.

Bep you’re ready to be a French politician :slight_smile: ah ah

2 Likes

Thank you @bep, it’s working now and I managed to solve the remainder issues that came after it.

Or a theologian.

The argument reminds of theological discussions regarding the difference between Catholic and Orthodox Christians.

Great!

I still mean that if you have a flat tire you have a broken system even if the warning system is does not alert about it … Fixing the warning system will not fix your flat tire, but you’re certainly in a much better position than before.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.