-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile: fix export/import of range loop.
As with other recent issues, the Init field of a range loop was not being handled properly. Generally, it is much better to explicitly import/export the Init statements, else they are incorrectly added before the associated node, rather than as the Init value of the node. This was causing labels to not be correctly added to the range loop that it is immediately preceding. Made the ORANGE handling completely similar to the OFOR handling. Fixes #48462 Change-Id: I999530e84f9357f81deaa3dda50660061f710e7c Reviewed-on: https://go-review.googlesource.com/c/go/+/350911 Run-TryBot: Dan Scales <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]> Trust: Dan Scales <[email protected]>
- Loading branch information
Showing
5 changed files
with
63 additions
and
8 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
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,22 @@ | ||
// Copyright 2021 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 a | ||
|
||
func Unique[T comparable](set []T) []T { | ||
nset := make([]T, 0, 8) | ||
|
||
loop: | ||
for _, s := range set { | ||
for _, e := range nset { | ||
if s == e { | ||
continue loop | ||
} | ||
} | ||
|
||
nset = append(nset, s) | ||
} | ||
|
||
return nset | ||
} |
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,23 @@ | ||
// Copyright 2021 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 | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
|
||
"a" | ||
) | ||
|
||
func main() { | ||
e := []int{1, 2, 2, 3, 1, 6} | ||
|
||
got := a.Unique(e) | ||
want := []int{1, 2, 3, 6} | ||
if !reflect.DeepEqual(got, want) { | ||
panic(fmt.Sprintf("got %d, want %d", got, want)) | ||
} | ||
|
||
} |
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,7 @@ | ||
// rundir -G=3 | ||
|
||
// Copyright 2021 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 ignored |