Skip to content

Commit

Permalink
Avoid exception for immutable list from folded (#574)
Browse files Browse the repository at this point in the history
* Added check to avoid error thrown when returning a immutable list from a function called by a comprehension expression
  • Loading branch information
livebranch committed Aug 15, 2022
1 parent 25bb4c6 commit ca2fb43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion interpreter/interpretable.go
Expand Up @@ -835,7 +835,9 @@ func (fold *evalFold) Eval(ctx Activation) ref.Val {
varActivationPool.Put(accuCtx)
// Convert a mutable list to an immutable one, if the comprehension has generated a list as a result.
if !types.IsUnknownOrError(res) && buildingList {
res = res.(traits.MutableLister).ToImmutableList()
if _, ok := res.(traits.MutableLister); ok {
res = res.(traits.MutableLister).ToImmutableList()
}
}
return res
}
Expand Down

0 comments on commit ca2fb43

Please sign in to comment.