Skip to content

Commit

Permalink
fix: panic in forEachResult.add (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreeaneata committed Mar 22, 2024
1 parent d867732 commit ee7c2af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changes/unreleased/Fixed-20240322-114459.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixed
body: panic in forEachResult.add
time: 2024-03-22T11:44:59.264406+02:00
10 changes: 6 additions & 4 deletions pkg/hcl_interpreter/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,13 @@ type forEachResult struct {

func (acc *forEachResult) add(key cty.Value, val cty.Value) {
if !acc.isTuple && key.Type() == cty.String {
if acc.object == nil {
acc.object = map[string]cty.Value{}
if !key.IsNull() && key.IsKnown() {
if acc.object == nil {
acc.object = map[string]cty.Value{}
}
acc.object[key.AsString()] = val
acc.tuple = append(acc.tuple, val)
}
acc.object[key.AsString()] = val
acc.tuple = append(acc.tuple, val)
} else {
acc.isTuple = true
acc.tuple = append(acc.tuple, val)
Expand Down

0 comments on commit ee7c2af

Please sign in to comment.