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
14be733a
Commit
14be733a
authored
Aug 24, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug197
R=ken OCL=33765 CL=33765
parent
9feee91d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
2 deletions
+48
-2
const.c
src/cmd/gc/const.c
+2
-0
go.h
src/cmd/gc/go.h
+1
-1
print.c
src/cmd/gc/print.c
+3
-0
typecheck.c
src/cmd/gc/typecheck.c
+9
-1
bug197.go
test/fixedbugs/bug197.go
+33
-0
No files found.
src/cmd/gc/const.c
View file @
14be733a
...
...
@@ -77,6 +77,8 @@ convlit1(Node **np, Type *t, int explicit)
return
;
if
(
eqtype
(
t
,
n
->
type
))
return
;
if
(
!
explicit
&&
n
->
type
->
etype
!=
TIDEAL
&&
n
->
type
!=
idealstring
&&
n
->
type
->
etype
!=
TNIL
)
return
;
//dump("convlit1", n);
if
(
n
->
op
==
OLITERAL
)
{
...
...
src/cmd/gc/go.h
View file @
14be733a
...
...
@@ -330,7 +330,7 @@ enum
OCMPIFACE
,
OCMPSTR
,
OCOMPLIT
,
OMAPLIT
,
OSTRUCTLIT
,
OARRAYLIT
,
OCOMPSLICE
,
OCOMPMAP
,
OCONV
,
OCONVNOP
,
OCONV
A2S
,
OCONV
IFACE
,
OCONVSLICE
,
OCONV
,
OCONVNOP
,
OCONVIFACE
,
OCONVSLICE
,
ODCL
,
ODCLFUNC
,
ODCLFIELD
,
ODCLCONST
,
ODCLTYPE
,
ODOT
,
ODOTPTR
,
ODOTMETH
,
ODOTINTER
,
OXDOT
,
ODOTTYPE
,
...
...
src/cmd/gc/print.c
View file @
14be733a
...
...
@@ -258,6 +258,9 @@ exprfmt(Fmt *f, Node *n, int prec)
break
;
case
OCONV
:
case
OCONVNOP
:
case
OCONVSLICE
:
case
OCONVIFACE
:
fmtprint
(
f
,
"%T("
,
n
->
type
);
exprfmt
(
f
,
n
->
left
,
0
);
fmtprint
(
f
,
")"
);
...
...
src/cmd/gc/typecheck.c
View file @
14be733a
...
...
@@ -87,6 +87,8 @@ reswitch:
ok
|=
Erv
;
if
(
n
->
iota
&&
!
(
top
&
Eiota
))
yyerror
(
"use of iota not in constant initializer"
);
if
(
n
->
val
.
ctype
==
CTSTR
)
n
->
type
=
idealstring
;
goto
ret
;
case
ONONAME
:
...
...
@@ -1268,7 +1270,9 @@ typecheckconv(Node *nconv, Node *n, Type *t, int explicit)
if
(
n
->
type
==
T
)
return
n
;
if
(
cvttype
(
t
,
n
->
type
)
&&
n
->
op
==
OLITERAL
)
{
if
(
n
->
op
==
OLITERAL
)
if
(
explicit
||
n
->
type
->
etype
==
TIDEAL
||
n
->
type
==
idealstring
||
n
->
type
->
etype
==
TNIL
)
if
(
cvttype
(
t
,
n
->
type
))
{
// can convert literal in place
// TODO(rsc) is this needed?
n1
=
nod
(
OXXX
,
N
,
N
);
...
...
@@ -1286,6 +1290,10 @@ typecheckconv(Node *nconv, Node *n, Type *t, int explicit)
return
n
;
case
0
:
if
(
nconv
)
{
nconv
->
op
=
OCONVNOP
;
return
nconv
;
}
return
n
;
}
...
...
test/fixedbugs/bug197.go
0 → 100644
View file @
14be733a
// errchk $G $D/$F.go
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
type
T
int
type
U
int
var
x
int
var
t
T
=
int
(
0
)
// ERROR "cannot use"
var
t1
T
=
int
(
x
)
// ERROR "cannot use"
var
u
U
=
int
(
0
)
// ERROR "cannot use"
var
u1
U
=
int
(
x
)
// ERROR "cannot use"
type
S
string
var
s
S
var
s1
=
s
+
"hello"
var
s2
=
"hello"
+
s
var
s3
=
s
+
string
(
"hello"
)
// ERROR "invalid operation"
var
s4
=
string
(
"hello"
)
+
s
// ERROR "invalid operation"
var
r
string
var
r1
=
r
+
"hello"
var
r2
=
"hello"
+
r
var
r3
=
r
+
string
(
"hello"
)
var
r4
=
string
(
"hello"
)
+
r
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