* Parameter error trapped too late
@ 2002-09-16 14:03 Peter Stephenson
2002-09-16 15:00 ` PATCH " Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2002-09-16 14:03 UTC (permalink / raw)
To: Zsh hackers list
% zsh -c 'fn() { local 30=foo; }; fn'
BUG: parameter recreated with wrong flags
fn:local: 30: can't assign initial value for array
Seems to have a dire effect on later use of parameters.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* PATCH Re: Parameter error trapped too late
2002-09-16 14:03 Parameter error trapped too late Peter Stephenson
@ 2002-09-16 15:00 ` Bart Schaefer
2002-09-16 15:59 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2002-09-16 15:00 UTC (permalink / raw)
To: Peter Stephenson, Zsh hackers list
On Sep 16, 3:03pm, Peter Stephenson wrote:
} Subject: Parameter error trapped too late
}
} % zsh -c 'fn() { local 30=foo; }; fn'
} BUG: parameter recreated with wrong flags
} fn:local: 30: can't assign initial value for array
The simplest fix appears to be the following patch, which has the effect
that instead of this error:
schaefer<501> typeset 30=foo
zsh: 30: can't assign initial value for array
One gets this error:
schaefer<501> typeset 30=foo
zsh: not an identifier: 30
We could refine the error message if that's desirable, but bash2 gives a
similar "not a valid identifier" in that example.
Index: builtin.c
===================================================================
diff -c -r1.17 builtin.c
--- builtin.c 12 Sep 2002 07:59:07 -0000 1.17
+++ builtin.c 16 Sep 2002 14:49:34 -0000
@@ -1909,7 +1909,7 @@
"%s: array elements must be scalar", pname, 0);
return NULL;
}
- } else if (isident(pname)) {
+ } else if (isident(pname) && !idigit(*pname)) {
/*
* Create a new node for a parameter with the flags in `on' minus the
* readonly flag
Index: B02typeset.ztst
===================================================================
diff -c -r1.2 B02typeset.ztst
--- B02typeset.ztst 1 Sep 2002 16:47:40 -0000 1.2
+++ B02typeset.ztst 16 Sep 2002 14:49:38 -0000
@@ -223,7 +223,7 @@
>scalar a r y
# The first declare works around the "not an identifier" bug with -h
- declare \! \# \$ * - ? @
+ declare \! \# \$ * - ? @ 0
typeset -h +g -m *
unset -m *
integer i=9
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH Re: Parameter error trapped too late
2002-09-16 15:00 ` PATCH " Bart Schaefer
@ 2002-09-16 15:59 ` Peter Stephenson
2002-09-18 15:07 ` PATCH (revised) " Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2002-09-16 15:59 UTC (permalink / raw)
To: Zsh hackers list
"Bart Schaefer" wrote:
> schaefer<501> typeset 30=foo
> zsh: not an identifier: 30
>
> We could refine the error message if that's desirable, but bash2 gives a
> similar "not a valid identifier" in that example.
Yes, but bash doesn't allow `30=foo' as a normal assignment whereas zsh
does, so I think a different error message here might be better.
Something like `identifier not allowed in this context'.
Otherwise this is fine --- there's no likelihood of us allowing
individual positional parameters to be made local.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* PATCH (revised) Re: Parameter error trapped too late
2002-09-16 15:59 ` Peter Stephenson
@ 2002-09-18 15:07 ` Bart Schaefer
2002-09-18 17:47 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2002-09-18 15:07 UTC (permalink / raw)
To: Zsh hackers list
On Sep 16, 4:59pm, Peter Stephenson wrote:
} Subject: Re: PATCH Re: Parameter error trapped too late
}
} > schaefer<501> typeset 30=foo
} > zsh: not an identifier: 30
} >
} > We could refine the error message if that's desirable, but bash2 gives a
} > similar "not a valid identifier" in that example.
}
} Yes, but bash doesn't allow `30=foo' as a normal assignment whereas zsh
} does, so I think a different error message here might be better.
} Something like `identifier not allowed in this context'.
How about the following, then. Is there any reason that zerrnam() was not
already being used for the "not an identifier" complaint? To pretend that
the error came from the parser, perhaps? Bash2's error in this same case
includes the name of the command.
Index: builtin.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/builtin.c,v
retrieving revision 1.17
diff -c -r1.17 builtin.c
--- builtin.c 12 Sep 2002 07:59:07 -0000 1.17
+++ builtin.c 18 Sep 2002 14:49:06 -0000
@@ -1909,7 +1909,7 @@
"%s: array elements must be scalar", pname, 0);
return NULL;
}
- } else if (isident(pname)) {
+ } else if (isident(pname) && !idigit(*pname)) {
/*
* Create a new node for a parameter with the flags in `on' minus the
* readonly flag
@@ -1918,7 +1918,10 @@
DPUTS(!pm, "BUG: parameter not created");
pm->ct = auxlen;
} else {
- zerr("not an identifier: %s", pname, 0);
+ if (isident(pname))
+ zerrnam(cname, "not valid in this context: %s", pname, 0);
+ else
+ zerrnam(cname, "not an identifier: %s", pname, 0);
return NULL;
}
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH (revised) Re: Parameter error trapped too late
2002-09-18 15:07 ` PATCH (revised) " Bart Schaefer
@ 2002-09-18 17:47 ` Peter Stephenson
0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2002-09-18 17:47 UTC (permalink / raw)
To: Zsh hackers list
"Bart Schaefer" wrote:
> How about the following, then.
OK
> Is there any reason that zerrnam() was not
> already being used for the "not an identifier" complaint?
I can't believe there was. These were never completely consistent.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-09-18 17:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-16 14:03 Parameter error trapped too late Peter Stephenson
2002-09-16 15:00 ` PATCH " Bart Schaefer
2002-09-16 15:59 ` Peter Stephenson
2002-09-18 15:07 ` PATCH (revised) " Bart Schaefer
2002-09-18 17:47 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).