mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +00:00
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:
Vendored
+2
@@ -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])
|
||||
|
||||
Vendored
+1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user