File tree 2 files changed +30
-2
lines changed
src/cmd/compile/internal/gc
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -339,13 +339,15 @@ func Main() {
339
339
// Phase 1: const, type, and names and types of funcs.
340
340
// This will gather all the information about types
341
341
// and methods but doesn't depend on any of it.
342
+ // We also defer type alias declarations until phase 2
343
+ // to avoid cycles like #18640.
342
344
defercheckwidth ()
343
345
344
346
// Don't use range--typecheck can add closures to xtop.
345
347
timings .Start ("fe" , "typecheck" , "top1" )
346
348
for i := 0 ; i < len (xtop ); i ++ {
347
349
n := xtop [i ]
348
- if op := n .Op ; op != ODCL && op != OAS && op != OAS2 {
350
+ if op := n .Op ; op != ODCL && op != OAS && op != OAS2 && ( op != ODCLTYPE || ! n . Left . Name . Param . Alias ) {
349
351
xtop [i ] = typecheck (n , Etop )
350
352
}
351
353
}
@@ -357,7 +359,7 @@ func Main() {
357
359
timings .Start ("fe" , "typecheck" , "top2" )
358
360
for i := 0 ; i < len (xtop ); i ++ {
359
361
n := xtop [i ]
360
- if op := n .Op ; op == ODCL || op == OAS || op == OAS2 {
362
+ if op := n .Op ; op == ODCL || op == OAS || op == OAS2 || op == ODCLTYPE && n . Left . Name . Param . Alias {
361
363
xtop [i ] = typecheck (n , Etop )
362
364
}
363
365
}
Original file line number Diff line number Diff line change
1
+ // compile
2
+
3
+ // Copyright 2017 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
+ type (
10
+ a = b
11
+ b struct {
12
+ * a
13
+ }
14
+
15
+ c struct {
16
+ * d
17
+ }
18
+ d = c
19
+
20
+ e = f
21
+ f = g
22
+ g = []h
23
+ h i
24
+ i = j
25
+ j = e
26
+ )
You can’t perform that action at this time.
0 commit comments