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

Issue 213750043: code review 213750043: compiler: Do not declare type switch variable outside c...

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 8 months ago by cmang
Modified:
10 years, 8 months ago
Reviewers:
iant
CC:
iant, gofrontend-dev_googlegroups.com
Visibility:
Public.

Description

compiler: Do not declare type switch variable outside case statements. For expressions containing a TypeSwitchGuard with a short variable declaration e.g. var := x.(type), the spec says that var is declared at the beginning of the implicit block for each in each clause. Previously, var was declared in the block for the switch statement and each implicit block, which led to errors if the type case clause referenced a type with a similar name as the declared variable. Fixes golang/go#10047.

Patch Set 1 #

Patch Set 2 : diff -r d42a0819e2eb https://code.google.com/p/gofrontend #

Patch Set 3 : diff -r d42a0819e2eb https://code.google.com/p/gofrontend #

Total comments: 4

Patch Set 4 : diff -r d42a0819e2eb https://code.google.com/p/gofrontend #

Patch Set 5 : diff -r d42a0819e2eb https://code.google.com/p/gofrontend #

Unified diffs Side-by-side diffs Delta from patch set Stats (+79 lines, -80 lines) Patch
M go/gogo.cc View 2 chunks +4 lines, -1 line 0 comments Download
M go/parse.h View 3 chunks +2 lines, -8 lines 0 comments Download
M go/parse.cc View 6 chunks +57 lines, -47 lines 0 comments Download
M go/statements.h View 3 chunks +7 lines, -6 lines 0 comments Download
M go/statements.cc View 5 chunks +9 lines, -18 lines 0 comments Download

Messages

Total messages: 7
cmang
Hello iant@golang.org (cc: gofrontend-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/gofrontend
10 years, 8 months ago (2015-03-04 21:45:03 UTC) #1
iant
https://codereview.appspot.com/213750043/diff/40001/go/parse.cc File go/parse.cc (right): https://codereview.appspot.com/213750043/diff/40001/go/parse.cc#newcode4609 go/parse.cc:4609: this->gogo_->current_block()->add_statement(switch_temp); Just use this->gogo_->add_statement(switch_temp);
10 years, 8 months ago (2015-03-04 22:06:31 UTC) #2
cmang
https://codereview.appspot.com/213750043/diff/40001/go/parse.cc File go/parse.cc (right): https://codereview.appspot.com/213750043/diff/40001/go/parse.cc#newcode4609 go/parse.cc:4609: this->gogo_->current_block()->add_statement(switch_temp); On 2015/03/04 22:06:30, iant wrote: > Just use ...
10 years, 8 months ago (2015-03-04 22:09:49 UTC) #3
iant
https://codereview.appspot.com/213750043/diff/40001/go/parse.cc File go/parse.cc (right): https://codereview.appspot.com/213750043/diff/40001/go/parse.cc#newcode4603 go/parse.cc:4603: "no new variables on left side of %<:=%>"); Since ...
10 years, 8 months ago (2015-03-05 02:14:13 UTC) #4
cmang
https://codereview.appspot.com/213750043/diff/40001/go/parse.cc File go/parse.cc (right): https://codereview.appspot.com/213750043/diff/40001/go/parse.cc#newcode4603 go/parse.cc:4603: "no new variables on left side of %<:=%>"); On ...
10 years, 8 months ago (2015-03-05 17:03:29 UTC) #5
iant
LGTM
10 years, 8 months ago (2015-03-06 00:19:37 UTC) #6
iant
10 years, 8 months ago (2015-03-06 00:23:01 UTC) #7
*** Submitted as https://code.google.com/p/gofrontend/source/detail?r=a58c55f615d7 *** compiler: Do not declare type switch variable outside case statements. For expressions containing a TypeSwitchGuard with a short variable declaration e.g. var := x.(type), the spec says that var is declared at the beginning of the implicit block for each in each clause. Previously, var was declared in the block for the switch statement and each implicit block, which led to errors if the type case clause referenced a type with a similar name as the declared variable. Fixes golang/go#10047. LGTM=iant R=iant CC=gofrontend-dev https://codereview.appspot.com/213750043 Committer: Ian Lance Taylor <iant@golang.org>
Sign in to reply to this message.

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