Skip to content

Commit

Permalink
process the ast.SliceExpr node as is.
Browse files Browse the repository at this point in the history
close #12

Signed-off-by: Vladislav Fursov <[email protected]>
  • Loading branch information
ghostiam committed Sep 11, 2024
1 parent 0981b03 commit b53207d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (c *processor) processInner(expr ast.Expr) {
c.write("*")
c.processInner(x.X)

case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit:
case *ast.CompositeLit, *ast.TypeAssertExpr, *ast.ArrayType, *ast.FuncLit, *ast.SliceExpr:
// Process the node as is.
c.write(formatNode(x))

Expand Down
4 changes: 4 additions & 0 deletions testdata/proto/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ func (x *Embedded) SetS(s string) {

func (x *Embedded) SetMap(_ map[string]string) {
}

func (x *Test) MyMarshal([]byte) (int, error) {
return 0, nil
}
4 changes: 4 additions & 0 deletions testdata/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ func testValid(t *proto.Test) {
t.RepeatedEmbeddeds = append(t.GetRepeatedEmbeddeds(), t.GetRepeatedEmbeddeds()...)
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, t.GetEmbedded())
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, &proto.Embedded{})

// issue #12
data := make([]byte, 4)
_, _ = t.MyMarshal(data[4:])
}

// stubs
Expand Down
4 changes: 4 additions & 0 deletions testdata/test.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ func testValid(t *proto.Test) {
t.RepeatedEmbeddeds = append(t.GetRepeatedEmbeddeds(), t.GetRepeatedEmbeddeds()...)
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, t.GetEmbedded())
t.RepeatedEmbeddeds = append(t.RepeatedEmbeddeds, &proto.Embedded{})

// issue #12
data := make([]byte, 4)
_, _ = t.MyMarshal(data[4:])
}

// stubs
Expand Down

0 comments on commit b53207d

Please sign in to comment.