Giter Club home page Giter Club logo

predeclared's Introduction

predeclared Build Status Godoc

Find code that overrides one of Go's predeclared identifiers (new, make, append uint, etc.).

The list of predeclared identifiers can be found in the spec.

go get github.com/nishanths/predeclared

See godoc or run predeclared without arguments to print usage.

Test

cd passes/predeclared && go test

Examples

Given a package with the file:

package pkg // import "example.org/foo/pkg"

func copy()  {}
func print() {}

func foo() string {
	string := "x"
	return string
}

type int struct{}

running:

predeclared example.org/foo/pkg

prints:

example.go:3:6: function "copy" has same name as predeclared identifier
example.go:4:6: function "print" has same name as predeclared identifier
example.go:7:2: variable "string" has same name as predeclared identifier
example.go:11:6: type "int" has same name as predeclared identifier

Running the program on the standard library's text package and subpackages produces:

$ predeclared text/...
/usr/local/go/src/text/template/parse/node.go:554:33: param "true" has same name as predeclared identifier
/usr/local/go/src/text/template/parse/node.go:599:3: variable "rune" has same name as predeclared identifier
/usr/local/go/src/text/template/funcs.go:164:36: param "cap" has same name as predeclared identifier
/usr/local/go/src/text/template/funcs.go:233:3: variable "cap" has same name as predeclared identifier
/usr/local/go/src/text/template/template.go:218:30: param "new" has same name as predeclared identifier
/usr/local/go/src/text/template/exec_test.go:232:21: param "error" has same name as predeclared identifier

predeclared's People

Contributors

alecthomas avatar dragonsinth avatar nishanths avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

predeclared's Issues

CI flake in our project, unclear why

A random flake in our predeclared setup happens not-infrequently in CI. Here's a recent example:

fullstorydev/emulators#68

https://app.circleci.com/pipelines/github/fullstorydev/emulators/143/workflows/c8fcf141-03e9-4688-ad6e-a8f78fff7439/jobs/486?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-checks-link&utm_content=summary

predeclared ./...
/home/circleci/repo/storage/gcsutil/gcspagetoken.pb.go:132:39: reflect.TypeOf(x{}).PkgPath undefined (type reflect.Type has no field or method PkgPath)
predeclared: analysis skipped due to errors in package
predeclared: analysis skipped due to errors in package
make: *** [Makefile:40: predeclared] Error 1

I have no intuition why a static checker would occasionally fail with something like this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.