Merge pull request #2280 from nspcc-dev/compiler-struct-cast
compiler: allow to slice struct field
This commit is contained in:
commit
dbe184a335
2 changed files with 13 additions and 3 deletions
|
@ -644,12 +644,12 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
return nil
|
||||
|
||||
case *ast.SliceExpr:
|
||||
if isCompoundSlice(c.typeOf(n.X.(*ast.Ident)).Underlying()) {
|
||||
if isCompoundSlice(c.typeOf(n.X).Underlying()) {
|
||||
c.prog.Err = errors.New("subslices are supported only for []byte")
|
||||
return nil
|
||||
}
|
||||
name := n.X.(*ast.Ident).Name
|
||||
c.emitLoadVar("", name)
|
||||
|
||||
ast.Walk(c, n.X)
|
||||
|
||||
if n.Low != nil {
|
||||
ast.Walk(c, n.Low)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue