Skip to content

Commit

Permalink
Don't remove const and type declarations in Go code
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jun 12, 2024
1 parent b8332c6 commit 48b81c9
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 682 deletions.
6 changes: 5 additions & 1 deletion frameworks/src/go/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ fn valid_field_id(field_name: &str) -> u16 {
static BLOCK_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("block"));
static BREAK_STATEMENT_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("break_statement"));
static CALL_EXPRESSION_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("call_expression"));
static CONST_DECLARATION_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("const_declaration"));
static CONTINUE_STATEMENT_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("continue_statement"));
static DEFER_STATEMENT_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("defer_statement"));
static IDENTIFIER_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("identifier"));
static RETURN_STATEMENT_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("return_statement"));
static SELECTOR_EXPRESSION_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("selector_expression"));
static SHORT_VAR_DECLARATION_KIND: Lazy<u16> =
Lazy::new(|| non_zero_kind_id("short_var_declaration"));
static TYPE_DECLARATION_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("type_declaration"));
static VAR_DECLARATION_KIND: Lazy<u16> = Lazy::new(|| non_zero_kind_id("var_declaration"));

fn non_zero_kind_id(kind: &str) -> u16 {
Expand Down Expand Up @@ -320,7 +322,9 @@ impl ParseLow for Go {
_storage: &std::cell::RefCell<<Self::Types as AbstractTypes>::Storage<'ast>>,
statement: <Self::Types as AbstractTypes>::Statement<'ast>,
) -> bool {
statement.0.node.kind_id() == *SHORT_VAR_DECLARATION_KIND
statement.0.node.kind_id() == *CONST_DECLARATION_KIND
|| statement.0.node.kind_id() == *SHORT_VAR_DECLARATION_KIND
|| statement.0.node.kind_id() == *TYPE_DECLARATION_KIND
|| statement.0.node.kind_id() == *VAR_DECLARATION_KIND
}

Expand Down
433 changes: 0 additions & 433 deletions necessist/tests/third_party_tests/0/chainlink.stdout

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
106 candidates in 17 tests in 2 test files
102 candidates in 17 tests in 2 test files
$DIR/src/encoding/base64/base64_test.go: dry running
$DIR/src/encoding/base64/base64_test.go: mutilating
$DIR/src/encoding/base64/base64_test.go: `.enc.EncodeToString([]byte(p.decoded))` nonbuildable
Expand Down Expand Up @@ -52,33 +52,21 @@ $DIR/src/encoding/base64/base64_test.go: `.Decode(dbuf, []byte(tc.input))` nonbu
$DIR/src/encoding/base64/base64_test.go: `testEqual(t, "Corruption in %q at offset %v, want %v", tc.input, int(err), tc.offset)` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `.EncodeToString(buf[:])` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `.Decode(buf[:], []byte(s))` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `type test struct {
enc *Encoding
n int
want int64
}` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, (math.MaxInt-5)/8 + 1, 357913942})` passed
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, math.MaxInt/4*3 + 2, math.MaxInt})` passed
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, (math.MaxInt-5)/8 + 1, 1537228672809129302})` passed
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, math.MaxInt/4*3 + 2, math.MaxInt})` passed
$DIR/src/encoding/base64/base64_test.go: `.enc.EncodedLen(tt.n)` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `type test struct {
enc *Encoding
n int
want int64
}` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, math.MaxInt/6 + 1, 268435456})` passed
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, math.MaxInt, 1610612735})` passed
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, math.MaxInt/6 + 1, 1152921504606846976})` passed
$DIR/src/encoding/base64/base64_test.go: `tests = append(tests, test{RawStdEncoding, math.MaxInt, 6917529027641081855})` passed
$DIR/src/encoding/base64/base64_test.go: `.enc.DecodedLen(tt.n)` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `const alpha = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `raw[i] = alpha[i%len(alpha)]` passed
$DIR/src/encoding/base64/base64_test.go: `.Write(raw)` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `err = w.Close()` failed
$DIR/src/encoding/base64/base64_test.go: `.ReadAll(NewDecoder(StdEncoding, encoded))` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `.Equal(raw, decoded)` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `const expected = "sure"` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `.DecodeString(e)` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `.New("my error")` nonbuildable
$DIR/src/encoding/base64/base64_test.go: `next <- nextRead{5, nil}` passed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
112 candidates in 30 tests in 3 test files
105 candidates in 30 tests in 3 test files
$DIR/src/encoding/binary/binary_test.go: dry running
$DIR/src/encoding/binary/binary_test.go: mutilating
$DIR/src/encoding/binary/binary_test.go: `.NewReader(src)` nonbuildable
Expand Down Expand Up @@ -62,29 +62,15 @@ $DIR/src/encoding/binary/binary_test.go: `.Range(func(_, _ any) bool {
})` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `i++` failed
$DIR/src/encoding/binary/binary_test.go: `total += delta` failed
$DIR/src/encoding/binary/binary_test.go: `type foo struct {
A uint32
}` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `type bar struct {
A Struct
B foo
C Struct
}` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.TypeOf(data)` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.String()` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `read(0)` passed
$DIR/src/encoding/binary/binary_test.go: `read(&s)` passed
$DIR/src/encoding/binary/binary_test.go: `const data = "0123456789abcdef"` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `errWant = io.EOF` failed
$DIR/src/encoding/binary/binary_test.go: `errWant = nil` passed
$DIR/src/encoding/binary/binary_test.go: `errWant = io.ErrUnexpectedEOF` failed
$DIR/src/encoding/binary/binary_test.go: `.NewReader(data[:i])` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.NewReader(data[:i])` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `type byteOrder interface {
ByteOrder
AppendByteOrder
}` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `const offset = 3` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.Float64bits(math.Pi)` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.Float64bits(math.E)` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `order.PutUint16(buf[:2], want16)` failed
Expand All @@ -106,12 +92,6 @@ $DIR/src/encoding/binary/binary_test.go: `buf = order.AppendUint64(buf[:offset],
$DIR/src/encoding/binary/binary_test.go: `.AppendUint64(buf[:offset], want64)` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.Uint64(buf[offset:])` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `testReadInvalidDestination(t, BigEndian)` passed
$DIR/src/encoding/binary/binary_test.go: `type Person struct {
Age int
Weight float64
Height float64
}` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `const val = 0x12345678` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.Slice((*byte)(unsafe.Pointer(&i)), unsafe.Sizeof(i))` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.Pointer(&i)` nonbuildable
$DIR/src/encoding/binary/binary_test.go: `.Sizeof(i)` nonbuildable
Expand Down
4 changes: 1 addition & 3 deletions necessist/tests/third_party_tests/0/go_src_mime.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
337 candidates in 56 tests in 12 test files
331 candidates in 56 tests in 12 test files
$DIR/src/mime/encodedword_test.go: dry running
$DIR/src/mime/encodedword_test.go: mutilating
$DIR/src/mime/encodedword_test.go: `.Repeat("é", 10)` nonbuildable
Expand Down Expand Up @@ -205,8 +205,6 @@ $DIR/src/mime/type_test.go: `clearMimeTypes()` passed
$DIR/src/mime/type_test.go: `setType(".foo", "x/foo")` failed
$DIR/src/mime/type_test.go: `setType(".bar", "x/bar")` failed
$DIR/src/mime/type_test.go: `setType(".Bar", "x/bar; capital=1")` failed
$DIR/src/mime/type_test.go: `const custom = "test/test; charset=iso-8859-1"` nonbuildable
$DIR/src/mime/type_test.go: `const caps = "test/test; WAS=ALLCAPS"` nonbuildable
$DIR/src/mime/type_test.go: `clearMimeTypes()` passed
$DIR/src/mime/type_test.go: `setType(".TEST", caps)` failed
$DIR/src/mime/type_test.go: `setType(".tesT", custom)` failed
Expand Down
4 changes: 1 addition & 3 deletions necessist/tests/third_party_tests/0/go_src_net_url.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
74 candidates in 25 tests in 2 test files
72 candidates in 25 tests in 2 test files
$DIR/src/net/url/url_test.go: dry running
$DIR/src/net/url/url_test.go: mutilating
$DIR/src/net/url/url_test.go: `.DeepEqual(u, tt.out)` nonbuildable
Expand Down Expand Up @@ -105,7 +105,6 @@ $DIR/src/net/url/url_test.go: `.Run(test.query, func(t *testing.T) {
})` nonbuildable
$DIR/src/net/url/url_test.go: `want = "<nil>"` passed
$DIR/src/net/url/url_test.go: `.url.RequestURI()` nonbuildable
$DIR/src/net/url/url_test.go: `const url = "%gh&%ij"` nonbuildable
$DIR/src/net/url/url_test.go: `.Sprint(err)` nonbuildable
$DIR/src/net/url/url_test.go: `.Contains(errStr, "%gh")` nonbuildable
$DIR/src/net/url/url_test.go: `.RequestURI()` nonbuildable
Expand All @@ -131,7 +130,6 @@ $DIR/src/net/url/url_test.go: `.User.Password()` nonbuildable
$DIR/src/net/url/url_test.go: `.User.String()` nonbuildable
$DIR/src/net/url/url_test.go: `.Sprint(err)` nonbuildable
$DIR/src/net/url/url_test.go: `.Contains(got, wantsub)` nonbuildable
$DIR/src/net/url/url_test.go: `const wantSub = "net/url: invalid control character in URL"` nonbuildable
$DIR/src/net/url/url_test.go: `.Sprint(err)` nonbuildable
$DIR/src/net/url/url_test.go: `.Contains(got, wantSub)` nonbuildable
$DIR/src/net/url/url_test.go: `wantErr = "non-nil error"` passed
Expand Down
17 changes: 1 addition & 16 deletions necessist/tests/third_party_tests/0/go_src_os.with_config.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
466 candidates in 78 tests in 1 test file
455 candidates in 78 tests in 1 test file
$DIR/src/os/os_test.go: dry running
$DIR/src/os/os_test.go: mutilating
$DIR/src/os/os_test.go: Warning: Failed to run test `TestMain`
Expand Down Expand Up @@ -337,14 +337,8 @@ $DIR/src/os/os_test.go: `fmt.Fprintf(Stderr, "fchdir back to dot failed: %s\n",
$DIR/src/os/os_test.go: `.Fprintf(Stderr, "fchdir back to dot failed: %s\n", err2)` nonbuildable
$DIR/src/os/os_test.go: `Exit(1)` passed
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `const data = "hello, world\n"` nonbuildable
$DIR/src/os/os_test.go: `io.WriteString(f, data)` failed
$DIR/src/os/os_test.go: `.WriteString(f, data)` nonbuildable
$DIR/src/os/os_test.go: `type test struct {
in int64
whence int
out int64
}` nonbuildable
$DIR/src/os/os_test.go: `.Seek(tt.in, tt.whence)` nonbuildable
$DIR/src/os/os_test.go: `.Contains(string(mounts), "reiserfs")` nonbuildable
$DIR/src/os/os_test.go: `_, err = r.Seek(0, 0)` nonbuildable
Expand All @@ -360,12 +354,10 @@ $DIR/src/os/os_test.go: `testenv.MustHaveExec(t)` passed
$DIR/src/os/os_test.go: `.MustHaveExec(t)` nonbuildable
$DIR/src/os/os_test.go: `.Cut(hostname, ".")` nonbuildable
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `const data = "hello, world\n"` nonbuildable
$DIR/src/os/os_test.go: `io.WriteString(f, data)` failed
$DIR/src/os/os_test.go: `.WriteString(f, data)` nonbuildable
$DIR/src/os/os_test.go: `.ReadAt(b, 7)` nonbuildable
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `const data = "hello, world\n"` nonbuildable
$DIR/src/os/os_test.go: `io.WriteString(f, data)` failed
$DIR/src/os/os_test.go: `.WriteString(f, data)` nonbuildable
$DIR/src/os/os_test.go: `f.Seek(0, 0)` failed
Expand All @@ -374,29 +366,24 @@ $DIR/src/os/os_test.go: `.ReadAt(b, 7)` nonbuildable
$DIR/src/os/os_test.go: `n, err = f.Read(b)` failed
$DIR/src/os/os_test.go: `.Read(b)` nonbuildable
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `const data = "hello, world\n"` nonbuildable
$DIR/src/os/os_test.go: `io.WriteString(f, data)` passed
$DIR/src/os/os_test.go: `.WriteString(f, data)` nonbuildable
$DIR/src/os/os_test.go: `f.Seek(0, 0)` passed
$DIR/src/os/os_test.go: `.Seek(0, 0)` nonbuildable
$DIR/src/os/os_test.go: `.ReadAt(b, -10)` nonbuildable
$DIR/src/os/os_test.go: `const wantsub = "negative offset"` nonbuildable
$DIR/src/os/os_test.go: `.Contains(fmt.Sprint(err), wantsub)` nonbuildable
$DIR/src/os/os_test.go: `.Sprint(err)` nonbuildable
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `const data = "hello, world\n"` nonbuildable
$DIR/src/os/os_test.go: `io.WriteString(f, data)` failed
$DIR/src/os/os_test.go: `.WriteString(f, data)` nonbuildable
$DIR/src/os/os_test.go: `.WriteAt([]byte("WORLD"), 7)` nonbuildable
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `.Name()` nonbuildable
$DIR/src/os/os_test.go: `.WriteAt([]byte("WORLD"), -10)` nonbuildable
$DIR/src/os/os_test.go: `const wantsub = "negative offset"` nonbuildable
$DIR/src/os/os_test.go: `.Contains(fmt.Sprint(err), wantsub)` nonbuildable
$DIR/src/os/os_test.go: `.Sprint(err)` nonbuildable
$DIR/src/os/os_test.go: `_, err = f.WriteAt([]byte(""), 1)` failed
$DIR/src/os/os_test.go: `.WriteAt([]byte(""), 1)` nonbuildable
$DIR/src/os/os_test.go: `const f = "append.txt"` nonbuildable
$DIR/src/os/os_test.go: `s = writeFile(t, f, O_APPEND|O_RDWR, "|append")` failed
$DIR/src/os/os_test.go: `s = writeFile(t, f, O_CREATE|O_APPEND|O_RDWR, "|append")` failed
$DIR/src/os/os_test.go: `s = writeFile(t, f, O_CREATE|O_APPEND|O_RDWR, "new&append")` failed
Expand All @@ -413,7 +400,6 @@ $DIR/src/os/os_test.go: `b[len(b)-1] = '\n'` passed
$DIR/src/os/os_test.go: `.Write(b)` nonbuildable
$DIR/src/os/os_test.go: `n, err = Stderr.Write(b)` passed
$DIR/src/os/os_test.go: `.Write(b)` nonbuildable
$DIR/src/os/os_test.go: `const mode = 0111` nonbuildable
$DIR/src/os/os_test.go: `.TempDir()` nonbuildable
$DIR/src/os/os_test.go: `.Mode()` nonbuildable
$DIR/src/os/os_test.go: `.Stat()` nonbuildable
Expand Down Expand Up @@ -636,7 +622,6 @@ $DIR/src/os/os_test.go: `.ModTime()` nonbuildable
$DIR/src/os/os_test.go: `.ModTime()` nonbuildable
$DIR/src/os/os_test.go: `.TestFS(fsys, "a", "b", "dir/x")` nonbuildable
$DIR/src/os/os_test.go: `.ReadDir("nonexistent")` nonbuildable
$DIR/src/os/os_test.go: `const nonesuch = "dir/nonesuch"` nonbuildable
$DIR/src/os/os_test.go: `.Open(nonesuch)` nonbuildable
$DIR/src/os/os_test.go: `.Contains(err.Error(), nonesuch)` nonbuildable
$DIR/src/os/os_test.go: `.Contains(err.(*PathError).Path, "testdata")` nonbuildable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
134 candidates in 15 tests in 4 test files
133 candidates in 15 tests in 4 test files
$DIR/src/testing/iotest/logger_test.go: dry running
$DIR/src/testing/iotest/logger_test.go: mutilating
$DIR/src/testing/iotest/logger_test.go: `.Writer()` nonbuildable
Expand Down Expand Up @@ -149,7 +149,6 @@ $DIR/src/testing/iotest/reader_test.go: `.Run(tt.name, func(t *testing.T) {
}
})` nonbuildable
$DIR/src/testing/iotest/reader_test.go: `.Read(nil)` nonbuildable
$DIR/src/testing/iotest/reader_test.go: `const msg = "Now is the time for all good gophers."` nonbuildable
$DIR/src/testing/iotest/reader_test.go: `.NewReader(msg)` nonbuildable
$DIR/src/testing/iotest/writer_test.go: dry running
$DIR/src/testing/iotest/writer_test.go: mutilating
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
38 candidates in 16 tests in 2 test files
36 candidates in 16 tests in 2 test files
$DIR/src/text/template/parse/parse_test.go: dry running
$DIR/src/text/template/parse/parse_test.go: mutilating
$DIR/src/text/template/parse/parse_test.go: `typ = itemCharConstant` failed
Expand Down Expand Up @@ -68,14 +68,8 @@ $DIR/src/text/template/parse/parse_test.go: `.Run(test.name, func(t *testing.T)
})` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Parse(test.input, "", "", make(map[string]*Tree))` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Contains(err.Error(), test.result)` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `const (
input = `a{{block "inner" .}}bar{{.}}baz{{end}}b`
outer = `a{{template "inner" .}}b`
inner = `bar{{.}}baz`
)` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Parse(input, "", "", treeSet, nil)` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Root.String()` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Root.String()` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `const count = 3` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Repeat("{{printf 1234}}\n", count)` nonbuildable
$DIR/src/text/template/parse/parse_test.go: `.Parse(text, "", "", make(map[string]*Tree), builtins)` nonbuildable
Loading

0 comments on commit 48b81c9

Please # to comment.