evalResult computes the final result of the fold after all entries have been folded and accumulated.
()
| 2131 | |
| 2132 | // evalResult computes the final result of the fold after all entries have been folded and accumulated. |
| 2133 | func (f *folder) evalResult() ref.Val { |
| 2134 | f.computeResult = true |
| 2135 | if f.interrupted { |
| 2136 | return types.WrapErr(InterruptError{}) |
| 2137 | } |
| 2138 | res := f.result.Exec(f.frame) |
| 2139 | // Convert a mutable list or map to an immutable one if the comprehension has generated a list or |
| 2140 | // map as a result. |
| 2141 | if !types.IsUnknownOrError(res) && f.mutableValue { |
| 2142 | if _, ok := res.(traits.MutableLister); ok { |
| 2143 | res = res.(traits.MutableLister).ToImmutableList() |
| 2144 | } |
| 2145 | if _, ok := res.(traits.MutableMapper); ok { |
| 2146 | res = res.(traits.MutableMapper).ToImmutableMap() |
| 2147 | } |
| 2148 | } |
| 2149 | return res |
| 2150 | } |
| 2151 | |
| 2152 | // reset clears any state associated with folder evaluation. |
| 2153 | func (f *folder) reset() { |
no test coverage detected