typecheckslice(n.Left.Ninit.Slice(), Etop)
n.Left = typecheck(n.Left, Erv)
+ n.Left = defaultlit(n.Left, nil)
n.Right = typecheck(n.Right, Etop)
typecheckslice(body, Etop)
n.Nbody.Prepend(body...)
n.Nbody.Append(v1)
n.Left = typecheck(n.Left, Erv)
+ n.Left = defaultlit(n.Left, nil)
typecheckslice(n.Nbody.Slice(), Etop)
n = walkstmt(n)
return true
if sw.Left == nil {
sw.Left = nodbool(true)
sw.Left = typecheck(sw.Left, Erv)
+ sw.Left = defaultlit(sw.Left, nil)
}
if sw.Left.Op == OTYPESW {
low := nod(OGE, s.exprname, rng[0])
high := nod(OLE, s.exprname, rng[1])
a.Left = nod(OANDAND, low, high)
- a.Left = typecheck(a.Left, Erv)
- a.Left = defaultlit(a.Left, nil)
- a.Left = walkexpr(a.Left, nil) // give walk the opportunity to optimize the range check
} else if (s.kind != switchKindTrue && s.kind != switchKindFalse) || assignop(n.Left.Type, s.exprname.Type, nil) == OCONVIFACE || assignop(s.exprname.Type, n.Left.Type, nil) == OCONVIFACE {
a.Left = nod(OEQ, s.exprname, n.Left) // if name == val
- a.Left = typecheck(a.Left, Erv)
- a.Left = defaultlit(a.Left, nil)
} else if s.kind == switchKindTrue {
a.Left = n.Left // if val
} else {
// s.kind == switchKindFalse
a.Left = nod(ONOT, n.Left, nil) // if !val
- a.Left = typecheck(a.Left, Erv)
- a.Left = defaultlit(a.Left, nil)
}
+ a.Left = typecheck(a.Left, Erv)
+ a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(n.Right) // goto l
cas = append(cas, a)
def = blk
}
i.Left = typecheck(i.Left, Erv)
+ i.Left = defaultlit(i.Left, nil)
cas = append(cas, i)
// Load hash from type or itab.
a := nod(OIF, nil, nil)
a.Left = nod(OEQ, s.hashname, nodintconst(int64(c.hash)))
a.Left = typecheck(a.Left, Erv)
+ a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(n.Right)
cas = append(cas, a)
}
a := nod(OIF, nil, nil)
a.Left = nod(OLE, s.hashname, nodintconst(int64(cc[half-1].hash)))
a.Left = typecheck(a.Left, Erv)
+ a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(s.walkCases(cc[:half]))
a.Rlist.Set1(s.walkCases(cc[half:]))
return a
Fatalf("missed typecheck: %+v", n)
}
+ if n.Type.IsUntyped() {
+ Fatalf("expression has untyped type: %+v", n)
+ }
+
if n.Op == ONAME && n.Class() == PAUTOHEAP {
nn := nod(OIND, n.Name.Param.Heapaddr, nil)
nn = typecheck(nn, Erv)
if (Op(n.Etype) == OEQ || Op(n.Etype) == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && n.Left.List.Len() == 2 && Isconst(n.Left.List.Second(), CTSTR) && strlit(n.Right) == strlit(n.Left.List.Second()) {
// TODO(marvin): Fix Node.EType type union.
r := nod(Op(n.Etype), nod(OLEN, n.Left.List.First(), nil), nodintconst(0))
- r = typecheck(r, Erv)
- r = walkexpr(r, init)
- r.Type = n.Type
- n = r
+ n = finishcompare(n, r, init)
break
}
remains -= step
i += step
}
- r = typecheck(r, Erv)
- r = walkexpr(r, init)
- r.Type = n.Type
- n = r
+ n = finishcompare(n, r, init)
break
}
}
r = nod(ONOT, r, nil)
r = nod(OOROR, nod(ONE, llen, rlen), r)
}
-
- r = typecheck(r, Erv)
- r = walkexpr(r, nil)
} else {
// sys_cmpstring(s1, s2) :: 0
r = mkcall("cmpstring", types.Types[TINT], init, conv(n.Left, types.Types[TSTRING]), conv(n.Right, types.Types[TSTRING]))
r = nod(Op(n.Etype), r, nodintconst(0))
}
- r = typecheck(r, Erv)
- if !n.Type.IsBoolean() {
- Fatalf("cmp %v", n.Type)
- }
- r.Type = n.Type
- n = r
+ n = finishcompare(n, r, init)
case OADDSTR:
n = addstr(n, init)