evalResult computes the final result of the fold after all entries have been folded and accumulated.
()
| 1624 | |
| 1625 | // evalResult computes the final result of the fold after all entries have been folded and accumulated. |
| 1626 | func (f *folder) evalResult() ref.Val { |
| 1627 | f.computeResult = true |
| 1628 | if f.interrupted { |
| 1629 | return types.WrapErr(InterruptError{}) |
| 1630 | } |
| 1631 | res := f.result.Exec(f.frame) |
| 1632 | // Convert a mutable list or map to an immutable one if the comprehension has generated a list or |
| 1633 | // map as a result. |
| 1634 | if !types.IsUnknownOrError(res) && f.mutableValue { |
| 1635 | if _, ok := res.(traits.MutableLister); ok { |
| 1636 | res = res.(traits.MutableLister).ToImmutableList() |
| 1637 | } |
| 1638 | if _, ok := res.(traits.MutableMapper); ok { |
| 1639 | res = res.(traits.MutableMapper).ToImmutableMap() |
| 1640 | } |
| 1641 | } |
| 1642 | return res |
| 1643 | } |
| 1644 | |
| 1645 | // reset clears any state associated with folder evaluation. |
| 1646 | func (f *folder) reset() { |
no test coverage detected