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: improve go compiler's syntax error message style #39274

Closed
delata opened this issue May 27, 2020 · 7 comments
Closed

cmd/compile: improve go compiler's syntax error message style #39274

delata opened this issue May 27, 2020 · 7 comments

Comments

@delata
Copy link

@delata delata commented May 27, 2020

If i take a look at GCC 's error massage, i see that they are very user friendly and descriptive.
Also provide suggestions how to fix the error.

I wish Go compiler will have this features.

try helloworld on Go and GCC with syntax error. to understand what i am saying

thanks.

@andybons andybons changed the title improve go compiler's syntax error massage style cmd/compile: improve go compiler's syntax error massage style May 27, 2020
@andybons
Copy link
Member

@andybons andybons commented May 27, 2020

While I understand the sentiment and agree that better error messages are a good thing for users, this issue doesn’t have a concrete proposal of what, precisely, should be improved. Without more actionable examples and proposed changes, this is difficult to act upon.

What, precisely, would you like to see changed?

@mdempsky mdempsky changed the title cmd/compile: improve go compiler's syntax error massage style cmd/compile: improve go compiler's syntax error message style May 27, 2020
@delata
Copy link
Author

@delata delata commented May 27, 2020

make it more like gcc. Also rustc looks good.
you know what mean. make it good, not bloated.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 28, 2020

@delata No, we don't know what you mean. We can guess, but experience tells me that our guess will not be what you expect. You know what you want. There is no reason to make us guess.
Please show us some examples. Thanks.

@delata
Copy link
Author

@delata delata commented May 28, 2020

try, helloworld with syntax error.

@delata
Copy link
Author

@delata delata commented May 28, 2020

i am unable to communicate my thought properly. sorry. English isn't my native language. currently i don't have access to a computer. i am writing this from a phone.

What you think about current error message style. are they good? if not, then discuss with core team and improve.

please.

this is the only reason i can't learn Go. I make a lot of syntax error and when i try to compile Go compiler don't give any good suggestion.
But with gcc it's very easy.
I want to learn Go.
please make the error message better, more helpful, user friendly.
thanks.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 28, 2020

Show us exactly what you did. Show us exactly what happened. Show us what you want to happen instead.

Otherwise we cannot help you. Sorry.

@andybons
Copy link
Member

@andybons andybons commented May 28, 2020

Given two “hello, world” examples with syntax errors (in C and Go, respectively):

C program:

#include <stdio.h>

int main() {
  printf("hello, world!\n);
  return 0;
}

gcc error:

main.c:4:10: warning: missing terminating '"' character [-Winvalid-pp-token]
  printf("hello, world!\n);
         ^
main.c:4:10: error: expected expression
main.c:6:2: error: expected '}'
}
 ^
main.c:3:12: note: to match this '{'
int main() {
           ^
1 warning and 2 errors generated.

Go program:

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, playground)
}

gc error:

./prog.go:8:33: newline in string
./prog.go:8:33: syntax error: unexpected newline, expecting comma or )

The warning is arguably more helpful, but both errors seem very similar. Note that Go doesn’t have warnings. If we interpret the warning as an error, then how granular is this specific request? Show a ^ under the offending line? Color-code the output? Show an error when there is no terminating quote in a string? That’s just for one class of errors.

We are sensitive to the sentiment you’re attempting to communicate, but the details matter. We can’t read your mind and are empathetic to the challenges that being a non-native English speaker presents, but without concrete requirements it’s very difficult for us to move forward. Additionally, asking us to run different compilers and compare output ourselves instead of running the commands yourself can be interpreted as you wanting others to do an outsized amount of work to, again, end up with a potential solution that doesn’t fit your requirements.

Closing for now. If you have more concrete requirements you’d like to communicate, feel free to do so. Thanks.

@andybons andybons closed this May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.