FAQ
just playing with go, when i try to use the "multiple return values as multiple parameters" feature with methods, i get the error:-"internal compiler error: arg count mismatch"


see: http://play.golang.org/p/7DDbhwHZvH


--

Search Discussions

  • Matt Kane's Brain at Sep 27, 2012 at 1:03 am
    Well, it's a weird error message, but you have a number of bugs in your program.
    Easy ones first!

    for i:=range *this {

    You never read from 'i' so the compiler throws a "variable not used"
    error. Replace with:

    for _ = range *this {


    func (this *pa) func2() p{
    return (*p).func3(this.func1())
    }

    p is not a variable. It's a type. I'm not sure what you're trying to
    do in this example, but if you are trying to call func3 with a
    receiver of type p that intend to return, you have to name it.

    func (this *pa) func2() (v p) {

    func1 returns two values, and func3 takes only 1, so you are passing
    in too many arguments.

    On Wed, Sep 26, 2012 at 8:43 PM, wrote:
    just playing with go, when i try to use the "multiple return values as
    multiple parameters" feature with methods, i get the error:-"internal
    compiler error: arg count mismatch"


    see: http://play.golang.org/p/7DDbhwHZvH


    --


    --
    matt kane's brain
    http://hydrogenproject.com

    --
  • Dan Kortschak at Sep 27, 2012 at 1:57 am
    That's legal as you can see from Jesse's post. He's calling the *p
    method as a function passing the *p and int returned from func1 as
    parameters.
    On Wed, 2012-09-26 at 21:03 -0400, Matt Kane's Brain wrote:
    func (this *pa) func2() p{
    return (*p).func3(this.func1())
    }

    p is not a variable. It's a type. I'm not sure what you're trying to
    do in this example, but if you are trying to call func3 with a
    receiver of type p that intend to return, you have to name it.

    --
  • Matt Kane's Brain at Sep 27, 2012 at 2:02 am

    On Wed, Sep 26, 2012 at 9:57 PM, Dan Kortschak wrote:
    That's legal as you can see from Jesse's post. He's calling the *p
    method as a function passing the *p and int returned from func1 as
    parameters.
    Right, I keep forgetting you can do that.

    --
    matt kane's brain
    http://hydrogenproject.com

    --
  • Beej Jorgensen at Sep 27, 2012 at 2:33 am

    On Wednesday, September 26, 2012 6:57:14 PM UTC-7, kortschak wrote:
    That's legal as you can see from Jesse's post. He's calling the *p
    method as a function passing the *p and int returned from func1 as
    parameters.
    This really weirded my newbie self out, so I dug around a bit more. Here's
    the reference for posterity:

    http://golang.org/ref/spec#Method_expressions

    Interesting stuff!

    This seems to build fine:

    //return (*p).func3(this.func1())
    x := (*p).func3
    return x(this.func1())


    Which I think is the same thing...?

    -Beej

    --
  • Simon Place at Sep 27, 2012 at 3:17 am
    just like to add:- what i did when i found the problem, was cut the code
    down as must as possible, still retaining the bug, and its that cut down
    code i showed, this technique has previously had me find what i was doing
    wrong quite quickly.

    however it does make for some pretty obscure looking code, sorry, but hey,
    it revealed the loop was involved.

    (BTW the original code had a receive channel range there.)

    guess i'll log this then.

    --
  • RoboTamer at Sep 27, 2012 at 1:17 am

    On Wednesday, September 26, 2012 5:43:50 PM UTC-7, simon...@googlemail.com wrote:

    just playing with go, when i try to use the "multiple return values as multiple parameters" feature with methods, i get the error:-"internal compiler error: arg count mismatch"


    see: http://play.golang.org/p/7DDbhwHZvH

    this is this.func1() is *pa
    func3 expects f int // func3(f int)

    --
  • Jesse McNelis at Sep 27, 2012 at 1:17 am

    On Thu, Sep 27, 2012 at 10:43 AM, wrote:
    just playing with go, when i try to use the "multiple return values as
    multiple parameters" feature with methods, i get the error:-"internal
    compiler error: arg count mismatch"


    see: http://play.golang.org/p/7DDbhwHZvH
    Looks like a bug.
    This works, http://play.golang.org/p/EYRsPdP1sn
    Some how the for loop is confusing the compiler here.



    --
    =====================
    http://jessta.id.au

    --
  • Michael Jones at Sep 27, 2012 at 1:31 am
    I get:

    prog.go:15: cannot use this.func1() (type (*p, int)) as type *p in
    assignment
    prog.go:15: internal compiler error: arg count mismatch: (@"".f int) vs
    this.func1()

    @"" can only come from so many places, ;-)
    On Thu, Sep 27, 2012 at 6:47 AM, Jesse McNelis wrote:
    On Thu, Sep 27, 2012 at 10:43 AM, wrote:
    just playing with go, when i try to use the "multiple return values as
    multiple parameters" feature with methods, i get the error:-"internal
    compiler error: arg count mismatch"


    see: http://play.golang.org/p/7DDbhwHZvH
    Looks like a bug.
    This works, http://play.golang.org/p/EYRsPdP1sn
    Some how the for loop is confusing the compiler here.



    --
    =====================
    http://jessta.id.au

    --


    --
    Michael T. Jones | Chief Technology Advocate | mtj@google.com | +1
    650-335-5765

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 27, '12 at 12:43a
activeSep 27, '12 at 3:17a
posts9
users7
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase