Skip to content

incorrect and misleading compiler error message  #1022

Closed
@gopherbot

Description

@gopherbot

by ehog.hedge:

What steps will reproduce the problem?

Compile this code:

(((((((((((((((((((((((((((((((((
package main

type Int struct{value int}

func ok( spoo Int ) {
    _ = Int{1} 
}

func bad( spoo (Int) ) {
    _ = Int{1} 
}
)))))))))))))))))))))))))))

What is the expected output?

Silent (successful) compilation.

What do you see instead?

  main.go:7: cannot parenthesize type in composite literal

Setup:
  GOOS=linux GOARCH=amd64

Which revision are you using?  (hg identify)

  52b9b58d0cfa+ tip

This problem initially revealed itself when the argument types were
more complex -- chan(Int) or [](Int) -- but it's reduceable to just
the (superfluous, at least in this example) bracketing.

Exchanging the two function definition causes the error to additionally
appear inside ok as well as bad.

It /looks/ like the bracketing is being injected into the type at its
first appearance and persists after that.

Chris

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions