File tree 3 files changed +27
-3
lines changed
src/cmd/compile/internal/noder
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,11 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
46
46
n .SetTypecheck (1 )
47
47
return n
48
48
case * syntax.DeclStmt :
49
- if _ , ok := stmt .DeclList [0 ].(* syntax.TypeDecl ); ok && g .topFuncIsGeneric {
50
- // TODO: remove this restriction. See issue 47631.
51
- base .ErrorfAt (g .pos (stmt ), "type declarations inside generic functions are not currently supported" )
49
+ if g .topFuncIsGeneric && len (stmt .DeclList ) > 0 {
50
+ if _ , ok := stmt .DeclList [0 ].(* syntax.TypeDecl ); ok {
51
+ // TODO: remove this restriction. See issue 47631.
52
+ base .ErrorfAt (g .pos (stmt ), "type declarations inside generic functions are not currently supported" )
53
+ }
52
54
}
53
55
n := ir .NewBlockStmt (g .pos (stmt ), nil )
54
56
g .decls (& n .List , stmt .DeclList )
Original file line number Diff line number Diff line change
1
+ // compile
2
+
3
+ // Copyright 2021 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
+ var ()
11
+ }
Original file line number Diff line number Diff line change
1
+ // compile -G=3
2
+
3
+ // Copyright 2021 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 [T any ]() {
10
+ var ()
11
+ }
You can’t perform that action at this time.
0 commit comments