aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/error_test.go
AgeCommit message (Collapse)Author
2022-09-20all: replace package ioutil with os and io in srcAndy Pan
For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-26cmd/compile/internal/syntax: check fallthrough in CheckBranches modeRobert Griesemer
The parser CheckBranches mode checked correct use of break, continue, and labels, but not of fallthrough statements. This CL adds checking of fallthrough statements as well. For #51456. Change-Id: I5000388011973724f80c59a6aaf015e3bb70faea Reviewed-on: https://go-review.googlesource.com/c/go/+/414134 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-03-30cmd/compile/internal/syntax: remove generic-specific parse modesRobert Griesemer
Generics have landed; we cannot revert the syntax anymore. Remove ability to choose between non-generic and generic code. Also remove mode to enable method type parameters. Adjust code accordingly. Also remove a couple of TODOs that are not relevant anymore. Remove tests from types2 which were focussed on method type parameters, make types2 and go/types tests match up where there was a difference in this regard. Change-Id: I989bdcb19eea7414214af739187fa013a044295d Reviewed-on: https://go-review.googlesource.com/c/go/+/396634 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-30cmd/compile/internal/syntax: use .go suffix for test files (cleanup)Robert Griesemer
- Use .go suffix for test files as go fmt doesn't descend into testdata directories. - Move test files from testdata/go2 into testdata directory. - Delete some test files that contained type-checker ERROR markers that were ignored by the TestParseGo2 test but would be considered by the TestSyntaxErrors test if the files were moved unchanged into the testdata directory. - Remove one (type checker) ERROR marker in testdata/slices.go to make it pass the syntax error tests. - Delete TestParseGo2 test. There's enough coverage with the existing TestSyntaxErrors test. - Add missing copyright notice to testdata/chans.go and gofmt the file. Change-Id: I449913fe1bd2119987ba33f7152e5e4ba5f3fe31 Reviewed-on: https://go-review.googlesource.com/c/go/+/396518 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-14cmd/compile/internal/syntax: remove AllowTypeSets modeRobert Griesemer
The respective issue has been accepted, so we can always accept constraint literals with omitted interfaces. For #48424. Change-Id: Ia3d325401252a5a22d5ffa98d2ae6af73178dec0 Reviewed-on: https://go-review.googlesource.com/c/go/+/355709 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-06cmd/compile/internal/syntax, types2: remove ability to handle type listsRobert Griesemer
The type set notation has been accepted a while ago. We're not going back to supporting the original type list notation. Remove support for it in the parser and type checker. Change-Id: I860651f80b89fa43a3a5a2a02cf823ec0dae583c Reviewed-on: https://go-review.googlesource.com/c/go/+/354131 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-01cmd/compile/internal/syntax: allow eliding interface in constraint literalsRobert Griesemer
This CL permits an arbitrary type as well as the type sets ~T and A|B in constraint position, without the need of a surrrounding interface. For instance, the type parameter list [P interface{ ~map[K]V }, K comparable, V interface{ ~string }] may be written as [P ~map[K]V, K comparable, V ~string] The feature must be enabled explicitly with the AllowTypeSets mode and is only available if AllowGenerics is set as well. For #48424. Change-Id: Ic70bb97a49ff75e67e040853eac10e6aed0fef1a Reviewed-on: https://go-review.googlesource.com/c/go/+/353133 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-24cmd/compile/internal/syntax: assume generic code for std libRobert Griesemer
Also: improve some error message prints in testSyntaxErrors. Change-Id: Iaa1d642398fa82975fefb4bde54f476dd5229eb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/351791 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-02cmd/compile: disable type list syntax for the compilerRobert Griesemer
Add (temporary) syntax.AllowTypeLists mode to control the acceptance of type lists; the compiler doesn't set it, but existing syntax and types2 tests do so that the code remains exercised while it exists. Adjust various tests to use the type set notation. Change-Id: I798e607912552db6bfe38a7cd4324b74c6bf4d95 Reviewed-on: https://go-review.googlesource.com/c/go/+/347249 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-10cmd/compile/internal/syntax: accept "~" and "|" interface elementsRobert Griesemer
Type lists continue to be accepted as before. While at it, print missing filenames in error tests (which uses an ad-hoc position representation). Change-Id: I933b3acbc9cf1985ad8f70f6b206e3a1dbd64d1e Reviewed-on: https://go-review.googlesource.com/c/go/+/307371 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-16[dev.typeparams] cmd/compile/internal/syntax: type parameters must always be ↵Robert Griesemer
named Report an error otherwise. Change-Id: Ia76ea03a3f26b13dd9bca49f7bd42101d1ff1f9e Reviewed-on: https://go-review.googlesource.com/c/go/+/278475 Trust: Robert Griesemer <gri@golang.org> Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2018-02-12cmd/compile/internal/syntax: implement regression test harness for syntax errorsRobert Griesemer
R=go1.11 Fixes #20800. Change-Id: Ifea273521d42a543a43da2f655ace7c295650e30 Reviewed-on: https://go-review.googlesource.com/88335 Reviewed-by: Matthew Dempsky <mdempsky@google.com>