singleValue reports an error if x describes a tuple and sets x.mode to invalid.
(x *operand)
| 1830 | |
| 1831 | // singleValue reports an error if x describes a tuple and sets x.mode to invalid. |
| 1832 | func (check *Checker) singleValue(x *operand) { |
| 1833 | if x.mode == value { |
| 1834 | // tuple types are never named - no need for underlying type below |
| 1835 | if t, ok := x.typ.(*Tuple); ok { |
| 1836 | assert(t.Len() != 1) |
| 1837 | if check.conf.CompilerErrorMessages { |
| 1838 | check.errorf(x, "multiple-value %s in single-value context", x) |
| 1839 | } else { |
| 1840 | check.errorf(x, "%d-valued %s where single value is expected", t.Len(), x) |
| 1841 | } |
| 1842 | x.mode = invalid |
| 1843 | } |
| 1844 | } |
| 1845 | } |
| 1846 | |
| 1847 | // op2tok translates syntax.Operators into token.Tokens. |
| 1848 | var op2tok = [...]token.Token{ |
no test coverage detected