aboutsummaryrefslogtreecommitdiff
path: root/test/ddd1.go
AgeCommit message (Collapse)Author
2021-06-02test: fix error check messages for 2 types2 testsZachary Burkett
Many compiler tests fail with -G=3 due to changes in error message format. This commit fixes two of these tests, to ensure I am on the right track in review. Updates #46447 Change-Id: I138956d536a1d48ca9198e6ddbfde13865bb5dd5 GitHub-Last-Rev: 0ed904b9fad5e6739fee02ab48c7bc66508d736b GitHub-Pull-Request: golang/go#46445 Reviewed-on: https://go-review.googlesource.com/c/go/+/323314 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-05-03cmd/compile: make typecheckaste correctly report invalid use of "..."Cuong Manh Le
Currently, when "..." argument is passed to non-variadic function, the compiler may skip that check, but continue checking whether the number of arguments matches the function signature. That causes the sanity check which was added in CL 255241 trigger. Instead, we should report an invalid use of "...", which matches the behavior of new type checker and go/types. Fixes #45913 Change-Id: Icbb254052cbcd756bbd41f966c2c8e316c44420f Reviewed-on: https://go-review.googlesource.com/c/go/+/315796 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28test: match gofrontend error messagesIan Lance Taylor
These changes match the following gofrontend error messages: blank1.go:16:1: error: may not define methods on non-local type chan/perm.go:28:9: error: expected channel chan/perm.go:29:11: error: left operand of ‘<-’ must be channel chan/perm.go:69:9: error: argument must be channel complit1.go:25:16: error: attempt to slice object that is not array, slice, or string complit1.go:26:16: error: attempt to slice object that is not array, slice, or string complit1.go:27:17: error: attempt to slice object that is not array, slice, or string complit1.go:49:41: error: may only omit types within composite literals of slice, array, or map type complit1.go:50:14: error: expected struct, slice, array, or map type for composite literal convlit.go:24:9: error: invalid type conversion (cannot use type unsafe.Pointer as type string) convlit.go:25:9: error: invalid type conversion (cannot use type unsafe.Pointer as type float64) convlit.go:26:9: error: invalid type conversion (cannot use type unsafe.Pointer as type int) ddd1.go:63:9: error: invalid use of ‘...’ calling non-variadic function fixedbugs/bug176.go:12:18: error: index expression is not integer constant fixedbugs/bug332.go:17:10: error: use of undefined type ‘T’ fixedbugs/issue4232.go:22:16: error: integer constant overflow fixedbugs/issue4232.go:33:16: error: integer constant overflow fixedbugs/issue4232.go:44:25: error: integer constant overflow fixedbugs/issue4232.go:55:16: error: integer constant overflow fixedbugs/issue4458.go:19:14: error: type has no method ‘foo’ fixedbugs/issue5172.go:24:14: error: too many expressions for struct init.go:17:9: error: reference to undefined name ‘runtime’ initializerr.go:26:29: error: duplicate value for index 1 interface/explicit.go:60:14: error: type assertion only valid for interface types label.go:64:9: error: reference to undefined label ‘go2’ label1.go:18:97: error: continue statement not within for label1.go:22:97: error: continue statement not within for label1.go:106:89: error: continue statement not within for label1.go:108:26: error: invalid continue label ‘on’ label1.go:111:118: error: break statement not within for or switch or select label1.go:113:23: error: invalid break label ‘dance’ map1.go:64:9: error: not enough arguments map1.go:65:9: error: not enough arguments map1.go:67:9: error: argument 1 must be a map method2.go:36:11: error: reference to undefined field or method ‘val’ method2.go:37:11: error: reference to undefined field or method ‘val’ method2.go:41:12: error: method requires pointer (use ‘(*T).g’) syntax/chan1.go:13:19: error: send statement used as value; use select for non-blocking send syntax/chan1.go:17:11: error: send statement used as value; use select for non-blocking send Change-Id: I98047b60a376e3d2788836300f7fcac3f2c285cb Reviewed-on: https://go-review.googlesource.com/c/go/+/273527 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-09-12cmd/compile: don't report not enough args error if call is undefinedCuong Manh Le
Fixes #38745 Change-Id: I2fbd8b512a8cf911b81a087162c74416116efea5 Reviewed-on: https://go-review.googlesource.com/c/go/+/253678 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-09-12cmd/compile: use clearer error message for stuct literalCuong Manh Le
This CL changes "T literal.M" error message to "T{...}.M". It's clearer expression and focusing user on actual issue. Updates #38745 Change-Id: I84b455a86742f37e0bde5bf390aa02984eecc3c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/253677 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-09-06cmd/compile: rewrite untyped constant conversion logicMatthew Dempsky
This CL detangles the hairy mess that was convlit+defaultlit. In particular, it makes the following changes: 1. convlit1 now follows the standard typecheck behavior of setting "n.Type = nil" if there's an error. Notably, this means for a lot of test cases, we now avoid reporting useless follow-on error messages. For example, after reporting that "1 << s + 1.0" has an invalid shift, we no longer also report that it can't be assigned to string. 2. Previously, assignconvfn had some extra logic for trying to suppress errors from convlit/defaultlit so that it could provide its own errors with better context information. Instead, this extra context information is now passed down into convlit1 directly. 3. Relatedly, this CL also removes redundant calls to defaultlit prior to assignconv. As a consequence, when an expression doesn't make sense for a particular assignment (e.g., assigning an untyped string to an integer), the error messages now say "untyped string" instead of just "string". This is more consistent with go/types behavior. 4. defaultlit2 is now smarter about only trying to convert pairs of untyped constants when it's likely to succeed. This allows us to report better error messages for things like 3+"x"; instead of "cannot convert 3 to string" we now report "mismatched types untyped number and untyped string". Passes toolstash-check. Change-Id: I26822a02dc35855bd0ac774907b1cf5737e91882 Reviewed-on: https://go-review.googlesource.com/c/go/+/187657 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2017-08-11test: reenable ... testTobias Klauser
The gofmt bug in question seems to be fixed (at least gofmt doesn't complain), so reenable the commented-out ... test. Change-Id: Icbfe0511160210557894ec8eb9b206aa6133d486 Reviewed-on: https://go-review.googlesource.com/55030 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-24cmd/compile: more error position tests for the typecheckerAlberto Donizetti
This change adds line position tests for several yyerror calls in the typechecker that are currently not tested in any way. Untested yyerror calls were found by replacing them with yerrorl(src.NoXPos, ...) (thus destroying position information in the error), and then running the test suite. No failures means no test coverage for the relevant yyerror call. For #19683 Change-Id: Iedb3d2f02141b332e9bfa76dbf5ae930ad2fddc3 Reviewed-on: https://go-review.googlesource.com/41477 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-28cmd/compile: improve not enough / too many arguments errorsMatthew Dempsky
Use "have" and "want" and multiple lines like other similar error messages. Also, fix handling of ... and multi-value function calls. Fixes #17650. Change-Id: I4850e79c080eac8df3b92a4accf9e470dff63c9a Reviewed-on: https://go-review.googlesource.com/32261 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-02all: make copyright headers consistent with one space after periodEmmanuel Odeke
Follows suit with https://go-review.googlesource.com/#/c/20111. Generated by running $ grep -R 'Go Authors. All' * | cut -d":" -f1 | while read F;do perl -pi -e 's/Go Authors. All/Go Authors. All/g' $F;done The code in cmd/internal/unvendor wasn't changed. Fixes #15213 Change-Id: I4f235cee0a62ec435f9e8540a1ec08ae03b1a75f Reviewed-on: https://go-review.googlesource.com/21819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2012-09-28test: match gccgo error messagesIan Lance Taylor
const1.go:31:12: error: integer constant overflow const1.go:31:12: error: integer constant overflow const1.go:33:12: error: integer constant overflow const1.go:33:12: error: integer constant overflow const1.go:34:14: error: integer constant overflow const1.go:35:17: error: integer constant overflow const1.go:35:17: error: integer constant overflow const1.go:35:17: error: integer constant overflow const1.go:35:17: error: integer constant overflow const1.go:35:17: error: integer constant overflow const1.go:36:19: error: integer constant overflow const1.go:37:15: error: integer constant overflow const1.go:37:15: error: integer constant overflow const1.go:37:24: error: integer constant overflow const1.go:37:15: error: integer constant overflow const1.go:37:15: error: integer constant overflow const1.go:37:15: error: integer constant overflow const1.go:37:24: error: integer constant overflow const1.go:37:15: error: integer constant overflow const1.go:38:12: error: integer constant overflow const1.go:38:12: error: integer constant overflow const1.go:38:12: error: integer constant overflow const1.go:38:12: error: integer constant overflow const1.go:41:20: error: integer constant overflow const1.go:41:20: error: integer constant overflow const1.go:42:20: error: integer constant overflow const1.go:42:20: error: integer constant overflow const1.go:44:28: error: integer constant overflow const1.go:44:28: error: integer constant overflow const1.go:45:14: error: integer constant overflow const1.go:49:14: error: integer constant overflow const1.go:50:14: error: integer constant overflow const1.go:51:14: error: integer constant overflow const1.go:54:23: error: integer constant overflow const1.go:54:23: error: integer constant overflow const1.go:54:23: error: integer constant overflow const1.go:54:23: error: integer constant overflow const1.go:56:14: error: integer constant overflow const1.go:57:24: error: integer constant overflow const1.go:57:24: error: integer constant overflow const1.go:58:24: error: integer constant overflow const1.go:58:24: error: integer constant overflow const1.go:59:22: error: integer constant overflow const1.go:59:22: error: integer constant overflow const1.go:61:24: error: integer constant overflow const1.go:62:20: error: division by zero const1.go:65:19: error: floating point constant overflow const1.go:65:19: error: floating point constant overflow const1.go:66:28: error: floating point constant overflow const1.go:66:28: error: floating point constant overflow const1.go:67:19: error: floating point constant overflow const1.go:67:19: error: floating point constant overflow const1.go:68:19: error: division by zero const1.go:33:14: error: integer constant overflow const1.go:35:19: error: integer constant overflow const1.go:42:22: error: integer constant overflow const1.go:53:17: error: integer constant overflow const1.go:55:14: error: integer constant overflow const1.go:59:24: error: integer constant overflow const1.go:69:20: error: expected integer type const1.go:75:4: error: argument 1 has incompatible type (cannot use type int8 as type int) const1.go:76:4: error: argument 1 has incompatible type (cannot use type int8 as type int) const1.go:77:4: error: argument 1 has incompatible type (cannot use type uint8 as type int) const1.go:79:4: error: argument 1 has incompatible type (cannot use type float32 as type int) const1.go:80:4: error: argument 1 has incompatible type (cannot use type float64 as type int) const1.go:81:4: error: floating point constant truncated to integer const1.go:83:4: error: argument 1 has incompatible type (cannot use type float64 as type int) const1.go:84:4: error: argument 1 has incompatible type (cannot use type string as type int) const1.go:85:4: error: argument 1 has incompatible type (cannot use type bool as type int) const1.go:88:7: error: const initializer cannot be nil const2.go:14:8: error: expected ‘=’ const5.go:27:7: error: expression is not constant const5.go:28:7: error: expression is not constant const5.go:30:7: error: expression is not constant const5.go:31:7: error: expression is not constant ddd1.go:57:23: error: invalid use of ‘...’ in type conversion ddd1.go:59:6: error: invalid use of ‘...’ in type conversion ddd1.go:60:12: error: use of ‘[...]’ outside of array literal ddd1.go:21:15: error: argument 1 has incompatible type ddd1.go:22:10: error: argument 1 has incompatible type ddd1.go:30:6: error: invalid use of ‘...’ with non-slice ddd1.go:30:6: error: invalid use of ‘...’ with non-slice ddd1.go:46:2: error: invalid use of %<...%> with builtin function ddd1.go:47:2: error: invalid use of %<...%> with builtin function ddd1.go:49:2: error: invalid use of %<...%> with builtin function ddd1.go:50:6: error: invalid use of %<...%> with builtin function ddd1.go:51:6: error: invalid use of %<...%> with builtin function ddd1.go:53:6: error: invalid use of %<...%> with builtin function ddd1.go:58:13: error: invalid use of %<...%> with builtin function ddd1.go:20:10: error: floating point constant truncated to integer ddd1.go:32:6: error: invalid use of ‘...’ calling non-variadic function declbad.go:20:3: error: variables redeclared but no variable is new declbad.go:38:3: error: variables redeclared but no variable is new declbad.go:44:3: error: variables redeclared but no variable is new declbad.go:51:3: error: variables redeclared but no variable is new declbad.go:57:3: error: variables redeclared but no variable is new declbad.go:63:3: error: variables redeclared but no variable is new declbad.go:26:3: error: incompatible types in assignment (cannot use type float32 as type int) declbad.go:32:3: error: incompatible types in assignment (cannot use type int as type float32) declbad.go:44:3: error: incompatible types in assignment (different number of results) fixedbugs/bug223.go:21:5: error: initialization expression for ‘m’ depends upon itself fixedbugs/bug412.go:10:2: error: duplicate field name ‘x’ fixedbugs/bug413.go:11:5: error: initialization expression for ‘i’ depends upon itself fixedbugs/bug416.go:13:1: error: method ‘X’ redeclares struct field name fixedbugs/bug435.go:15:49: error: missing ‘)’ fixedbugs/bug435.go:15:2: error: reference to undefined name ‘bar’ fixedbugs/bug451.go:9:9: error: expected package typeswitch3.go:39:9: error: no new variables on left side of ‘:=’ typeswitch3.go:24:2: error: impossible type switch case (type has no methods) R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6560063
2012-07-13cmd/gc: reject use of ... with multiple-valued expressions.Rémy Oudompheng
Fixes #3334. R=golang-dev, r CC=golang-dev, remy https://golang.org/cl/6350103
2012-02-19test: explanatory comments [c-g]*Rob Pike
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5656103
2012-02-16test: use testlib (first 100)Russ Cox
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5656082
2011-12-14gc: use inferred type rather than original one when reporting non-assignability.Luuk van Dijk
Fixes #2451 R=rsc, bradfitz CC=golang-dev https://golang.org/cl/5372105
2011-10-31gc: clean up printing.Luuk van Dijk
Got rid of all the magic mystery globals. Now for %N, %T, and %S, the flags +,- and # set a sticky debug, sym and export mode, only visible in the new fmt.c. Default is error mode. Handle h and l flags consistently with the least side effects, so we can now change things without worrying about unrelated things breaking. fixes #2361 R=rsc CC=golang-dev https://golang.org/cl/5316043
2011-10-08gc: changes to export format in preparation for inlining.Luuk van Dijk
string literals used as package qualifiers are now prefixed with '@' which obviates the need for the extra ':' before tags. R=rsc, gri, lvd CC=golang-dev https://golang.org/cl/5129057
2011-07-26gc: disallow [...][...]int{{1,2,3}}Russ Cox
Fixes #1600. R=ken2 CC=golang-dev https://golang.org/cl/4819045
2011-05-31gc: disallow ... in type conversionsAnthony Martin
Fixes #1866. R=bradfitz, rsc CC=golang-dev https://golang.org/cl/4548073
2011-04-01gc: avoid saying same error 3 timesRuss Cox
R=ken2 CC=golang-dev https://golang.org/cl/4316051
2011-03-11go code: replace closed(c) with x, ok := <-cRuss Cox
R=golang-dev, rog, bradfitzwork, r CC=golang-dev https://golang.org/cl/4243072
2010-09-24gc: ... changesRuss Cox
R=ken2, ken3 CC=golang-dev https://golang.org/cl/2208047
2010-02-05Match gccgo error messages.Ian Lance Taylor
ddd1.go:16:10: error: argument 1 has incompatible type ddd1.go:17:10: error: argument 1 has incompatible type ddd1.go:15:10: error: floating point constant truncated to integer R=rsc CC=golang-dev https://golang.org/cl/204048
2010-02-01gc: ... T corner casesRuss Cox
more to come, but should suffice for Printf work. R=ken2 CC=golang-dev https://golang.org/cl/197044
2010-02-01gc: add ... T, rework plain ...Russ Cox
No longer a distinct type; now a property of func types. R=ken2 CC=golang-dev https://golang.org/cl/197042