evalResult computes the final result of the fold after all entries have been folded and accumulated.
()
| 1686 | |
| 1687 | // evalResult computes the final result of the fold after all entries have been folded and accumulated. |
| 1688 | func (f *folder) evalResult() ref.Val { |
| 1689 | f.computeResult = true |
| 1690 | if f.interrupted { |
| 1691 | return types.WrapErr(InterruptError{}) |
| 1692 | } |
| 1693 | res := f.result.Exec(f.frame) |
| 1694 | // Convert a mutable list or map to an immutable one if the comprehension has generated a list or |
| 1695 | // map as a result. |
| 1696 | if !types.IsUnknownOrError(res) && f.mutableValue { |
| 1697 | if _, ok := res.(traits.MutableLister); ok { |
| 1698 | res = res.(traits.MutableLister).ToImmutableList() |
| 1699 | } |
| 1700 | if _, ok := res.(traits.MutableMapper); ok { |
| 1701 | res = res.(traits.MutableMapper).ToImmutableMap() |
| 1702 | } |
| 1703 | } |
| 1704 | return res |
| 1705 | } |
| 1706 | |
| 1707 | // reset clears any state associated with folder evaluation. |
| 1708 | func (f *folder) reset() { |
no test coverage detected