Skip to content

Commit

Permalink
hclwrite: Fix unstable list returned by Body.Blocks()
Browse files Browse the repository at this point in the history
Fixes #310

The type of `Body.items` is a `nodeSet` (That is, `map[*node]struct{}`),
so the order of the list returned by Body.Blocks () was unstable.
  • Loading branch information
minamijoyo authored and apparentlymart committed Oct 17, 2019
1 parent b15db4a commit c21e319
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hclwrite/ast_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (b *Body) Attributes() map[string]*Attribute {
// Blocks returns a new slice of all the blocks in the body.
func (b *Body) Blocks() []*Block {
ret := make([]*Block, 0, len(b.items))
for n := range b.items {
for _, n := range b.items.List() {
if block, isBlock := n.content.(*Block); isBlock {
ret = append(ret, block)
}
Expand Down

0 comments on commit c21e319

Please sign in to comment.