-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile: avoid copying Pos from ONAME when creating converts for …
…maps ONAME nodes are shared, so using their position for anything is almost always a mistake. There are probably more instances of this mistake elsewhere. For now, handle the case of map key temporaries, where it's been a problem. Fixes #53456. Change-Id: Id44e845d08d428592ad3ba31986635b6b87b0041 Reviewed-on: https://go-review.googlesource.com/c/go/+/417076 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
3 changed files
with
64 additions
and
25 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,19 @@ | ||
package main | ||
|
||
type T struct { | ||
m map[int]int | ||
} | ||
|
||
func main() { | ||
t := T{ | ||
m: make(map[int]int), | ||
} | ||
t.Inc(5) | ||
t.Inc(7) | ||
} | ||
|
||
func (s *T) Inc(key int) { | ||
v := s.m[key] // break, line 16 | ||
v++ | ||
s.m[key] = v // also here | ||
} |
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