Skip to content

Commit b53207d

Browse files
committed
process the ast.SliceExpr node as is.
close #12 Signed-off-by: Vladislav Fursov <github@ghost.im>
1 parent 0981b03 commit b53207d

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

processor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (c *processor) processInner(expr ast.Expr) {
218218
c.write("*")
219219
c.processInner(x.X)
220220

221-
case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit:
221+
case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit, *ast.SliceExpr:
222222
// Process the node as is.
223223
c.write(formatNode(x))
224224

testdata/proto/test.go

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ func (x *Embedded) SetS(s string) {
2121

2222
func (x *Embedded) SetMap(_ map[string]string) {
2323
}
24+
25+
func (x *Test) MyMarshal([]byte) (int, error) {
26+
return 0, nil
27+
}

testdata/test.go

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ func testValid(t *proto.Test) {
179179
t.RepeatedEmbeddeds = append(t.GetRepeatedEmbeddeds(), t.GetRepeatedEmbeddeds()...)
180180
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, t.GetEmbedded())
181181
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, &proto.Embedded{})
182+
183+
// issue #12
184+
data := make([]byte, 4)
185+
_, _ = t.MyMarshal(data[4:])
182186
}
183187

184188
// stubs

testdata/test.go.golden

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ func testValid(t *proto.Test) {
179179
t.RepeatedEmbeddeds = append(t.GetRepeatedEmbeddeds(), t.GetRepeatedEmbeddeds()...)
180180
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, t.GetEmbedded())
181181
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, &proto.Embedded{})
182+
183+
// issue #12
184+
data := make([]byte, 4)
185+
_, _ = t.MyMarshal(data[4:])
182186
}
183187

184188
// stubs

0 commit comments

Comments
 (0)