Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rsc opened this issue Jun 25, 2024 · 2 comments
Open

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

rsc opened this issue Jun 25, 2024 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. gabywins NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Jun 25, 2024

% 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

@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 25, 2024
@rsc rsc added this to the Go1.24 milestone Jun 25, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jun 25, 2024
@gabyhelp
Copy link

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@rsc
Copy link
Contributor Author

rsc commented Jun 28, 2024

Closed #42114 as a duplicate of this one.

@rsc rsc added the gabywins label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. gabywins NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

4 participants