@@ -345,10 +345,6 @@ BEGIN {
345
345
346
346
# Per-XSUB INPUT section parsing state:
347
347
348
- ' xsub_map_varname_to_seen_in_INPUT' , # Hash: map argument names to a
349
- # 'seen in INPUT' boolean (for duplicate
350
- # spotting).
351
-
352
348
' xsub_seen_RETVAL_in_INPUT' , # Seen var called 'RETVAL' in an INPUT section.
353
349
354
350
707
703
708
704
# Initialize some per-XSUB instance variables:
709
705
710
- foreach my $member (qw(
711
- xsub_map_varname_to_seen_in_INPUT
712
- ) )
713
- {
714
- $self -> {$member } = {};
715
- }
716
-
717
706
$self -> {xsub_seen_PROTOTYPE } = 0;
718
707
$self -> {xsub_seen_SCOPE } = 0;
719
708
$self -> {xsub_seen_INTERFACE_or_MACRO } = 0;
@@ -1284,7 +1273,6 @@ EOF
1284
1273
# PREINIT/INPUT
1285
1274
#
1286
1275
# keep track of which vars have been seen
1287
- %{ $self -> {xsub_map_varname_to_seen_in_INPUT } } = ();
1288
1276
$self -> {xsub_seen_RETVAL_in_OUTPUT } = 0; # RETVAL seen in OUTPUT section
1289
1277
1290
1278
# Process any implicit INPUT section.
@@ -2374,14 +2362,34 @@ sub INPUT_handler {
2374
2362
# flag 'RETVAL' as having been seen
2375
2363
$self -> {xsub_seen_RETVAL_in_INPUT } |= $var_name eq " RETVAL" ;
2376
2364
2365
+ my ($var_num , $is_alien );
2377
2366
my $sig_param = $self -> {xsub_sig }{names }{$var_name };
2378
2367
2379
- # The index number of the parameter. The counting starts at 1 and skips
2380
- # fake parameters like 'length(s))'. If not found, flag it as 'alien':
2381
- # a var which appears in an INPUT section but not in the XSUB's
2382
- # signature. Legal but nasty.
2383
- my $var_num = $sig_param -> {arg_num };
2384
- my $is_alien = !defined ($var_num );
2368
+ if (defined $sig_param ) {
2369
+ # The var appeared in the signature too.
2370
+
2371
+ # Check for duplicate definitions of a particular parameter name.
2372
+ # This can be either because it has appeared in multiple INPUT
2373
+ # lines, or because the type was already defined in the signature,
2374
+ # and thus shouldn't be defined again. The exception to this are
2375
+ # synthetic params like THIS, which are assigned a provisional type
2376
+ # which can be overridden.
2377
+ if ( $sig_param -> {in_input }
2378
+ or (!$sig_param -> {is_synthetic } and exists $sig_param -> {type })
2379
+ ) {
2380
+ $self -> blurt(
2381
+ " Error: duplicate definition of argument '$var_name ' ignored" );
2382
+ next ;
2383
+ }
2384
+ $sig_param -> {in_input } = 1;
2385
+ $var_num = $sig_param -> {arg_num };
2386
+ }
2387
+ else {
2388
+ # The var is in an INPUT line, but not in signature. Treat it as a
2389
+ # general var declaration (which really should have been in a
2390
+ # PREINIT section). Legal but nasty: flag is as 'alien'
2391
+ $is_alien = 1;
2392
+ }
2385
2393
2386
2394
# Parse the initialisation part of the INPUT line (if any)
2387
2395
0 commit comments