Commit 5fc3771b authored by Russ Cox's avatar Russ Cox

gc: remove m[k] = x, false

R=ken2
CC=golang-dev
https://golang.org/cl/5376076
parent 90c50700
......@@ -222,7 +222,6 @@ esc(Node *n)
case OAS2RECV: // v, ok = <-ch
case OAS2MAPR: // v, ok = m[k]
case OAS2DOTTYPE: // v, ok = x.(type)
case OAS2MAPW: // m[k] = x, ok
escassign(n->list->n, n->rlist->n);
break;
......
......@@ -802,7 +802,6 @@ stmtfmt(Fmt *f, Node *n)
case OAS2DOTTYPE:
case OAS2FUNC:
case OAS2MAPR:
case OAS2MAPW:
case OAS2RECV:
fmtprint(f, "%,H = %,H", n->list, n->rlist);
break;
......@@ -981,7 +980,6 @@ static int opprec[] = {
[OAS2DOTTYPE] = -1,
[OAS2FUNC] = -1,
[OAS2MAPR] = -1,
[OAS2MAPW] = -1,
[OAS2RECV] = -1,
[OASOP] = -1,
[OBREAK] = -1,
......
......@@ -425,7 +425,7 @@ enum
OAPPEND,
OARRAYBYTESTR, OARRAYRUNESTR,
OSTRARRAYBYTE, OSTRARRAYRUNE,
OAS, OAS2, OAS2MAPW, OAS2FUNC, OAS2RECV, OAS2MAPR, OAS2DOTTYPE,
OAS, OAS2, OAS2FUNC, OAS2RECV, OAS2MAPR, OAS2DOTTYPE,
OASOP,
OBAD,
OCALL, OCALLFUNC, OCALLMETH, OCALLINTER,
......
......@@ -2334,7 +2334,7 @@ typecheckas2(Node *n)
{
int cl, cr;
NodeList *ll, *lr;
Node *l, *r, *rr;
Node *l, *r;
Iter s;
Type *t;
......@@ -2373,16 +2373,7 @@ typecheckas2(Node *n)
if(cl == 1 && cr == 2 && l->op == OINDEXMAP) {
if(l->type == T)
goto out;
n->op = OAS2MAPW;
n->rlist->n = assignconv(r, l->type, "assignment");
rr = n->rlist->next->n;
n->rlist->next->n = assignconv(rr, types[TBOOL], "assignment");
if(isconst(rr, CTBOOL) && !rr->val.u.bval) {
n->op = ODELETE;
n->list = list(list1(l->left), l->right);
n->right = n->rlist->n;
n->rlist = nil;
}
yyerror("assignment count mismatch: %d = %d (use delete)", cl, cr);
goto out;
}
......
......@@ -183,7 +183,6 @@ walkstmt(Node **np)
case OAS2DOTTYPE:
case OAS2RECV:
case OAS2FUNC:
case OAS2MAPW:
case OAS2MAPR:
case OCLOSE:
case OCOPY:
......@@ -644,17 +643,6 @@ walkexpr(Node **np, NodeList **init)
n = mkcall1(mapfndel("mapdelete", t), t->down, init, typename(t), l, r);
goto ret;
case OAS2MAPW:
// map[] = a,b - mapassign2
// a,b = m[i];
*init = concat(*init, n->ninit);
n->ninit = nil;
walkexprlistsafe(n->list, init);
l = n->list->n;
t = l->left->type;
n = mkcall1(mapfn("mapassign2", t), T, init, typename(t), l->left, l->right, n->rlist->n, n->rlist->next->n);
goto ret;
case OAS2DOTTYPE:
// a,b = i.(T)
*init = concat(*init, n->ninit);
......
......@@ -1000,34 +1000,6 @@ runtime·mapassign1(MapType *t, Hmap *h, ...)
runtime·mapassign(t, h, ak, av);
}
// mapassign2(mapType *type, hmap *map[any]any, key any, val any, pres bool);
#pragma textflag 7
void
runtime·mapassign2(MapType *t, Hmap *h, ...)
{
byte *ak, *av, *ap;
if(h == nil)
runtime·panicstring("assignment to entry in nil map");
ak = (byte*)&h + h->ko2;
av = (byte*)&h + h->vo2;
ap = (byte*)&h + h->po2;
if(*ap == false)
av = nil; // delete
runtime·mapassign(t, h, ak, av);
if(debug) {
runtime·prints("mapassign2: map=");
runtime·printpointer(h);
runtime·prints("; key=");
h->keyalg->print(h->keysize, ak);
runtime·prints("\n");
}
}
// mapdelete(mapType *type, hmap *map[any]any, key any)
#pragma textflag 7
void
......
// $G $D/$F.go || echo BUG: bug220
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func main() {
m := make(map[int]map[uint]float64)
m[0] = make(map[uint]float64), false // 6g used to reject this
m[1] = nil
}
......@@ -93,7 +93,8 @@ func main() {
m[13] = 'B'
// 13 14
m[gint()] = gbyte(), false
delete(m, gint())
gbyte()
if _, present := m[13]; present {
println("bad map removal")
panic("fail")
......
......@@ -41,7 +41,6 @@ func main() {
asBool(i < j) // ERROR "cannot use.*type bool.*as type Bool"
_, b = m[2] // ERROR "cannot .* bool.*type Bool"
m[2] = 1, b // ERROR "cannot use.*type Bool.*as type bool"
var inter interface{}
_, b = inter.(Map) // ERROR "cannot .* bool.*type Bool"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment