Skip to content

cmd/compile: spurious undefined identifier warning for invalid identifier #68183

Closed
@rsc

Description

@rsc
% cat /tmp/x.go
package main

import "fmt"

func main() {
	fmt.Printf☹("hello world")
}
% go build /tmp/x.go
# command-line-arguments
/tmp/x.go:6:6: undefined: fmt.Printf☹
/tmp/x.go:6:12: invalid character U+2639 '☹' in identifier
% 

The first error is irrelevant; the second error is the real problem.

I ran into this in a real program by accidentally typing a non-breaking space (U+00A0), which renders invisibly. That made the first error look even weirder:

/tmp/x.go:6:6: undefined: fmt.Printf 
/tmp/x.go:6:12: invalid character U+00A0 in identifier

If the identifier has an invalid character, that should be diagnosed and there shouldn't be any other errors about it.

/cc @griesemer

Metadata

Metadata

Assignees

Labels

NeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.gabywins

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions