compiler,runtime: support operations on nil map

The index expression and delete keyword are valid on nil maps, so the
runtime must be modified to support this.
This commit is contained in:
Ayke van Laethem
2020-01-22 17:19:21 +01:00
committed by Ayke
parent 53688c86c8
commit 4dfc289ae5
4 changed files with 37 additions and 12 deletions
+2
View File
@@ -44,6 +44,8 @@ func main() {
var nilmap map[string]int
println(m == nil, m != nil, len(m))
println(nilmap == nil, nilmap != nil, len(nilmap))
delete(nilmap, "foo")
println("nilmap:", nilmap["bar"])
println(testmapIntInt[2])
testmapIntInt[2] = 42
println(testmapIntInt[2])
+1
View File
@@ -50,6 +50,7 @@ lookup with comma-ok: eight 8 true
lookup with comma-ok: nokey 0 false
false true 2
true false 0
nilmap: 0
4
42
4321