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: conversion error is a bit inaccurate #23394
Comments
Thank you @hirochachacha for this report! For the record, to be more explicit this seems like a regression in the error message, the results are: Go1.9.2https://play.golang.org/p/TYPAMUyqiEI prog.go:5:10: cannot convert 'r' to type string
prog.go:5:10: invalid operation: 'r' != s (mismatched types rune and string)
prog.go:6:8: cannot convert 1 to type string
prog.go:6:8: invalid operation: 1 != s (mismatched types int and string)
prog.go:7:10: cannot convert 1.1 to type string
prog.go:7:10: invalid operation: 1.1 != s (mismatched types float64 and string) Go1.10beta* and tip are./prog.go:5:10: cannot convert 'r' (type untyped number) to type string
./prog.go:5:10: invalid operation: 'r' != s (mismatched types rune and string)
./prog.go:6:8: cannot convert 1 (type untyped number) to type string
./prog.go:6:8: invalid operation: 1 != s (mismatched types int and string)
./prog.go:7:10: cannot convert 1.1 (type untyped number) to type string
./prog.go:7:10: invalid operation: 1.1 != s (mismatched types float64 and string) and diffing --- before 2018-01-09 23:56:03.000000000 -0800
+++ after 2018-01-09 23:56:10.000000000 -0800
@@ -1,6 +1,6 @@
-prog.go:5:10: cannot convert 'r' to type string
+prog.go:5:10: cannot convert 'r' (type untyped number) to type string
prog.go:5:10: invalid operation: 'r' != s (mismatched types rune and string)
-prog.go:6:8: cannot convert 1 to type string
+prog.go:6:8: cannot convert 1 (type untyped number) to type string
prog.go:6:8: invalid operation: 1 != s (mismatched types int and string)
-prog.go:7:10: cannot convert 1.1 to type string
+prog.go:7:10: cannot convert 1.1 (type untyped number) to type string
prog.go:7:10: invalid operation: 1.1 != s (mismatched types float64 and string) and I can confirm that this CL https://go-review.googlesource.com/46912 aka commit d05a123 is the source of the regression when we changed the print verb to /cc @kshvmdn and @griesemer |
Thanks @odeke-em for the analysis. For the record, gotype reports three errors:
|
The error messages could be better, but there are error messages. Not urgent. Moving to unplanned. |
Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
I expected to see "untyped rune", "untyped int", "untyped float".
What did you see instead?
"type untyped number" which is not a searchable keyword in the https://golang.org/ref/spec.
To be precise, conversion error here is already inaccurate.
The error message implies
s := string('r')
is incorrect code, but it's not true.Also "type untyped" is redundant expression to me.
or
is correct one. (initial one is better in this context)
Does this issue reproduce with the latest release (go1.9.2)?
I can see the conversion error, but I can't see "untyped number" in the error message.
System details
The text was updated successfully, but these errors were encountered: