<commit_before>// Heavily modivied version of Go's src/go/ast/walk.go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Copyright (c) 2017, <NAME> <<EMAIL>>
// See LICENSE for licensing information

package main

import (
	"go/ast"
)

func (r *reducer) walkIdentList(list []*ast.Ident) {
	for _, x := range list {
		r.walk(x)
	}
}

func (r *reducer) walkExprList(list []ast.Expr) {
	for _, x := range list {
		r.walk(x)
	}
}

func (r *reducer) walkStmtList(list *[]ast.Stmt) {
	orig := *list
	// RULE: remove each one of the statements
	for i := range orig {
		l := make([]ast.Stmt, len(orig)-1)
		copy(l, orig[:i])
		copy(l[i:], orig[i+1:])
		*list = l
		if r.okChange() {
			return
		}
	}
	*list = orig
	for i, x := range orig {
		r.stmt = &orig[i]
		r.walk(x)
	}
}

func (r *reducer) walkDeclList(list []ast.Decl) {
	for _, x := range list {
		r.walk(x)
	}<commit_msg>Discard assigns and returns when removing stmts<commit_after>// Heavily modivied version of Go's src/go/ast/walk.go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Copyright (c) 2017, <NAME> <<EMAIL>>
// See LICENSE for licensing information

package main

import (
	"go/ast"
	"go/token"
)

func (r *reducer) walkIdentList(list []*ast.Ident) {
	for _, x := range list {
		r.walk(x)
	}
}

func (r *reducer) walkExprList(list []ast.Expr) {
	for _, x := range list {
		r.walk(x)
	}
}

func (r *reducer) walkStmtList(list *[]ast.Stmt) {
	orig := *list
	// RULE: remove each one of the statements
	for i, stmt := range orig {
		// discard those that will break compilation
		switch x := stmt.(type) {
		case *ast.DeclStmt, *ast.ReturnStmt:
			continue
		case *ast.AssignStmt:
			if x.Tok == token.DEFINE { // :=
				continue
			}
		}
		l := make([]ast.Stmt, len(orig)-1)
		copy(l, orig[:i])
		copy(l[i:], orig[i+1:])
		*list = l
		if r.okChange() {
			return
		}
	}
	*list = orig
	for i, x := range orig {
		r.stmt = &orig[i]
		r.walk(x)
	}
}

func (r *reducer) walkDeclList(list []ast.Decl) {
	for _, x := range list {
		r.walk(x)
	}
{'fraction_non_alphanumeric': 0.15964125560538117, 'fraction_numerical': 0.008968609865470852, 'mean_word_length': 3.056363636363636, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1574035', 'n_tokens_mistral': 922, 'n_tokens_neox': 866, 'n_words': 263}