Odd error message - expression in go must be function call

108 views
Skip to first unread message

Matthew Zimmerman

unread,
Apr 23, 2020, 10:30:59 AM4/23/20
to golang-nuts
I was really confused by this error for ~10 minutes or so.  Usually when this happens to me, I missed a closing/opening brace somewhere or I forgot to add () after my anonymous function declaration to actually run it.

This time though all the braces were lining up and I had () there appropriately.  I finally gave up on that error and started working on the next one and when I looked there (using if instead of for with the range operator) I realized I had a bug fixed it and my first error went away too.

Not sure if this is anything to be too worried about, but I found it confusing and wasn't sure if this was worth a bug report or not.

It's easily reproducible: https://play.golang.org/p/DJKZqMtng4S

Change line 13 from if to for and everything works.

Great project/language, thanks for everyone's work on it!

Mhd Shulhan

unread,
Apr 23, 2020, 11:01:42 AM4/23/20
to Matthew Zimmerman, golang-nuts
Pada tanggal Kam, 23 Apr 2020 21.30, Matthew Zimmerman <mzimm...@gmail.com> menulis:
I was really confused by this error for ~10 minutes or so.  Usually when this happens to me, I missed a closing/opening brace somewhere or I forgot to add () after my anonymous function declaration to actually run it.

This time though all the braces were lining up and I had () there appropriately.  I finally gave up on that error and started working on the next one and when I looked there (using if instead of for with the range operator) I realized I had a bug fixed it and my first error went away too.

Not sure if this is anything to be too worried about, but I found it confusing and wasn't sure if this was worth a bug report or not.

It's easily reproducible: https://play.golang.org/p/DJKZqMtng4S


After reading several sentences, I just click the link and can't figured out where the mistake was, and then I read your full email to realize where the error was.

Here is another example of confusing error message that I found just today,


You may find the mistake easily by first glance. Usually error like this happen if you have many lines of code with static string here and there, and one single typo.

Ian Lance Taylor

unread,
Apr 23, 2020, 12:16:43 PM4/23/20
to Matthew Zimmerman, golang-nuts
Thanks. Can you file a bug report for this at
https://golang.org/issue ? I agree that we should do better here.

Ian

Matthew Zimmerman

unread,
Apr 23, 2020, 12:35:56 PM4/23/20
to Ian Lance Taylor, golang-nuts

Ian Lance Taylor

unread,
Apr 23, 2020, 10:57:43 PM4/23/20
to Matthew Zimmerman, golang-nuts
On Thu, Apr 23, 2020 at 9:35 AM Matthew Zimmerman <mzimm...@gmail.com> wrote:
>
> Reported, thank you!
>
> https://github.com/golang/go/issues/38624

Thanks!

Ian
Reply all
Reply to author
Forward
0 new messages