Drop the "= RHS" out of "var x T = RHS"

This commit is contained in:
Nigel Tao committed 2018-12-27 11:29:47 +11:00
1 parent cbe19f50e0
commit 6dc68950c0
7 files changed
+20 -68

No files matched your search

-6
View File
@@ -420,12 +420,6 @@ func (h *resumabilityHelper) doRet(r resumabilities, n *a.Ret, depth uint32) err
}
func (h *resumabilityHelper) doVar(r resumabilities, n *a.Var, depth uint32) error {
if n.Value() != nil {
if err := h.doExpr(r, n.Value()); err != nil {
return err
}
}
name := n.Name()
if i, ok := h.vars[name]; !ok {
return fmt.Errorf("unrecognized variable %q", name.Str(h.tm))
+4 -9
View File
@@ -43,10 +43,9 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
switch n.Kind() {
case a.KAssign:
n := n.AsAssign()
mightIntroduceTemporaries = n.LHS().Effect().Coroutine() || n.RHS().Effect().Coroutine()
case a.KVar:
v := n.AsVar().Value()
mightIntroduceTemporaries = v != nil && v.Effect().Coroutine()
mightIntroduceTemporaries = n.RHS().Effect().Coroutine()
case a.KExpr:
// TODO.
}
if mightIntroduceTemporaries {
// Put n's code into its own block, to restrict the scope of the
@@ -86,11 +85,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
return g.writeStatementRet(b, n.AsRet(), depth)
case a.KVar:
n := n.AsVar()
op := n.Operator()
if n.Value() == nil {
op = t.IDEq
}
return g.writeStatementAssign(b, n.Name(), nil, n.XType(), op, n.Value(), depth)
return g.writeStatementAssign(b, n.Name(), nil, n.XType(), t.IDEq, nil, depth)
case a.KWhile:
return g.writeStatementWhile(b, n.AsWhile(), depth)
}