goimports to use the package name as a local qualifier in an import.
For example, if findImports("pkg", "X") returns ("foo/bar",
rename=true), then goimports adds the import line:
import pkg "foo/bar"
to satisfy uses of pkg.X in the file.
This change doesn't add any implementations of rename=true, though one
is sketched in a TODO.
LGTM=crawshaw
R=crawshaw, rsc
CC=bradfitz, golang-codereviews
https://golang.org/cl/76400050
This change allows code to be sent safely to a partially sandboxed playground using the Native Client environment.
Execution of non-Go code is blocked when the RunScripts is false to prevent inclusion of code that might escape by virtue of being under a different runtime environment.
Two options for communicating whether to prevent non-Go code were considered: as has been done here and alternatively, using a message field. The latter was not chosen to close that as an attack option.
Another will be follow that adds a -nacl flag to the present command to allow sandboxing of playground code in presentations.
See discussion here: https://groups.google.com/d/topic/golang-dev/Hy-7PBP-T4Q/
LGTM=adg
R=adg, dave
CC=golang-codereviews
https://golang.org/cl/74740045
See analysis.go for overview of new features.
See README for known bugs and issues.
Much UI polish, testing and optimization work remains, but
this is a starting point.
Flag: we add a new flag -analysis=type,pointer, default "",
for adventurous users only at this stage.
Type analysis takes ~10s for stdlib + go.tools;
Pointer analysis (currently) takes several minutes.
Dependencies: we now include jquery.treeview.js and its GIF
images among the resources. (bake.go now handles binary.)
LGTM=crawshaw, bgarcia
R=crawshaw, bgarcia
CC=bradfitz, golang-codereviews
https://golang.org/cl/60540044
Also, add loader.Config.DisplayPath hook, which allows the
filename returned by build.Context.Import() to be transformed
prior to attaching to the AST. This allows a virtual file
system to be used without leaking into the user interface.
Eliminate parsePackageFiles hook; I don't think we need it any
more. The test that was using it has been rewritten to use
the build.Context hooks.
LGTM=gri
R=gri, crawshaw
CC=daniel.morsing, golang-codereviews, rsc
https://golang.org/cl/75520046
With this CL, an Object.Parent() Scope is always the scope in
which the object was originally declared. For dot-imported
objects, that is the package scope of the package from which
the objects are imported (not the file scope into which they
are imported).
Also:
- Changed Scope.Insert to be agnostic regarding blank
identifiers - blank identifiers must be handled outside.
- Fixed handling of blank labels: they are never declared.
Fixesgolang/go#7537.
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/75570043
It's pointless.
Also this fixes a crash, because the blank identifier no longer appears as a
defined object after CL 74190043 so we were getting nil pointer violations.
Even better, we get to re-enable a disabled test.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/75140043
e.g. file foo.go scope {...}
package math scope {...}
function f scope {...}
if scope {...}
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/74320043
1) Killing proceses on timeout was wrong: the os/exec
package will never return our package's error type
from its Wait.
2) fix a goroutine leak on timeout.
3) unexported an undocumented and elsewhere-unused type.
4) rename timeout type to end in "Error", per convention,
not Err.
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/74290043
If we are building, for example, linux/386 on a linux/amd64 machine we want to make sure that the whole build is done as a if this were compiled on a real linux/386 machine. In other words, we want to not do a cross compilation build.
The exception to this rule is when we are doing nacl builds. These are by definition always cross compilation, and we have support built into cmd/go to be able to handle this case.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/74230043
This change renumbers nodes so that addressable ones
(that may appear in a points-to set) all have lower
numbers than non-addressable ones----initially at least:
reflection, SetFinalizer, etc add new nodes during
solving.
This improves the efficiency of sparse PTS
representations (to be added later). The largest int in
a PTS is now about 20% of the previous max.
Overview:
- move constraint stuff into constraint.go.
- add two methods to constraint:
(1) renumber(): renumbers all nodeids. The
implementations are very repetitive but simple. I
thought hard about other ways (mixins, reflection)
but decided this one was fine.
(2) indirect(): report the set of nodeids whose
points-to relations depend on the solver, not just
the initial constraint graph.
(This method is currently unused and is logically
part of a forthcoming change to implement PE/LE
presolver optimizations. (Perhaps I should comment
it out/remove it for now.)
- split up the population of the intrinsics map by file.
- delete analysis.probes (unused field)
- remove state="..." from panic message; unnecessary.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/73320043
Now that go/types permits files to be added to a package
incrementally (fixing bug 7114), this CL extends the loader
to load and augment multiple test packages at once.
TESTED:
- go/loader/stdlib_test runs the type-checker on the entire
standard library loaded from source in a single gulp, with
each package augmented by tests.
- Manually tested on:
% ssadump -test -run unicode encoding/ascii85
Both sets of tests are run (and pass).
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/61060043
With this CL, it is now possible to type-check additional
package files to an already type-checked package through
repeated calls to Checker.Files.
Fixesgolang/go#7114.
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/72730043
Now we can say
vet -printf=false
to disable the printf test but run all others.
Implemented by creating a tri-state boolean flag that records whether it has been
set explicitly; before this, -printf=false was not distinguishable from not having
mentioned the printf flag at all.
Fixesgolang/go#7422.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72330043
Over time, a number of modules were added that used Warn instead of Bad
to report problems with the code, but the documentation states that
if there is a problem, the exit code must be 1, not 0. Warn does not set the
exit code and should be used only for internal errors and messages
triggered by the -v flag.
There's nothing substantive here except calling the other function in a few
places.
Fixesgolang/go#7017.
LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/71860044
Provide an extra field, "Soft" in types.Error.
A client may want to filter out soft errors and
only abort if there are "hard" errors.
Qualified a first set of errors as "soft".
Fixesgolang/go#7360.
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/71800043
Also:
- slightly better error messages for return statements
- more AST validity checking of parameter lists
- use secondary error message for clarifying message in type switch errors
Fixesgolang/go#7469.
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/71780044
The parser may return error positions referring to positions
immediately after rather than at a token position. Provide
mechanism to identify those positions in test cases.
Also: Don't compute position strings for each token in test
cases. Should speed up Check test.
Pending CL 70190046 in main repo.
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/71330043
(On Windows the two are not the same.)
Fixesgolang/go#7189.
Also: remove exception for code.google.com subtree; this was
an artifact of my unusual setup.
LGTM=gri
R=alex.brainman, gri
CC=golang-codereviews
https://golang.org/cl/70060048
The old code was misleading in saying how many args were present.
Change the wording of the message to be unambiguous and change
the presentation of the format to include the full directive, making
it easier to correlate with the input (and fixing a silent bug).
Fixesgolang/go#6248.
LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/69120044
Before, they were named func@line:col which made them easy to find in the source if you know the file, but hard if you don't, and it made tests fragile.
Now, they are named outer$1, outer$2, etc, which makes them
more informative in a UI since "outer" has meaning.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/65630048
This is to avoid an internal error in pointer analysis from
bringing down a long-lived application such as godoc.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/68930046
An identifier X in anonymous struct field struct{X} is both a
definition of a field (*Var) and reference to a type
(*TypeName). Now that we have split the map, we can capture
both of these aspects.
Interestingly, every client but one was going to extra effort
to iterate over just the uses or just the defs; this
simplifies them.
Also, fix two bug related to tagless switches:
- An entry was being recorded in the Object map for a piece of
synthetic syntax.
- The "true" identifier was being looked up in the current scope,
which allowed perverse users to locally redefine it. Now
we use the bool (not untyped boolean) constant true, per the
consequent clarification of the spec (issue 7404).
+ tests.
Fixesgolang/go#7276
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/68270044