Skip to content

Commit b826448

Browse files
committed
ParseXS: improve an error message
For the specific case of RETVAL appearing in an OUTPUT section when NO_OUTPUT is in force, output this new more specific error message: can't use RETVAL in OUTPUT when NO_OUTPUT declared rather than the more generic (and in this case, slightly confusing) message: OUTPUT RETVAL not a parameter
1 parent a9b73fc commit b826448

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,11 +2119,14 @@ sub OUTPUT_handler {
21192119
next;
21202120
}
21212121

2122+
if ($outarg eq "RETVAL" and $self->{xsub_seen_NO_OUTPUT}) {
2123+
$self->blurt("Error: can't use RETVAL in OUTPUT when NO_OUTPUT declared");
2124+
next;
2125+
}
2126+
21222127
if ( !$param # no such param or, for RETVAL, RETVAL was void
2123-
or ($outarg eq "RETVAL"
2124-
? $self->{xsub_seen_NO_OUTPUT} # mustn't return in this case
2125-
: !$param->{arg_num}) # not bound to an arg which can be updated
2126-
)
2128+
# not bound to an arg which can be updated
2129+
or $outarg ne "RETVAL" && !$param->{arg_num})
21272130
{
21282131
$self->blurt("Error: OUTPUT $outarg not a parameter");
21292132
next;

dist/ExtUtils-ParseXS/t/001-basic.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,7 @@ EOF
24182418
| OUTPUT:
24192419
| RETVAL
24202420
EOF
2421-
[ 1, 0, qr/Error: OUTPUT RETVAL not a parameter/, "OUTPUT err" ],
2421+
[ 1, 0, qr/Error: can't use RETVAL in OUTPUT when NO_OUTPUT declared/, "OUTPUT err" ],
24222422
],
24232423
24242424
[
@@ -2429,7 +2429,7 @@ EOF
24292429
| OUTPUT:
24302430
| RETVAL
24312431
EOF
2432-
[ 1, 0, qr/Error: OUTPUT RETVAL not a parameter/, "OUTPUT err" ],
2432+
[ 1, 0, qr/Error: can't use RETVAL in OUTPUT when NO_OUTPUT declared/, "OUTPUT err" ],
24332433
],
24342434
24352435
[
@@ -2442,7 +2442,7 @@ EOF
24422442
| OUTPUT:
24432443
| RETVAL
24442444
EOF
2445-
[ 1, 0, qr/Error: OUTPUT RETVAL not a parameter/, "OUTPUT err" ],
2445+
[ 1, 0, qr/Error: can't use RETVAL in OUTPUT when NO_OUTPUT declared/, "OUTPUT err" ],
24462446
],
24472447
24482448

0 commit comments

Comments
 (0)