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
811e59f2
Commit
811e59f2
authored
Jul 27, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
named string type bugs
R=ken OCL=32244 CL=32244
parent
03b25a92
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
walk.c
src/cmd/gc/walk.c
+13
-5
bug173.go
test/fixedbugs/bug173.go
+21
-0
No files found.
src/cmd/gc/walk.c
View file @
811e59f2
...
...
@@ -2715,7 +2715,9 @@ stringop(Node *n, int top, NodeList **init)
break
;
case
OSLICE
:
args
=
list1
(
n
->
left
);
r
=
nod
(
OCONV
,
n
->
left
,
N
);
r
->
type
=
types
[
TSTRING
];
args
=
list1
(
r
);
// sys_slicestring(s, lb, hb)
r
=
nod
(
OCONV
,
n
->
right
->
left
,
N
);
...
...
@@ -2733,7 +2735,10 @@ stringop(Node *n, int top, NodeList **init)
case
OINDEX
:
// sys_indexstring(s, i)
args
=
list1
(
n
->
left
);
r
=
nod
(
OCONV
,
n
->
left
,
N
);
r
->
type
=
types
[
TSTRING
];
args
=
list1
(
r
);
r
=
nod
(
OCONV
,
n
->
right
,
N
);
r
->
type
=
types
[
TINT
];
args
=
list
(
args
,
r
);
...
...
@@ -2753,9 +2758,10 @@ stringop(Node *n, int top, NodeList **init)
break
;
case
OARRAY
:
r
=
n
->
left
;
// arraystring([]byte) string;
on
=
syslook
(
"arraystring"
,
0
);
r
=
n
->
left
;
if
(
r
->
type
!=
T
&&
r
->
type
->
type
!=
T
)
{
if
(
istype
(
r
->
type
->
type
,
TINT
)
||
istype
(
r
->
type
->
type
->
type
,
TINT
))
{
// arraystring([]byte) string;
...
...
@@ -4081,7 +4087,7 @@ strng:
tempname
(
ohk
,
types
[
TINT
]);
ha
=
nod
(
OXXX
,
N
,
N
);
// hidden string
tempname
(
ha
,
t
);
tempname
(
ha
,
t
ypes
[
TSTRING
]
);
hv
=
N
;
if
(
v
!=
N
)
{
...
...
@@ -4096,7 +4102,9 @@ strng:
}
// ha = s
a
=
nod
(
OAS
,
ha
,
m
);
a
=
nod
(
OCONV
,
m
,
N
);
a
->
type
=
ha
->
type
;
a
=
nod
(
OAS
,
ha
,
a
);
init
=
list
(
init
,
a
);
// ohk = 0
...
...
test/fixedbugs/bug173.go
0 → 100644
View file @
811e59f2
// $G $D/$F.go || echo BUG: bug173
// 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.
// these used to fail because the runtime
// functions that get called to implement them
// expected string, not T.
package
main
type
T
string
func
main
()
{
var
t
T
=
"hello"
;
println
(
t
[
0
:
4
],
t
[
4
]);
for
i
,
x
:=
range
t
{
}
for
i
:=
range
t
{
}
}
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