]> Cypherpunks repositories - gostls13.git/commit
go/types: update operand types early
authorRobert Griesemer <gri@golang.org>
Mon, 11 Mar 2013 20:38:45 +0000 (13:38 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 11 Mar 2013 20:38:45 +0000 (13:38 -0700)
commit5183bfda7590bb14f3be77fdc1852c6b314c0762
tree3b8569a3b23449755880cdf7aac91a667db3bf8f
parented10fa7e75db068f93e7fe7712a8f851b022e261
go/types: update operand types early

For expressions where the result type is independent
of the argument types (comparisons, conversions, rhs
of shifts), set the final expression types for those
subtrees early.

This fixes several bugs where incorrect lhs shift
operands where used (say in a comparison), but were
not reported.

Together with the changes listed below this CL fixes
many type-checker bugs.

Also:
- better documented updateExprType
- added larger comment to expr.go explaining
  the basic expression checking algorithm
- use latest definition for indices and make
  arguments; use the same code to check both
- use the same mechanism for cycle detection
  in constant expressions as for variables
  (new field Constant.visited)
- more tests for complex and make builtins
- many more and systematic tests for shifts;
  moved them into separate testfile
- in the testing code, don't compare the
  expected error pattern against itself
  (the actual message was always ignored...)
- fix affected error patterns in the test files
- various cleanups along the way

R=adonovan
CC=golang-dev
https://golang.org/cl/7432051
13 files changed:
src/pkg/go/types/builtins.go
src/pkg/go/types/check.go
src/pkg/go/types/check_test.go
src/pkg/go/types/const.go
src/pkg/go/types/conversions.go
src/pkg/go/types/expr.go
src/pkg/go/types/operand.go
src/pkg/go/types/stmt.go
src/pkg/go/types/testdata/builtins.src
src/pkg/go/types/testdata/decls1.src
src/pkg/go/types/testdata/expr3.src
src/pkg/go/types/testdata/shifts.src [new file with mode: 0644]
src/pkg/go/types/testdata/stmt0.src