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;
case OAS2DOTTYPE:
case OAS2FUNC:
case OAS2MAPR:
- case OAS2MAPW:
case OAS2RECV:
fmtprint(f, "%,H = %,H", n->list, n->rlist);
break;
[OAS2DOTTYPE] = -1,
[OAS2FUNC] = -1,
[OAS2MAPR] = -1,
- [OAS2MAPW] = -1,
[OAS2RECV] = -1,
[OASOP] = -1,
[OBREAK] = -1,
OAPPEND,
OARRAYBYTESTR, OARRAYRUNESTR,
OSTRARRAYBYTE, OSTRARRAYRUNE,
- OAS, OAS2, OAS2MAPW, OAS2FUNC, OAS2RECV, OAS2MAPR, OAS2DOTTYPE,
+ OAS, OAS2, OAS2FUNC, OAS2RECV, OAS2MAPR, OAS2DOTTYPE,
OASOP,
OBAD,
OCALL, OCALLFUNC, OCALLMETH, OCALLINTER,
{
int cl, cr;
NodeList *ll, *lr;
- Node *l, *r, *rr;
+ Node *l, *r;
Iter s;
Type *t;
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;
}
case OAS2DOTTYPE:
case OAS2RECV:
case OAS2FUNC:
- case OAS2MAPW:
case OAS2MAPR:
case OCLOSE:
case OCOPY:
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);
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
+++ /dev/null
-// $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
-}
m[13] = 'B'
// 13 14
- m[gint()] = gbyte(), false
+ delete(m, gint())
+ gbyte()
if _, present := m[13]; present {
println("bad map removal")
panic("fail")
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"