Infer coroutine effects automatically
This commit is contained in:
parent
bac1183593
commit
5b30e49486
15 changed files with 339 additions and 103 deletions
|
|
@ -138,7 +138,7 @@ func (p *parser) parseProgram() (*Program, error) {
|
|||
default:
|
||||
return nil, fmt.Errorf("unsupported annotation %q", annotation.lexeme)
|
||||
}
|
||||
case p.check(tokenFun) || p.check(tokenSuspend):
|
||||
case p.check(tokenFun):
|
||||
fn, err := p.parseFunction()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -325,7 +325,7 @@ func (p *parser) parseClass() (ClassDecl, error) {
|
|||
var methods []FunctionDecl
|
||||
for !p.check(tokenRBrace) && !p.check(tokenEOF) {
|
||||
p.match(tokenOverride)
|
||||
if !p.check(tokenFun) && !p.check(tokenSuspend) {
|
||||
if !p.check(tokenFun) {
|
||||
tok := p.peek()
|
||||
return ClassDecl{}, fmt.Errorf("expected class member at %d, found %q", tok.pos, tok.lexeme)
|
||||
}
|
||||
|
|
@ -482,12 +482,10 @@ func (p *parser) parseFunction() (FunctionDecl, error) {
|
|||
Params: signature.Params,
|
||||
ReturnType: signature.ReturnType,
|
||||
Body: body,
|
||||
Suspend: signature.Suspend,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *parser) parseFunctionSignature() (FunctionSignature, error) {
|
||||
suspend := p.match(tokenSuspend)
|
||||
if _, err := p.expect(tokenFun, "expected 'fun'"); err != nil {
|
||||
return FunctionSignature{}, err
|
||||
}
|
||||
|
|
@ -524,7 +522,6 @@ func (p *parser) parseFunctionSignature() (FunctionSignature, error) {
|
|||
TypeParams: typeParams,
|
||||
Params: params,
|
||||
ReturnType: returnType,
|
||||
Suspend: suspend,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue