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
98b34e5b
Commit
98b34e5b
authored
Mar 04, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reject invalid map key types at compile time
R=ken OCL=25720 CL=25720
parent
0793c883
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
12 deletions
+24
-12
src/cmd/gc/go.h
src/cmd/gc/go.h
+1
-0
src/cmd/gc/go.y
src/cmd/gc/go.y
+4
-12
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+19
-0
No files found.
src/cmd/gc/go.h
View file @
98b34e5b
...
...
@@ -657,6 +657,7 @@ int isslice(Type*);
int
isinter
(
Type
*
);
int
isnilinter
(
Type
*
);
int
isddd
(
Type
*
);
Type
*
maptype
(
Type
*
,
Type
*
);
Type
*
dclmethod
(
Type
*
);
Type
*
methtype
(
Type
*
);
int
methconv
(
Type
*
);
...
...
src/cmd/gc/go.y
View file @
98b34e5b
...
...
@@ -1019,9 +1019,7 @@ convtype:
|
LMAP
'['
type
']'
type
{
//
map
literal
$$
=
typ
(
TMAP
);
$$->
down
=
$
3
;
$$->
type
=
$
5
;
$$
=
maptype
($
3
,
$
5
);
}
|
structtype
|
'('
type
')'
...
...
@@ -1126,9 +1124,7 @@ Aothertype:
}
|
LMAP
'['
type
']'
Atype
{
$$
=
typ
(
TMAP
);
$$->
down
=
$
3
;
$$->
type
=
$
5
;
$$
=
maptype
($
3
,
$
5
);
}
|
'*'
Atype
{
...
...
@@ -1160,9 +1156,7 @@ Bothertype:
}
|
LMAP
'['
type
']'
Btype
{
$$
=
typ
(
TMAP
);
$$->
down
=
$
3
;
$$->
type
=
$
5
;
$$
=
maptype
($
3
,
$
5
);
}
|
'*'
Btype
{
...
...
@@ -1806,9 +1800,7 @@ hidden_type1:
}
|
LMAP
'['
hidden_type
']'
hidden_type
{
$$
=
typ
(
TMAP
);
$$->
down
=
$
3
;
$$->
type
=
$
5
;
$$
=
maptype
($
3
,
$
5
);
}
|
LSTRUCT
'{'
ohidden_structdcl_list
'}'
{
...
...
src/cmd/gc/subr.c
View file @
98b34e5b
...
...
@@ -305,6 +305,25 @@ algtype(Type *t)
return
a
;
}
Type
*
maptype
(
Type
*
key
,
Type
*
val
)
{
Type
*
t
;
if
(
key
!=
nil
&&
key
->
etype
!=
TANY
&&
algtype
(
key
)
==
ANOEQ
)
yyerror
(
"invalid map key type %T"
,
key
);
t
=
typ
(
TMAP
);
t
->
down
=
key
;
t
->
type
=
val
;
return
t
;
}
int
iskeytype
(
Type
*
t
)
{
return
algtype
(
t
)
!=
ANOEQ
;
}
Node
*
list
(
Node
*
a
,
Node
*
b
)
{
...
...
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