MCPcopy Create free account
hub / github.com/despiteallobjections/amigo / singleValue

Method singleValue

types/expr.go:1832–1845  ·  view source on GitHub ↗

singleValue reports an error if x describes a tuple and sets x.mode to invalid.

(x *operand)

Source from the content-addressed store, hash-verified

1830
1831// singleValue reports an error if x describes a tuple and sets x.mode to invalid.
1832func (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.
1848var op2tok = [...]token.Token{

Callers 4

assignmentMethod · 0.95
exprMethod · 0.95
exprWithHintMethod · 0.95
exprOrTypeMethod · 0.95

Calls 3

errorfMethod · 0.95
assertFunction · 0.70
LenMethod · 0.45

Tested by

no test coverage detected