mirror of
https://github.com/golang/go.git
synced 2025-05-13 11:24:40 +00:00
reject new of function type
R=ken OCL=17598 CL=17598
This commit is contained in:
parent
f0e93e8cc5
commit
dbabeb1d7a
@ -1824,6 +1824,10 @@ newcompat(Node *n)
|
|||||||
|
|
||||||
t = t->type;
|
t = t->type;
|
||||||
switch(t->etype) {
|
switch(t->etype) {
|
||||||
|
case TFUNC:
|
||||||
|
yyerror("cannot make new %T", t);
|
||||||
|
break;
|
||||||
|
|
||||||
case TMAP:
|
case TMAP:
|
||||||
r = mapop(n, Erv);
|
r = mapop(n, Erv);
|
||||||
return r;
|
return r;
|
||||||
|
14
test/newfn.go
Normal file
14
test/newfn.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// errchk $G $D/$F.go
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func main()
|
||||||
|
{
|
||||||
|
f := new(()); // ERROR "new"
|
||||||
|
g := new((x int, f float) string); // ERROR "new"
|
||||||
|
h := new(*()); // ok
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user