Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(419)

Issue 7381052: code review 7381052: go/types: fix type-checking of shift expressions (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 3 months ago by gri
Modified:
12 years, 3 months ago
Reviewers:
CC:
adonovan, axw, golang-dev
Visibility:
Public.

Description

go/types: fix type-checking of shift expressions Completely rethought shift expression type checking. Instead of attempting to type-check them eagerly, now delay the checking of untyped constant lhs in non- constant shifts until the final expression type becomes clear. Once it is clear, update the respective expression tree with the final (not untyped) type and check respective shift lhs' where necessary. This also cleans up another conundrum: How to report the type of untyped constants as it changes from untyped to typed. Now, Context.Expr is only called for an expresion x once x has received its final (not untyped) type (for constant initializers, the final type may still be untyped). With this CL all remaining std lib packages that did not typecheck due to shift errors pass now. TODO: There's a lot of residual stuff that needs to be cleaned up but with this CL all tests pass now.

Patch Set 1 #

Patch Set 2 : diff -r 82796ae901bb https://code.google.com/p/go #

Patch Set 3 : diff -r 1e891021e069 https://code.google.com/p/go #

Patch Set 4 : diff -r 2bf8d07c14c1 https://code.google.com/p/go #

Patch Set 5 : diff -r ab7c5976cb19 https://code.google.com/p/go #

Patch Set 6 : diff -r ab7c5976cb19 https://code.google.com/p/go #

Patch Set 7 : diff -r c3733f9d8642 https://code.google.com/p/go #

Patch Set 8 : diff -r 38b1893be35d https://code.google.com/p/go #

Patch Set 9 : diff -r 38b1893be35d https://code.google.com/p/go #

Patch Set 10 : diff -r 38b1893be35d https://code.google.com/p/go #

Total comments: 13

Patch Set 11 : diff -r 3e3f5a31adaf https://code.google.com/p/go #

Patch Set 12 : diff -r 86983e7002df https://code.google.com/p/go #

Patch Set 13 : diff -r 4cdeb75811c7 https://code.google.com/p/go #

Patch Set 14 : diff -r 4cdeb75811c7 https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+419 lines, -145 lines) Patch
M src/pkg/exp/gotype/gotype_test.go View 1 2 3 4 5 6 7 5 chunks +10 lines, -9 lines 0 comments Download
M src/pkg/go/types/api.go View 1 2 3 4 5 6 7 8 9 10 1 chunk +7 lines, -3 lines 0 comments Download
M src/pkg/go/types/builtins.go View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/types/check.go View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +41 lines, -6 lines 0 comments Download
M src/pkg/go/types/expr.go View 1 2 3 4 5 6 7 8 9 10 11 12 25 chunks +212 lines, -75 lines 0 comments Download
M src/pkg/go/types/stmt.go View 1 2 3 4 5 6 7 8 9 10 9 chunks +44 lines, -37 lines 0 comments Download
M src/pkg/go/types/testdata/expr3.src View 1 2 3 4 5 6 7 8 9 10 1 chunk +84 lines, -3 lines 0 comments Download
M src/pkg/go/types/testdata/stmt0.src View 1 2 3 4 5 6 7 5 chunks +20 lines, -11 lines 0 comments Download

Messages

Total messages: 7
gri
Hello adonovan@google.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
12 years, 3 months ago (2013-02-28 07:29:07 UTC) #1
axw
Thanks! Haven't been through the change in great detail, but I patched and ran my ...
12 years, 3 months ago (2013-02-28 13:30:00 UTC) #2
gri
https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go File src/pkg/go/types/expr.go (left): https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go#oldcode304 src/pkg/go/types/expr.go:304: if !x.isNil() && len(t.Methods) > 0 /* empty interfaces ...
12 years, 3 months ago (2013-02-28 17:33:59 UTC) #3
adonovan
LGTM The two phase bottom-up/top-down approach seems much clearer. https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go File src/pkg/go/types/expr.go (right): https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go#newcode302 src/pkg/go/types/expr.go:302: ...
12 years, 3 months ago (2013-02-28 19:43:07 UTC) #4
gri
Thanks. I will do some more testing (go vet) before submitting. https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go File src/pkg/go/types/expr.go (right): ...
12 years, 3 months ago (2013-02-28 19:49:28 UTC) #5
gri
https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go File src/pkg/go/types/expr.go (right): https://codereview.appspot.com/7381052/diff/14015/src/pkg/go/types/expr.go#newcode480 src/pkg/go/types/expr.go:480: check.invalidOp(y.pos(), "%s: stupid shift", y) On 2013/02/28 19:49:28, gri ...
12 years, 3 months ago (2013-02-28 22:32:04 UTC) #6
gri
12 years, 3 months ago (2013-02-28 23:27:55 UTC) #7
*** Submitted as https://code.google.com/p/go/source/detail?r=f10ff2e7c9bd ***

go/types: fix type-checking of shift expressions

Completely rethought shift expression type checking.
Instead of attempting to type-check them eagerly, now
delay the checking of untyped constant lhs in non-
constant shifts until the final expression type
becomes clear. Once it is clear, update the respective
expression tree with the final (not untyped) type and
check respective shift lhs' where necessary.

This also cleans up another conundrum: How to report
the type of untyped constants as it changes from
untyped to typed. Now, Context.Expr is only called
for an expresion x once x has received its final
(not untyped) type (for constant initializers, the
final type may still be untyped).

With this CL all remaining std lib packages that
did not typecheck due to shift errors pass now.

TODO: There's a lot of residual stuff that needs
to be cleaned up but with this CL all tests pass
now.

R=adonovan, axwalk
CC=golang-dev
https://codereview.appspot.com/7381052
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b