diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/go/printer/nodes.go | 4 | ||||
| -rw-r--r-- | src/go/printer/testdata/comments.golden | 28 | ||||
| -rw-r--r-- | src/go/printer/testdata/comments.input | 28 | ||||
| -rw-r--r-- | src/math/big/int.go | 2 |
4 files changed, 59 insertions, 3 deletions
diff --git a/src/go/printer/nodes.go b/src/go/printer/nodes.go index 83c17fef5e..5b5b6063fb 100644 --- a/src/go/printer/nodes.go +++ b/src/go/printer/nodes.go @@ -865,7 +865,9 @@ func (p *printer) expr1(expr ast.Expr, prec1, depth int) { if len(x.Elts) > 0 { mode |= noExtraBlank } - p.print(mode, x.Rbrace, token.RBRACE, mode) + // need the initial indent to print lone comments with + // the proper level of indentation + p.print(indent, unindent, mode, x.Rbrace, token.RBRACE, mode) p.level-- case *ast.Ellipsis: diff --git a/src/go/printer/testdata/comments.golden b/src/go/printer/testdata/comments.golden index d14d8d6cbb..3fc29ccf91 100644 --- a/src/go/printer/testdata/comments.golden +++ b/src/go/printer/testdata/comments.golden @@ -831,4 +831,32 @@ func _() { */ } +var _ = []T{ /* lone comment */ } + +var _ = []T{ + /* lone comment */ +} + +var _ = []T{ + // lone comments + // in composite lit +} + +var _ = [][]T{ + { + // lone comments + // in composite lit + }, +} + +// TODO: gofmt doesn't add these tabs; make it so that these golden +// tests run the printer in a way that it's exactly like gofmt. + +var _ = []T{ // lone comment +} + +var _ = []T{ // lone comments + // in composite lit +} + /* This comment is the last entry in this file. It must be printed and should be followed by a newline */ diff --git a/src/go/printer/testdata/comments.input b/src/go/printer/testdata/comments.input index df98056a65..985e334795 100644 --- a/src/go/printer/testdata/comments.input +++ b/src/go/printer/testdata/comments.input @@ -832,4 +832,32 @@ func _() { */ } +var _ = []T{/* lone comment */} + +var _ = []T{ +/* lone comment */ +} + +var _ = []T{ +// lone comments +// in composite lit +} + +var _ = [][]T{ + { + // lone comments + // in composite lit + }, +} + +// TODO: gofmt doesn't add these tabs; make it so that these golden +// tests run the printer in a way that it's exactly like gofmt. + +var _ = []T{// lone comment +} + +var _ = []T{// lone comments +// in composite lit +} + /* This comment is the last entry in this file. It must be printed and should be followed by a newline */ diff --git a/src/math/big/int.go b/src/math/big/int.go index 135ebd083f..0eda9cd4e1 100644 --- a/src/math/big/int.go +++ b/src/math/big/int.go @@ -533,7 +533,6 @@ func (z *Int) GCD(x, y, a, b *Int) *Int { // See Jebelean, "Improving the multiprecision Euclidean algorithm", // Design and Implementation of Symbolic Computation Systems, pp 45-58. func (z *Int) lehmerGCD(a, b *Int) *Int { - // ensure a >= b if a.abs.cmp(b.abs) < 0 { a, b = b, a @@ -551,7 +550,6 @@ func (z *Int) lehmerGCD(a, b *Int) *Int { // loop invariant A >= B for len(B.abs) > 1 { - // initialize the digits var a1, a2, u0, u1, u2, v0, v1, v2 Word |
