1
0
mirror of https://github.com/golang/go synced 2024-10-01 13:18:33 -06:00
Commit Graph

3059 Commits

Author SHA1 Message Date
Andrew Gerrand
61d86e98d5 go.tools/cmd/vet: check for recursive stringers
Fixes golang/go#6129.

R=r
CC=golang-dev
https://golang.org/cl/12936046
2013-08-21 11:07:53 +10:00
Brad Fitzpatrick
3e29592dba cmd/vet: move whitelist to its own package
App Engine needs the whitelist file and it's cleaner if it's
in its own package where it can be imported directly, without
pushing composite.go through a pile of sed.

R=dsymonds, r
CC=golang-dev
https://golang.org/cl/12746045
2013-08-20 15:39:49 -07:00
Alan Donovan
99ac9493e1 go.types/ssa: add back Signature.Recv to interface method wrappers.
It is needed after all, as I discovered in the pointer analysis.
(ssa needs more API test coverage.)

Also:
- sanity: remove debugging cruft
- promote: don't redundantly include the function's
  own name in its Synthetic string.
- print: IntuitiveMethodSet utility fixes a bug in the
  printing logic (for interface types, mset(*T) is empty).
  The function is also used by the Oracle.

R=crawshaw
CC=golang-dev
https://golang.org/cl/13116043
2013-08-20 14:50:13 -04:00
Andrew Gerrand
74ecc2c09b go.tools/cmd/vet: detect useless function comparisons
Also fix bug in types.go discovered by this check.

Fixes golang/go#5347.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/13102043
2013-08-20 16:11:01 +10:00
Brad Fitzpatrick
7c5549876e cmd/godoc: don't parse HTML templates in command-line mode
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12956044
2013-08-19 22:29:56 -07:00
Andrew Gerrand
4e1a4d9fde go.tools/go/types: fix bad function comparison
Issue found by vet -nilfunc.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12816044
2013-08-20 15:26:04 +10:00
Alan Donovan
5cbf2abd36 go.tools/ssa: ensure address-deriving operations panic on nil inputs.
&x.f, &x[0], x[i:j], &*x all must panic if x==nil.

The first three are already addressed by the semantics of
FieldAddr, IndexAddr, Slice; updated docs to reflect this.
The final case requires generation of an additional dynamic check.

See golang.org/s/go12nil for details.

Tested on $GOROOT/test/nilptr2.go (with patch from CL 13108043)

Also: remove a TODO where a no-op will do.

R=gri, crawshaw
CC=golang-dev, rsc
https://golang.org/cl/13064044
2013-08-19 17:51:33 -04:00
Alan Donovan
7072253af5 go.tools/ssa: fixes, cleanups, cosmetic tweaks.
Fix bug: the Signature for an interface method wrapper
erroneously had a non-nil receiver.

Function:
- Set Pkg field non-nil even for wrappers.
  It is equal to that of the wrapped function.
  Only wrappers of error.Error
  (and its embeddings in other interfaces) may have nil.
  Sanity checker now asserts this.
- FullName() now uses .Synthetic field to discriminate
  synthetic methods, not Pkg==nil.
- Fullname() uses new relType() utility to print receiver type
  name unqualified if it belongs to the same package.
  (Alloc.String also uses relType utility.)

CallCommon:
- Description(): fix switch logic broken when we
  eliminated the Recv field.
- better docs.

R=david.crawshaw, crawshaw, gri
CC=golang-dev
https://golang.org/cl/13057043
2013-08-19 15:38:30 -04:00
Alan Donovan
df0c50c614 go.tools/importer: retain scope information.
(It's needed by the oracle.)

R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/13071043
2013-08-19 15:14:13 -04:00
Alan Donovan
50bd0e3288 go.tools/ssa: synthesize main functions for test packages.
Package.CreateTestMainFunction() creates a function called
main and adds it to the package.  This function calls
testing.Main in the Go library with the appropriate arguments:
slices of test, benchmark and example functions from the
package.

Tested by running the interpreter on the following tests:
- unicode/script_test.go
- unicode/digit_test.go
- hash/crc32/crc32_test.go
- path/path_test.go

It's also covered indirectly via the pointer analysis.

R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/12814046
2013-08-19 15:00:25 -04:00
Alan Donovan
3b53279d8f go.tools/ssa: preserve type of &&/|| operands in result.
+ test.

With this change, the Go Oracle is now self-aware. :)

R=gri, rsc
CC=golang-dev
https://golang.org/cl/12381043
2013-08-19 12:50:40 -04:00
Dave Cheney
41a15a3013 go.tools/go/vcs: do not delete $TMPDIR during test runs
The test would nuke the entire contents of os.TempDir on completion.

This change corrects the code to use ioutil.TempDir.

R=r, adg
CC=golang-dev
https://golang.org/cl/12796045
2013-08-19 16:22:31 +10:00
David Symonds
a7c698b070 undo CL 12811043 / 44387735a77d
Not the right thing to do.
Fixes golang/go#6148.

««« original CL description
cmd/vet: flag redundant invocations of String and Error methods in printf calls.

R=r
CC=golang-dev
https://golang.org/cl/12811043
»»»

R=r
CC=golang-dev
https://golang.org/cl/13034043
2013-08-19 11:12:44 +10:00
Brad Fitzpatrick
1633383a2b cmd/godoc: don't start up indexer in command-line mode
Fixes golang/go#6075

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12995044
2013-08-16 19:49:24 -07:00
Andrew Gerrand
32acd2b372 go.tools/cmd/godoc: redirect old pkg/cmd paths
fixes golang/go#5317.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12869046
2013-08-16 13:44:52 +10:00
Andrew Gerrand
562e4faeca cmd/godoc: bake templates and scripts into godoc binary
Add godoc/vfs/mapfs package for serving baked files.

Fixes golang/go#6010.

R=golang-dev, bradfitz, r, arnehormann, rsc
CC=golang-dev
https://golang.org/cl/12978043
2013-08-16 11:44:27 +10:00
Chris Manghane
dfa65ded17 go.tools: add go/vcs
go/vcs exposes cmd/go/vcs.go from the `go get` command.

- Exported global variables `Verbose` and `ShowCmd` to replace `buildV` and `buildX` from cmd/go/main.go.
- Moved environment building code (envForDir, mergeEnvLists)from cmd/go/main.go to env.go
- Exported Cmd and its methods: Create, Download, Ping, TagSync, and Tags
- Exported ByCmd and FromDir functions for constructing Cmd
- Exported TagCmd
- Exported RepoRoot
- Exported RepoRootForImport* functions for constructing RepoRoot

R=golang-dev, adg, cmang, bradfitz
CC=golang-dev
https://golang.org/cl/12058054
2013-08-15 09:00:02 -07:00
Robert Griesemer
ae874abc7a go.tools/go/types: *interface types have no methods
Fixes golang/go#5918.

R=adonovan
CC=golang-dev
https://golang.org/cl/12909043
2013-08-14 11:02:10 -07:00
Robert Griesemer
0b3996b1d3 go.tools/ssa/interp: add missing "external" (fix build)
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12898043
2013-08-13 15:00:07 -07:00
David Symonds
c0b6badc83 cmd/vet: flag redundant invocations of String and Error methods in printf calls.
R=r
CC=golang-dev
https://golang.org/cl/12811043
2013-08-13 13:47:58 +10:00
Robert Griesemer
d13d94afe7 go.tools/go/types: do rounding in constant numeric conversions
- cleaned up surrounding code
- adjusted error message positions for too few/many argument errors
- added more conversion tests
- added all tests under test/ken to std tests

R=adonovan, r
TBR=adonovan
CC=golang-dev
https://golang.org/cl/12711043
2013-08-12 14:57:08 -07:00
Robert Griesemer
508ae115ae go.tools/go/types: added missing test for file scopes
R=adonovan, r
CC=golang-dev
https://golang.org/cl/12671044
2013-08-08 20:54:28 -07:00
Rob Pike
28fe5aa8d3 go.tools/cmd/cover: s/ParseInt/Atoi/
So people stop asking me to do this.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12691044
2013-08-09 13:48:46 +10:00
Robert Griesemer
2449594308 go.tools/go.types: retain ast.Node links on demand only
- support Info.Scopes mapping that maps ast.Nodes
  to the respective *Scope
- remove old node link from *Scope
- added corresponding API test

Also: re-enable debug mode (the faster version was
only important for the go api tool, which  has its
own version now).

R=adonovan, r
CC=golang-dev
https://golang.org/cl/12552047
2013-08-08 20:27:15 -07:00
Rob Pike
4622486b62 go.tools/cmd/cover: add -func mode to print per-function coverage
fmt/format.go:	init			100.0%
fmt/format.go:	clearflags		100.0%
fmt/format.go:	init			100.0%
fmt/format.go:	computePadding		84.6%
fmt/format.go:	writePadding		83.3%
...
total:		(statements)		91.3%

Fixes golang/go#5985.

R=golang-dev, dave, gri
CC=golang-dev
https://golang.org/cl/12454043
2013-08-09 12:55:21 +10:00
Robert Griesemer
875ff2496f go.tools/go/types: support for fake imports of package "C"
Also:
- cleaner method set printing
- disable debug mode internally (50% faster)

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12578043
2013-08-07 14:09:50 -07:00
Robert Griesemer
56b9e46247 go.tools/go/types: fewer guarantees in case of type errors
Provide fewer guarantees regarding the collected result
type information in types.Info if there are type errors.

Specifically, don't record nil objects in the Objects map
in case of a declaration error; instead, simply omit them.

R=adonovan
TBR=adonovan
CC=golang-dev
https://golang.org/cl/12553043
2013-08-06 11:27:05 -07:00
Rob Pike
75920173e4 go.tools/go/types: don't put an interface nil into the Objects map
If a method cannot type check, we end up with the interface variable
m to hold <*Func, nil>. Don't put that in the map because it defeats
the usual != nil check.

R=gri, dsymonds
CC=golang-dev
https://golang.org/cl/12506043
2013-08-06 16:19:10 +10:00
Robert Griesemer
45e3d57f32 go.tools/cmd/vet: enable test (fix build)
R=r
TBR=r
CC=golang-dev
https://golang.org/cl/12482043
2013-08-05 14:02:52 -07:00
Robert Griesemer
b956928b06 go.tools/go/types: Fix for broken IsAssignableTo.
Was broken by CL 12378043.

- factored out some error checking code
- adjusted error positions

R=adonovan
TBR=adonovan
CC=golang-dev
https://golang.org/cl/12401043
2013-08-05 13:54:22 -07:00
David Symonds
1dce9cc7c7 go/types: exclude a couple of files from the stdlib test that don't parse on Windows.
They use stuff in syscall that doesn't exist on Windows, and this test does not
parse build tags (not that we make that easy) to automatically skip them.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/12453043
2013-08-05 13:54:22 +10:00
Rob Pike
c333e7a7b6 go.tools/cmd/vet: fix go.tools build
TBR: gri

I cannot create an issue on the tracker for some reason, so here it is:
go vet contains this snippet:

        if types.IsAssignableTo(typ, errorType) || types.IsAssignableTo(typ, stringerType) {

It's getting the wrong answer: It claims

interface {
        f()
}

or even

interface {
        f() float64
}

matches the Error and Stringer interfaces. Both of them.  This causes a test failure:
$ go test code.google.com/p/go.tools/cmd/vet
BUG: errchk: testdata/print.go:124: missing expected error: '"for printf verb %s of wrong type"'
$
This worked until very recently.

R=gri
CC=golang-dev
https://golang.org/cl/12398043
2013-08-03 15:56:56 +10:00
Rob Pike
aecec2f502 go.tools/cmd/vet: the composite test is about keys, not tags
Fix the confusion.
No semantic change, just some renamings.

Fixes golang/go#6017.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12394043
2013-08-03 12:19:59 +10:00
Robert Griesemer
3209d6ad73 go.tools/go/types: fix interface vs interface type assertion
R=adonovan
CC=golang-dev
https://golang.org/cl/12378043
2013-08-02 14:37:19 -07:00
Robert Griesemer
e06b897351 go.tools/go/types: mark imported named types as 'complete'
Fixes "illegal cycle" error for: go tool vet -v pkg/unicode.

R=adonovan
CC=golang-dev
https://golang.org/cl/12355043
2013-08-02 09:33:37 -07:00
Rob Pike
797431e1a3 go.tools/cmd/vet: fix printf analysis for structs.
The old code only got it right for Stringers (etc.) and a few other simple cases.
But the rule used by fmt.Printf for non-Stringers is that pointers to structs
print as pointers, the rest must satisfy the format verb element-wise.
Thus for example
        struct {a int, b []byte}
prints with %d and %q (sic) but not %g.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12340043
2013-08-02 22:52:38 +10:00
Alex Brainman
4ff367ac3c go.tools/ssa: fix windows build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12320043
2013-08-02 16:25:49 +10:00
Robert Griesemer
4ceda807d5 go.tools/go/types: add mode to typecheck pkg-level decls only
This is useful for situations where one only cares about
exports, for instance (as in the goapi checker).

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/12292043
2013-08-01 16:37:56 -07:00
Alan Donovan
61a33ecd43 go.tools/go/types: fix: the type of a method value should not have a reciever
e.g.
type T int
func (T) f() {}
var t T
_ = t.f  // method value: should have signature "func()", no receiver

Also:
- ssa: add sanity check that helped diagnose this.

R=gri
CC=golang-dev
https://golang.org/cl/12283043
2013-08-01 15:38:41 -04:00
Alan Donovan
5cc33ea5a7 go.tools/ssa: cosmetic changes to ssa.Alloc.
Remove its 'name' field and treat it just like any other
ssa.Register: it gets a temp name like "t1".

Instead, give it a comment field holding its purpose, e.g, "x"
for a source-level vare, or "new", "slicelit", "complit" or
"varargs".

This improves usability of tools whose UI needs to refer to a
particular allocation site.

R=gri
CC=golang-dev
https://golang.org/cl/12273043
2013-08-01 14:06:10 -04:00
Andrew Gerrand
8d55039560 go.tools/cmd/godoc: fix typo
R=golang-dev
CC=golang-dev
https://golang.org/cl/12238043
2013-08-01 17:43:31 +10:00
Andrew Gerrand
37c18cdcf3 go.tools/cmd/godoc: start indexer in app engine mode
R=golang-dev
CC=golang-dev
https://golang.org/cl/12237044
2013-08-01 17:37:20 +10:00
Andrew Gerrand
0830cbddc9 go.talks/cmd/godoc: add jquery.js and style.css
Somehow missed these.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12233043
2013-08-01 17:36:56 +10:00
Andrew Gerrand
0afeff2d4b go.tools/cmd/godoc: add godocs.js and playground.js from core repo
The originals will be removed.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12219043
2013-08-01 15:08:46 +10:00
Chris Manghane
a705311956 go.tools: add dashboard
Moving misc/dashboard to its new home. It will be deleted
(except for misc/dashboard/codereview) from its current home
if this is approved.

R=golang-dev, bradfitz, cmang, adg
CC=golang-dev
https://golang.org/cl/12180043
2013-08-01 13:23:51 +10:00
Robert Griesemer
caf3fc90ed go.tools/go/types: test against test/fixedbugs
Fixed several bugs:
- lhs blank identifier may be parenthesized: (_) = 0 is ok
- constant shift counts in non-constant shifts must be >= 0
- init functions must have a body

Classified currently failing tests:
- 10 classes of errors not checked at the moment

R=adonovan, r
CC=golang-dev
https://golang.org/cl/11952046
2013-07-31 20:08:18 -07:00
Folke Behrens
976d735966 go.tools/godoc: Fix jump-to-line in source view.
Remove the empty anchor element and add the line ID (Lnnn)
to the span element that contains the line number.
Fixes golang/go#5903.
Fixes golang/go#5977.

R=adg
CC=bradfitz, golang-dev
https://golang.org/cl/12189043
2013-08-01 11:52:25 +10:00
Alan Donovan
e7016436a6 go.tools/ssa: accommodate go/types changes to value,ok-mode inferred types.
The required changes were surprisingly minimal (I was hoping for a net
code deletion) because ssa is essentially doing its own type inference
for the three value,ok operators---and it continues to have to do so.
To see why, consider:

  var i interface{}; var ok bool
  i, ok := (map[string]string)(nil)[""]

Before, go/types inferred interface{} for the RHS of the assignment,
and now it infers (interface{}, bool), yet neither of these is what
ssa needs: it needs to know that the map values were strings so
that it can emit a lookup of the right type followed by a conversion
from string to interface{}.

TBR=gri
CC=golang-dev
https://golang.org/cl/11988044
2013-07-31 21:31:46 -04:00
Andrew Gerrand
508186a765 go.tools/cmd/godoc: copy templates from $GOROOT/lib/godoc
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12209043
2013-08-01 11:01:10 +10:00
Robert Griesemer
ae07aa6055 go.tools/go/types: return typed bool for comma-ok expressions
Also: determine default types for assignments of the form: _ = x .

R=adonovan
CC=golang-dev
https://golang.org/cl/12186043
2013-07-31 12:49:34 -07:00