File tree 2 files changed +27
-1
lines changed
src/cmd/compile/internal/typecheck 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ func typecheckrangeExpr(n *ir.RangeStmt) {
71
71
72
72
do := func (nn ir.Node , t * types.Type ) {
73
73
if nn != nil {
74
- if ir .DeclaredBy (nn , n ) {
74
+ if ir .DeclaredBy (nn , n ) && nn . Type () == nil {
75
75
nn .SetType (t )
76
76
} else if nn .Type () != nil {
77
77
if op , why := Assignop (t , nn .Type ()); op == ir .OXXX {
Original file line number Diff line number Diff line change
1
+ // compile
2
+
3
+ // Copyright 2023 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package p
8
+
9
+ func f () {
10
+ F ([]int {}, func (* int ) bool { return true })
11
+ }
12
+
13
+ func F [S []E , E any ](a S , fn func (* E ) bool ) {
14
+ for _ , v := range a {
15
+ G (a , func (e E ) bool { return fn (& v ) })
16
+ }
17
+ }
18
+
19
+ func G [E any ](s []E , f func (E ) bool ) int {
20
+ for i , v := range s {
21
+ if f (v ) {
22
+ return i
23
+ }
24
+ }
25
+ return - 1
26
+ }
You can’t perform that action at this time.
0 commit comments