LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file implements the Check function, which typechecks a package. | 5 // This file implements the Check function, which typechecks a package. |
6 | 6 |
7 package types | 7 package types |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 f := check.funclist[i] | 474 f := check.funclist[i] |
475 if trace { | 475 if trace { |
476 s := "<function literal>" | 476 s := "<function literal>" |
477 if f.obj != nil { | 477 if f.obj != nil { |
478 s = f.obj.Name | 478 s = f.obj.Name |
479 } | 479 } |
480 fmt.Println("---", s) | 480 fmt.Println("---", s) |
481 } | 481 } |
482 check.funcsig = f.sig | 482 check.funcsig = f.sig |
483 check.stmtList(f.body.List) | 483 check.stmtList(f.body.List) |
| 484 if len(f.sig.Results) > 0 && f.body != nil && !check.isTerminati
ng(f.body, "") { |
| 485 check.errorf(f.body.Rbrace, "missing return") |
| 486 } |
484 } | 487 } |
485 | 488 |
486 // remaining untyped expressions must indeed be untyped | 489 // remaining untyped expressions must indeed be untyped |
487 if debug { | 490 if debug { |
488 for x, typ := range check.untyped { | 491 for x, typ := range check.untyped { |
489 if !isUntyped(typ) { | 492 if !isUntyped(typ) { |
490 check.dump("%s: %s (type %s) is not untyped", x.
Pos(), x, typ) | 493 check.dump("%s: %s (type %s) is not untyped", x.
Pos(), x, typ) |
491 panic(0) | 494 panic(0) |
492 } | 495 } |
493 } | 496 } |
494 } | 497 } |
495 | 498 |
496 // notify client of any untyped types left | 499 // notify client of any untyped types left |
497 // TODO(gri) Consider doing this before and | 500 // TODO(gri) Consider doing this before and |
498 // after function body checking for smaller | 501 // after function body checking for smaller |
499 // map size and more immediate feedback. | 502 // map size and more immediate feedback. |
500 if ctxt.Expr != nil { | 503 if ctxt.Expr != nil { |
501 for x, typ := range check.untyped { | 504 for x, typ := range check.untyped { |
502 ctxt.Expr(x, typ, check.constants[x]) | 505 ctxt.Expr(x, typ, check.constants[x]) |
503 } | 506 } |
504 } | 507 } |
505 | 508 |
506 return | 509 return |
507 } | 510 } |
LEFT | RIGHT |