-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile: properly handle map assignments for OAS2DOTTYPE
The boolean destination in an OAS2DOTTYPE expression craps out during compilation when trying to assign to a map entry because, unlike slice entries, map entries are not directly addressable in memory. The solution is to properly order the boolean destination node so that map entries are set via autotmp variables. Fixes #14678 Change-Id: If344e8f232b5bdac1b53c0f0d21eeb43ab17d3de Reviewed-on: https://go-review.googlesource.com/22833 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
- Loading branch information
1 parent
e6ec820
commit 9d7c9b4
Showing
2 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// run | ||
|
||
// Copyright 2016 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]bool) | ||
i := interface{}(1) | ||
var v int | ||
|
||
// Ensure map is updated properly | ||
_, m[1] = i.(int) | ||
v, m[2] = i.(int) | ||
|
||
if v != 1 { | ||
panic("fail: v should be 1") | ||
} | ||
if m[1] == false { | ||
panic("fail: m[1] should be true") | ||
} | ||
if m[2] == false { | ||
panic("fail: m[2] should be true") | ||
} | ||
} |