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
b03b541b
Commit
b03b541b
authored
Apr 24, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recognize a defined constant
as a new name in a later declaration (bug 144) R=r OCL=27850 CL=27850
parent
9c3a9b71
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
10 deletions
+20
-10
go.y
src/cmd/gc/go.y
+1
-0
walk.c
src/cmd/gc/walk.c
+19
-2
bug144.go
test/fixedbugs/bug144.go
+0
-0
golden.out
test/golden.out
+0
-8
No files found.
src/cmd/gc/go.y
View file @
b03b541b
...
...
@@ -845,6 +845,7 @@ pexpr:
|
laconst
{
$$
=
nod
(
OLITERAL
,
N
,
N
);
$$->
sym
=
$
1
;
$$->
val
=
$
1
->
oconst
->
val
;
$$->
type
=
$
1
->
oconst
->
type
;
}
...
...
src/cmd/gc/walk.c
View file @
b03b541b
...
...
@@ -3050,12 +3050,29 @@ out:
return
n
;
}
int
colasname
(
Node
*
n
)
{
switch
(
n
->
op
)
{
case
ONAME
:
case
ONONAME
:
break
;
case
OLITERAL
:
if
(
n
->
sym
!=
S
)
break
;
// fallthrough
default:
return
0
;
}
return
1
;
}
Node
*
old2new
(
Node
*
n
,
Type
*
t
)
{
Node
*
l
;
if
(
n
->
op
!=
ONAME
&&
n
->
op
!=
ONONAME
)
{
if
(
!
colasname
(
n
)
)
{
yyerror
(
"left side of := must be a name"
);
return
n
;
}
...
...
@@ -3092,7 +3109,7 @@ checkmixed(Node *nl)
t
=
l
->
type
;
l
=
l
->
left
;
if
(
l
->
op
!=
ONAME
&&
l
->
op
!=
ONONAME
)
if
(
!
colasname
(
l
)
)
goto
allnew
;
if
(
l
->
sym
->
block
==
block
)
{
if
(
!
eqtype
(
l
->
type
,
t
,
0
))
...
...
test/bugs/bug144.go
→
test/
fixed
bugs/bug144.go
View file @
b03b541b
File moved
test/golden.out
View file @
b03b541b
...
...
@@ -121,14 +121,6 @@ bugs/bug140.go:6: syntax error near L1
bugs/bug140.go:7: syntax error near L2
BUG should compile
=========== bugs/bug144.go
bugs/bug144.go:8: left side of := must be a name
bugs/bug144.go:8: operation LITERAL not allowed in assignment context
bugs/bug144.go:8: illegal types for operand: AS
ideal
int
BUG should compile
=========== fixedbugs/bug016.go
fixedbugs/bug016.go:7: constant -3 overflows uint
...
...
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