sibl = kid->op_sibling;
switch (oa & 7) {
case OA_SCALAR:
+ /* list seen where single (scalar) arg expected? */
+ if (numargs == 1 && !(oa >> 4)
+ && kid->op_type == OP_LIST && type != OP_SCALAR)
+ {
+ return too_many_arguments(o,PL_op_desc[type]);
+ }
scalar(kid);
break;
case OA_LIST:
break;
case OA_AVREF:
if (kid->op_type == OP_CONST &&
- (kid->op_private & OPpCONST_BARE)) {
+ (kid->op_private & OPpCONST_BARE))
+ {
char *name = SvPVx(((SVOP*)kid)->op_sv, n_a);
OP *newop = newAVREF(newGVOP(OP_GV, 0,
gv_fetchpv(name, TRUE, SVt_PVAV) ));
break;
case OA_HVREF:
if (kid->op_type == OP_CONST &&
- (kid->op_private & OPpCONST_BARE)) {
+ (kid->op_private & OPpCONST_BARE))
+ {
char *name = SvPVx(((SVOP*)kid)->op_sv, n_a);
OP *newop = newHVREF(newGVOP(OP_GV, 0,
gv_fetchpv(name, TRUE, SVt_PVHV) ));
case OA_FILEREF:
if (kid->op_type != OP_GV && kid->op_type != OP_RV2GV) {
if (kid->op_type == OP_CONST &&
- (kid->op_private & OPpCONST_BARE)) {
+ (kid->op_private & OPpCONST_BARE))
+ {
OP *newop = newGVOP(OP_GV, 0,
gv_fetchpv(SvPVx(((SVOP*)kid)->op_sv, n_a), TRUE,
SVt_PVIO) );
better, IRIX 6.2 or better. Naturally 64-bit platforms like Digital
UNIX and UNICOS also have 64-bit support.
+=head2 Better syntax checks on parenthesized unary operators
+
+Expressions such as:
+
+ print defined(&foo,&bar,&baz);
+ print uc("foo","bar","baz");
+ undef($foo,&bar);
+
+used to be accidentally allowed in earlier versions, and produced
+unpredictable behavior. Some of them produced ancillary warnings
+when used in this way, while others silently did the wrong thing.
+
+The parenthesized forms of most unary operators that expect a single
+argument will now ensure that they are not called with more than one
+argument, making the above cases syntax errors. Note that the usual
+behavior of:
+
+ print defined &foo, &bar, &baz;
+ print uc "foo", "bar", "baz";
+ undef $foo, &bar;
+
+remains unchanged. See L<perlop>.
+
=head1 Supported Platforms
=over 4
the construction C<@{[ (some expression) ]}>, but usually a simple
C<(some expression)> suffices.
+Though C<scalar> can be considered in general to be a unary operator,
+EXPR is also allowed to be a parenthesized list. The list in fact
+behaves as a scalar comma expression, evaluating all but the last
+element in void context and returning the final element evaluated in
+a scalar context.
+
+The following single statement:
+
+ print uc(scalar(&foo,$bar)),$baz;
+
+is the moral equivalent of these two:
+
+ &foo;
+ print(uc($bar),$baz);
+
+See L<perlop> for more details on unary operators and the comma operator.
+
=item seek FILEHANDLE,POSITION,WHENCE
Sets FILEHANDLE's position, just like the C<fseek()> call of C<stdio()>.
=head2 Terms and List Operators (Leftward)
-A TERM has the highest precedence in Perl. They includes variables,
+A TERM has the highest precedence in Perl. They include variables,
quote and quote-like operators, any expression in parentheses,
and any function whose arguments are parenthesized. Actually, there
aren't really functions in this sense, just list operators and unary
--- /dev/null
+#!./perl
+#
+# check if builtins behave as prototyped
+#
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+
+print "1..7\n";
+
+my $i = 1;
+
+sub foo {}
+my $bar = "bar";
+
+sub test_too_many {
+ eval $_[0];
+ print "not " unless $@ =~ /^Too many arguments/;
+ printf "ok %d\n",$i++;
+}
+
+sub test_no_error {
+ eval $_[0];
+ print "not " if $@;
+ printf "ok %d\n",$i++;
+}
+
+test_too_many($_) for split /\n/,
+q[ defined(&foo, $bar);
+ undef(&foo, $bar);
+ uc($bar,$bar);
+];
+
+test_no_error($_) for split /\n/,
+q[ scalar(&foo,$bar);
+ defined &foo, &foo, &foo;
+ undef &foo, $bar;
+ uc $bar,$bar;
+];