hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
373 stars 66 forks source link

hclpack: fix hclpack decoding nested body #73

Closed akupila closed 5 years ago

akupila commented 5 years ago

Fixes an issue where a nested block would be decoded incorrectly, the body of the last decoded block overwrites the previously decoded ones.

This was caused by the block being assigned on the stack in the for loop; when the block is converted to a *hcl.Block, the pointer to Body will always point to the same block. This caused decoding a new block to overwrite the bodies of any previously decoded blocks.

This is my first PR here, if there's anything else you'd like to see here please let me know.

Fixes #72

apparentlymart commented 5 years ago

Thanks for looking into this, @akupila!

This hclpack package is still pretty new/experimental, so I'm sorry you were the one to find these rough edges, and I appreciate you taking the time to dig in and debug them.

It looks like somehow Travis-CI got disconnected from this repository, so I'm going to close and re-open this in the hopes of triggering a Travis-CI run.

codecov-io commented 5 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@819a65a). Click here to learn what that means. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #73   +/-   ##
=========================================
  Coverage          ?   65.61%           
=========================================
  Files             ?       97           
  Lines             ?    10238           
  Branches          ?        0           
=========================================
  Hits              ?     6718           
  Misses            ?     3189           
  Partials          ?      331
Impacted Files Coverage Δ
hclpack/structure.go 42.51% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 819a65a...5ff4045. Read the comment docs.

akupila commented 5 years ago

No worries at all! I really like the idea of hclpack and happy to help smooth out the rough edges