]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/fix: check type assertion in netipv6zone rule.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 2 Jun 2013 13:39:47 +0000 (15:39 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 2 Jun 2013 13:39:47 +0000 (15:39 +0200)
Fixes #5461.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9947043

src/cmd/fix/netipv6zone.go
src/cmd/fix/netipv6zone_test.go

index fe973a21139c710e28e5296e3b40a50a9581bc54..195c218074ecf983b4252f6769a102044018995e 100644 (file)
@@ -51,7 +51,7 @@ func netipv6zone(f *ast.File) bool {
                                                Value: e,
                                        }
                                case 1:
-                                       if e.(*ast.BasicLit).Value == "0" {
+                                       if elit, ok := e.(*ast.BasicLit); ok && elit.Value == "0" {
                                                cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
                                        } else {
                                                cl.Elts[i] = &ast.KeyValueExpr{
index 0fab00531962115849fae550af90964dffa00440..142880a12a7242f8a584f29d33c16104bb4aed07 100644 (file)
@@ -20,6 +20,8 @@ func f() net.Addr {
        sub(&net.UDPAddr{ip2, 12345})
        c := &net.TCPAddr{IP: ip3, Port: 54321}
        d := &net.TCPAddr{ip4, 0}
+       p := 1234
+       e := &net.TCPAddr{ip4, p}
        return &net.TCPAddr{ip5}, nil
 }
 `,
@@ -32,6 +34,8 @@ func f() net.Addr {
        sub(&net.UDPAddr{IP: ip2, Port: 12345})
        c := &net.TCPAddr{IP: ip3, Port: 54321}
        d := &net.TCPAddr{IP: ip4}
+       p := 1234
+       e := &net.TCPAddr{IP: ip4, Port: p}
        return &net.TCPAddr{IP: ip5}, nil
 }
 `,