Require effectful func's args to be effect-free

This commit is contained in:
Nigel Tao committed 2018-08-04 09:11:33 +10:00
1 parent 81eecf2936
commit 0822842344
1 file changed
+9
+9
View File
@@ -1078,6 +1078,15 @@ func (p *parser) parseOperand() (*a.Expr, error) {
if err != nil {
return nil, err
}
if flags.AsEffect() != 0 {
for _, arg := range args {
o := arg.AsArg().Value()
if o.Effect() != 0 {
return nil, fmt.Errorf(`parse: effectful function call %q has effectful argument %q at %s:%d`,
lhs.Str(p.tm), o.Str(p.tm), p.filename, p.line())
}
}
}
lhs = a.NewExpr(flags, t.IDOpenParen, 0, 0, lhs.AsNode(), nil, nil, args)
case t.IDOpenBracket: