(frame *interpreter.ExecutionFrame)
| 802 | } |
| 803 | |
| 804 | func (opt *evalOptionalOrValue) Exec(frame *interpreter.ExecutionFrame) ref.Val { |
| 805 | // short-circuit lhs. |
| 806 | optLHS := opt.lhs.Exec(frame) |
| 807 | |
| 808 | switch val := optLHS.(type) { |
| 809 | case *types.Err, *types.Unknown: |
| 810 | return optLHS |
| 811 | case *types.Optional: |
| 812 | if val.HasValue() { |
| 813 | return val.GetValue() |
| 814 | } |
| 815 | return opt.rhs.Exec(frame) |
| 816 | default: |
| 817 | return types.NoSuchOverloadErr() |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | // Eval evaluates the left-hand side optional to determine whether it contains a value, else |
| 822 | // proceeds with the right-hand side evaluation. |
no test coverage detected