Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
689b28fd
Commit
689b28fd
authored
Oct 24, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix method function type compare bug (again)
R=ken OCL=17819 CL=17819
parent
c14c961a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
10 deletions
+46
-10
src/cmd/gc/dcl.c
src/cmd/gc/dcl.c
+10
-5
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+15
-2
test/golden.out
test/golden.out
+3
-3
test/method1.go
test/method1.go
+18
-0
No files found.
src/cmd/gc/dcl.c
View file @
689b28fd
...
...
@@ -279,8 +279,10 @@ addmethod(Node *n, Type *t, int local)
d
=
f
;
continue
;
}
if
(
!
eqtype
(
t
,
f
->
type
,
0
))
if
(
!
eqtype
(
t
,
f
->
type
,
0
))
{
yyerror
(
"method redeclared: %S of type %S"
,
sf
,
st
);
print
(
"
\t
%T
\n\t
%T
\n
"
,
f
->
type
,
t
);
}
return
;
}
...
...
@@ -337,10 +339,13 @@ funchdr(Node *n)
// check for same types
if
(
on
!=
N
)
{
if
(
eqtype
(
n
->
type
,
on
->
type
,
0
))
{
if
(
!
eqargs
(
n
->
type
,
on
->
type
))
yyerror
(
"forward declarations not the same: %S"
,
s
);
if
(
!
eqargs
(
n
->
type
,
on
->
type
))
{
yyerror
(
"function arg names changed: %S"
,
s
);
print
(
"
\t
%T
\n\t
%T
\n
"
,
on
->
type
,
n
->
type
);
}
}
else
{
yyerror
(
"redeclare of function: %S"
,
s
);
yyerror
(
"function redeclared: %S"
,
s
);
print
(
"
\t
%T
\n\t
%T
\n
"
,
on
->
type
,
n
->
type
);
on
=
N
;
}
}
...
...
@@ -674,7 +679,7 @@ addvar(Node *n, Type *t, int ctxt)
if
(
s
->
vblock
==
block
)
{
if
(
s
->
oname
!=
N
)
{
yyerror
(
"var %S redeclared in this block"
"
\n
previous declaration at %L"
,
"
\n
\t
previous declaration at %L"
,
s
,
s
->
oname
->
lineno
);
}
else
yyerror
(
"var %S redeclared in this block"
,
s
);
...
...
src/cmd/gc/subr.c
View file @
689b28fd
...
...
@@ -1763,9 +1763,11 @@ eqtype(Type *t1, Type *t2, int d)
return
1
;
case
TFUNC
:
// Loop over structs: receiver, in, out.
t1
=
t1
->
type
;
t2
=
t2
->
type
;
for
(;;)
{
Type
*
ta
,
*
tb
;
if
(
t1
==
t2
)
break
;
if
(
t1
==
T
||
t2
==
T
)
...
...
@@ -1773,8 +1775,19 @@ eqtype(Type *t1, Type *t2, int d)
if
(
t1
->
etype
!=
TSTRUCT
||
t2
->
etype
!=
TSTRUCT
)
return
0
;
if
(
!
eqtype
(
t1
->
type
,
t2
->
type
,
0
))
return
0
;
// Loop over fields in structs, checking type only.
ta
=
t1
->
type
;
tb
=
t2
->
type
;
while
(
ta
!=
tb
)
{
if
(
ta
==
T
||
tb
==
T
)
return
0
;
if
(
ta
->
etype
!=
TFIELD
||
tb
->
etype
!=
TFIELD
)
return
0
;
if
(
!
eqtype
(
ta
->
type
,
tb
->
type
,
0
))
return
0
;
ta
=
ta
->
down
;
tb
=
tb
->
down
;
}
t1
=
t1
->
down
;
t2
=
t2
->
down
;
...
...
test/golden.out
View file @
689b28fd
...
...
@@ -182,9 +182,9 @@ fixedbugs/bug029.go:6: syntax error near int
=========== fixedbugs/bug035.go
fixedbugs/bug035.go:6: var i redeclared in this block
previous declaration at fixedbugs/bug035.go:5
previous declaration at fixedbugs/bug035.go:5
fixedbugs/bug035.go:7: var f redeclared in this block
previous declaration at fixedbugs/bug035.go:5
previous declaration at fixedbugs/bug035.go:5
=========== fixedbugs/bug037.go
fixedbugs/bug037.go:6: vlong: undefined
...
...
@@ -193,7 +193,7 @@ fixedbugs/bug037.go:6: illegal types for operand: AS
=========== fixedbugs/bug039.go
fixedbugs/bug039.go:6: var x redeclared in this block
previous declaration at fixedbugs/bug039.go:5
previous declaration at fixedbugs/bug039.go:5
=========== fixedbugs/bug049.go
fixedbugs/bug049.go:6: illegal conversion of nil to string
...
...
test/method1.go
0 → 100644
View file @
689b28fd
// 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
struct
{
}
func
(
t
*
T
)
M
(
int
,
string
);
func
(
t
*
T
)
M
(
int
,
float
)
{
}
// ERROR "redeclared"
func
f
(
int
,
string
);
func
f
(
int
,
float
)
{
}
// ERROR "redeclared"
func
g
(
a
int
,
b
string
);
func
g
(
a
int
,
c
string
);
// ERROR "names changed"
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