Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
fd897ffc
Commit
fd897ffc
authored
Aug 19, 2011
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
type switches: test for pathological case
R=rsc, r CC=golang-dev
https://golang.org/cl/4894057
parent
82189f65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
typeswitch2.go
test/typeswitch2.go
+19
-3
No files found.
test/typeswitch2.go
View file @
fd897ffc
...
@@ -18,11 +18,27 @@ func whatis(x interface{}) string {
...
@@ -18,11 +18,27 @@ func whatis(x interface{}) string {
return
"Reader1"
return
"Reader1"
case
io
.
Reader
:
// ERROR "duplicate"
case
io
.
Reader
:
// ERROR "duplicate"
return
"Reader2"
return
"Reader2"
case
interface
{
r
();
w
()
}
:
case
interface
{
r
()
w
()
}
:
return
"rw"
return
"rw"
case
interface
{
w
();
r
()
}
:
// ERROR "duplicate"
case
interface
{
w
()
r
()
}
:
// ERROR "duplicate"
return
"wr"
return
"wr"
}
}
return
""
return
""
}
}
func
notused
(
x
interface
{})
{
// The first t is in a different scope than the 2nd t; it cannot
// be accessed (=> declared and not used error); but it is legal
// to declare it.
switch
t
:=
0
;
t
:=
x
.
(
type
)
{
// ERROR "declared and not used"
case
int
:
_
=
t
// this is using the t of "t := x.(type)"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment