Skip to content

cmd/compile: error for unexpected return values does not say 'return' #50653

@rsc

Description

@rsc
p1% cat /tmp/x.go
package p

func f0_2()            { return 1, 2 }
func f0_1()            { return 1 }
func f1_0() int        { return }
func f1_2() int        { return 1, 2 }
func f2_0() (int, int) { return }
func f2_1() (int, int) { return 1 }
p1% go tool compile /tmp/x.go
/tmp/x.go:3:33: no result values expected   <<<
/tmp/x.go:4:33: no result values expected   <<<
/tmp/x.go:5:26: not enough return values
	have ()
	want (int)
/tmp/x.go:6:36: too many return values
	have (number, number)
	want (int)
/tmp/x.go:7:26: not enough return values
	have ()
	want (int, int)
/tmp/x.go:8:33: not enough return values
	have (number)
	want (int, int)
p1% 

The marked messages that say 'result values' should be rewritten to say 'return values',
both for consistency with the others and for clarity.

The simplest fix is probably to stop treating f0_1 and f0_2 as a special case
and let the general 'too many return values' printer handle them, just like
f1_0 and f2_0` are not special cases and are handled by the general 'not enough return values' printer.

I know there's still plenty of generics work left in the type checker.
I can take care of this one myself this week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions