Giter Site home page Giter Site logo

grind's Introduction

grind's People

Contributors

rsc 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

grind's Issues

assignment count mismatch

I'm getting ../../../rsc.io/grind/vardecl/vardecl.go:84: assignment count mismatch: 2 = 3 when I go get the package. I looked into NodeEval() and it seemed correct. So I'm at a loss for more suggestions, sorry.

I'm using go version 1.4 (darwin/amd64) in case it matters.

Grind moves delcarations in between loop labels and their bodies

A minimal test case:

package main

import "time"

func f(ch chan int) {

}

func main() {

    var m int

    ch := make(chan int)

    for i := 0; i < 10; i++ {
        go f(ch)
    }

    t := time.After(1 * time.Second)

loop:
    for i := 0; i < 10; i++ {
        select {
        case j, ok := <-ch:
            if ok {
                m += j
            }

        case <-t:
            break loop
        }

    }
}

becomes

package main

import "time"

func f(ch chan int) {
}

func main() {
    ch := make(chan int)

    for i := 0; i < 10; i++ {
        go f(ch)
    }

    t := time.After(1 * time.Second)

loop:
    var m int
    for i := 0; i < 10; i++ {
        select {
        case j, ok := <-ch:
            if ok {
                m += j
            }

        case <-t:
            break loop
        }
    }
}

which fails to build because loop is no longer a valid break label because the declaration of m was moved after it, making it a regular label.

Stuck in a loop.

$ grind github.com/btcsuite/btcd gets stuck in a loop swapping var declarations:

EDIT: cpuminer.go
@@ -73,8 +73,8 @@ func (m *CPUMiner) speedMonitor() {
        defer ticker.Stop()

 out:
-       var hashesPerSec float64
        var totalHashes uint64
+       var hashesPerSec float64
        for {
                select {
                // Periodic updates from the workers with how many hashes they

36
EDIT: cpuminer.go
@@ -73,8 +73,8 @@ func (m *CPUMiner) speedMonitor() {
        defer ticker.Stop()

 out:
-       var totalHashes uint64
        var hashesPerSec float64
+       var totalHashes uint64
        for {
                select {
                // Periodic updates from the workers with how many hashes they

Incorrect variable movement

Given the code....

func test(s string) []string {
    var p []string
    switch s {
    case "test":
        p = append(p, "test")
    }
    return p
}

... grind produces...

func test(s string) []string {
    switch s {
    case "test":
        var p []string
        p = append(p, "test")
    }
    var p []string
    return p
}

Grind doesn't see assignments in select cases

Here is a trimmed down test case:

package main

import "fmt"

func main() {

    ch := make(chan int)

    var ok bool
    var m int
    select {
    case m, ok = <-ch:
        if ok {
            fmt.Println(m)
        }
    }
}

after grinding becomes

package main

import "fmt"

func main() {
    ch := make(chan int)

    select {
    case m, ok = <-ch:
        var ok bool
        if ok {
            var m int
            fmt.Println(m)
        }
    }
}

which fails to build because the declarations of m and ok now appear after their first use in the select case.

tantalizing project name + short desc, want more

I see this project looks very young, but stumbled upon it from twitter. Since github has lacklustre subscribing features, I'll do it here: is there a way of learning more about this project save for reading the code that I don't know about? The godoc isn't a whole lot of help at the moment I'm afraid.

cannot find package "golang.org/x/tools/go/gcimporter"

trace:

package golang.org/x/tools/go/gcimporter: cannot find package "golang.org/x/tools/go/gcimporter" in any of:
    /usr/local/Cellar/go/1.6.2/libexec/src/golang.org/x/tools/go/gcimporter (from $GOROOT)
    /Users/daddye/.src/go/src/golang.org/x/tools/go/gcimporter (from $GOPATH)
package golang.org/x/tools/go/types: no buildable Go source files in /Users/daddye/.src/go/src/golang.org/x/tools/go/types

Var declaration moving is not always polished

This code is not be beautiful to start with (there are indeed many things wrong with it), but the change proposed by grind doesn't make it better I think. Perhaps a threshold of some kind where the moving of a vardecl is skipped if it results in more than x new vardecls? Or recognizing the zero value so the early returns could be modified to return nil, ... instead?

@@ -829,26 +830,29 @@ func (m *Model) ConnectedTo(deviceID protocol.DeviceID) bool {
 }

 func (m *Model) GetIgnores(folder string) ([]string, []string, error) {
-   var lines []string

    m.fmut.RLock()
    cfg, ok := m.folderCfgs[folder]
    m.fmut.RUnlock()
    if !ok {
+       var lines []string
        return lines, nil, fmt.Errorf("Folder %s does not exist", folder)
    }

    fd, err := os.Open(filepath.Join(cfg.Path, ".stignore"))
    if err != nil {
        if os.IsNotExist(err) {
+           var lines []string
            return lines, nil, nil
        }
        l.Warnln("Loading .stignore:", err)
+       var lines []string
        return lines, nil, err
    }
    defer fd.Close()

    scanner := bufio.NewScanner(fd)
+   var lines []string
    for scanner.Scan() {
        lines = append(lines, strings.TrimSpace(scanner.Text()))
    }

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.