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

Method funcType

syntax/parser.go:1361–1395  ·  view source on GitHub ↗

If context != "", type parameters are not permitted.

(context string, tparamList *[]*Field)

Source from the content-addressed store, hash-verified

1359
1360// If context != "", type parameters are not permitted.
1361func (p *parser) funcType(context string, tparamList *[]*Field) *FuncType {
1362 if trace {
1363 defer p.trace("funcType")()
1364 }
1365
1366 typ := new(FuncType)
1367 typ.pos = p.pos()
1368
1369 if p.allowGenerics() && p.tok == _Lbrack {
1370 p.async(func() {
1371 p.next()
1372 if context != "" {
1373 // accept but complain
1374 p.syntaxErrorAt(typ.pos, context+" must have no type parameters")
1375 }
1376 if p.tok == _Rbrack {
1377 p.syntaxError("empty type parameter list")
1378 p.next()
1379 } else {
1380 list := p.paramList(nil, nil, _Rbrack, true)
1381 if tparamList != nil {
1382 *tparamList = list
1383 }
1384 }
1385 })
1386 }
1387
1388 p.async(func() {
1389 p.want(_Lparen)
1390 typ.ParamList = p.paramList(nil, nil, _Rparen, false)
1391 })
1392 typ.ResultList = p.funcResult()
1393
1394 return typ
1395}
1396
1397// "[" has already been consumed, and pos is its position, and open is its tape index.
1398// If len != nil it is the already consumed array length.

Callers 4

funcDeclOrNilMethod · 0.95
operandMethod · 0.95
typeOrNilMethod · 0.95
methodDeclMethod · 0.95

Calls 11

traceMethod · 0.95
posMethod · 0.95
allowGenericsMethod · 0.95
asyncMethod · 0.95
syntaxErrorAtMethod · 0.95
syntaxErrorMethod · 0.95
paramListMethod · 0.95
wantMethod · 0.95
funcResultMethod · 0.95
nextMethod · 0.65
newFunction · 0.50

Tested by

no test coverage detected