mirror of
https://github.com/golang/go
synced 2024-11-12 01:10:21 -07:00
recognize a defined constant
as a new name in a later declaration (bug 144) R=r OCL=27850 CL=27850
This commit is contained in:
parent
9c3a9b71c8
commit
b03b541b7a
@ -845,6 +845,7 @@ pexpr:
|
||||
| laconst
|
||||
{
|
||||
$$ = nod(OLITERAL, N, N);
|
||||
$$->sym = $1;
|
||||
$$->val = $1->oconst->val;
|
||||
$$->type = $1->oconst->type;
|
||||
}
|
||||
|
@ -3050,12 +3050,29 @@ out:
|
||||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
colasname(Node *n)
|
||||
{
|
||||
switch(n->op) {
|
||||
case ONAME:
|
||||
case ONONAME:
|
||||
break;
|
||||
case OLITERAL:
|
||||
if(n->sym != S)
|
||||
break;
|
||||
// fallthrough
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Node*
|
||||
old2new(Node *n, Type *t)
|
||||
{
|
||||
Node *l;
|
||||
|
||||
if(n->op != ONAME && n->op != ONONAME) {
|
||||
if(!colasname(n)) {
|
||||
yyerror("left side of := must be a name");
|
||||
return n;
|
||||
}
|
||||
@ -3092,7 +3109,7 @@ checkmixed(Node *nl)
|
||||
t = l->type;
|
||||
l = l->left;
|
||||
|
||||
if(l->op != ONAME && l->op != ONONAME)
|
||||
if(!colasname(l))
|
||||
goto allnew;
|
||||
if(l->sym->block == block) {
|
||||
if(!eqtype(l->type, t, 0))
|
||||
|
@ -121,14 +121,6 @@ bugs/bug140.go:6: syntax error near L1
|
||||
bugs/bug140.go:7: syntax error near L2
|
||||
BUG should compile
|
||||
|
||||
=========== bugs/bug144.go
|
||||
bugs/bug144.go:8: left side of := must be a name
|
||||
bugs/bug144.go:8: operation LITERAL not allowed in assignment context
|
||||
bugs/bug144.go:8: illegal types for operand: AS
|
||||
ideal
|
||||
int
|
||||
BUG should compile
|
||||
|
||||
=========== fixedbugs/bug016.go
|
||||
fixedbugs/bug016.go:7: constant -3 overflows uint
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user