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
27970af5
Commit
27970af5
authored
Feb 12, 2013
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/types: print, println accept 0 or more arguments
R=adonovan CC=golang-dev
https://golang.org/cl/7304089
parent
17377ab6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
+37
-5
src/pkg/go/types/builtins.go
src/pkg/go/types/builtins.go
+9
-3
src/pkg/go/types/testdata/builtins.src
src/pkg/go/types/testdata/builtins.src
+26
-0
src/pkg/go/types/universe.go
src/pkg/go/types/universe.go
+2
-2
No files found.
src/pkg/go/types/builtins.go
View file @
27970af5
...
...
@@ -41,7 +41,7 @@ func (check *checker) builtin(x *operand, call *ast.CallExpr, bin *builtin, iota
if
n
>
0
{
arg0
=
args
[
0
]
switch
id
{
case
_Make
,
_New
,
_Trace
:
case
_Make
,
_New
,
_
Print
,
_Println
,
_
Trace
:
// respective cases below do the work
default
:
// argument must be an expression
...
...
@@ -301,9 +301,15 @@ func (check *checker) builtin(x *operand, call *ast.CallExpr, bin *builtin, iota
x
.
mode
=
variable
x
.
typ
=
&
Pointer
{
Base
:
resultTyp
}
case
_Panic
,
_Print
,
_Println
:
for
_
,
arg
:=
range
args
[
1
:
]
{
case
_Panic
:
x
.
mode
=
novalue
case
_Print
,
_Println
:
for
_
,
arg
:=
range
args
{
check
.
expr
(
x
,
arg
,
nil
,
-
1
)
if
x
.
mode
==
invalid
{
goto
Error
}
}
x
.
mode
=
novalue
...
...
src/pkg/go/types/testdata/builtins.src
View file @
27970af5
...
...
@@ -214,6 +214,32 @@ func _new() {
new
/*
ERROR
"not used"
*/
(
int
)
}
func
_panic
()
{
panic
/*
ERROR
"arguments"
*/
()
panic
/*
ERROR
"arguments"
*/
(
1
,
2
)
panic
(
0
)
panic
(
"foo"
)
panic
(
false
)
}
func
_print
()
{
print
()
print
(
1
)
print
(
1
,
2
)
print
(
"foo"
)
print
(
2.718281828
)
print
(
false
)
}
func
_println
()
{
println
()
println
(
1
)
println
(
1
,
2
)
println
(
"foo"
)
println
(
2.718281828
)
println
(
false
)
}
func
_real
()
{
var
f32
float32
var
f64
float64
...
...
src/pkg/go/types/universe.go
View file @
27970af5
...
...
@@ -73,8 +73,8 @@ var predeclaredFunctions = [...]*builtin{
{
_Make
,
"make"
,
1
,
true
,
false
},
{
_New
,
"new"
,
1
,
false
,
false
},
{
_Panic
,
"panic"
,
1
,
false
,
true
},
{
_Print
,
"print"
,
1
,
true
,
true
},
{
_Println
,
"println"
,
1
,
true
,
true
},
{
_Print
,
"print"
,
0
,
true
,
true
},
{
_Println
,
"println"
,
0
,
true
,
true
},
{
_Real
,
"real"
,
1
,
false
,
false
},
{
_Recover
,
"recover"
,
0
,
false
,
true
},
...
...
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