44d1a8523a
This CL implements a number of minor fixes that were discovered in getting -G=3 working for running all.bash. 1. Field tags were handled incorrectly. If a struct type had some fields with tags, but later fields without tags, the trailing tag-less fields would all copy the tag of the last tagged field. Fixed by simply reinitializing `tag` to "" for each field visited. 2. Change the ending of switch case clause scopes from the end of the last statement to the next "case" token or the switch-ending "}" token. I don't think this is strictly necessary, but it matches my intuition about where case-clause scopes end and cmd/compile's current scoping logic (admittedly influenced by the former). 3. Change select statements to correctly use the scope of each individual communication clause, instead of the scope of the entire select statement. This issue appears to be due to the original go/types code being written to rebind "s" from the *SelectStmt to the Stmt in the range loop, and then being further asserted to "clause" of type *CommClause. In most places within the loop body, "clause" was used, but the rebound "s" identifier was used for the scope boundaries. However, in the syntax AST, SelectStmt directly contains a []*CommClause (rather than a *BlockStmt, with []Stmt), so no assertion is necessary and instead of rebinding "s", the range loop was updated to directly declare "clause". 4. The end position for increment/decrement statements (x++/x--) was incorrectly calculated. Within the syntax AST, these are represented as "x += ImplicitOne", and for AssignStmts types2 calculated the end position as the end position of the RHS operand. But ImplicitOne doesn't have any position information. To workaround this, this CL detects ImplicitOne and then computes the end position of the LHS operand instead, and then adds 2. In practice this should be correct, though it could be wrong for ill-formatted statements like "x ++". Change-Id: I13d4830af39cb3f3b9f0d996672869d3db047ed2 Reviewed-on: https://go-review.googlesource.com/c/go/+/282914 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> |
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
AUTHORS | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
favicon.ico | ||
LICENSE | ||
PATENTS | ||
README.md | ||
robots.txt | ||
SECURITY.md |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.