From 0822842344c0efb362889179b04c33e1a494a210 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 4 Aug 2018 09:11:33 +1000 Subject: [PATCH] Require effectful func's args to be effect-free --- lang/parse/parse.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lang/parse/parse.go b/lang/parse/parse.go index 04819bc0..d538a728 100644 --- a/lang/parse/parse.go +++ b/lang/parse/parse.go @@ -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: