in reply to Re^7: shift on empty array in list context broken (show context)
in thread shift on empty array in list context broken
see Update
Ok I've had another go. This time within the debugger and the output is leaning more towards concise. However, I am now unsure whether I have something that could relate to the issue or if it's because am still noobing DB.
Apart from getting contexts out of kilter, there are a couple of issues. Firstly,( moved to new SoPW Should high traceDepth trace into debugger code? )
Secondly, I get a 'panic' warning, about attempting to copy a freed scalar. So I'm in panic mode and posting this now, along with the trace I attempted. Its probably nothing right?
DB<57> x sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ +shift @d }; ${ wants( @a ) } 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; in $=main::wants() from (eval 50)[C:/Dwimperl/perl/lib/perl5db.pl:640 +]:2 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; 0 undef DB<58> x sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ sh +ift @d }; ${ wants( undef @b ) } 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; in $=main::wants(undef) from (eval 51)[C:/Dwimperl/perl/lib/perl5db.p +l:640]:2 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; 0 undef DB<59> x sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ sh +ift @d }; @{ wants( @c , undef @c ) } 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; @{ wants( @c , undef @c ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; @{ wants( @c , undef @c ) }; in $=main::wants('', 1, undef, 2, undef) from (eval 52)[C:/Dwimperl/p +erl/lib/perl5db.pl:640]:2 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; @{ wants( @c , undef @c ) }; panic: attempt to copy freed scalar 302528c to 30257dc at (eval 52)[C: +/Dwimperl/perl/lib/perl5db.pl:640] line 2.
Update Ok scratch that, I added use strict; Also, moved the 'Firstly' out to a new SoPW.
DB<69> x use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( s +hift @d, shift @d ) : shift @d }; wants( @a ) in $=CODE(0x3025d1c)() from (eval 62)[C:/Dwimperl/perl/lib/perl5db.pl +:640]:2 in $=strict::import('strict') from (eval 62)[C:/Dwimperl/perl/lib/pe +rl5db.pl:640]:2 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); in @=main::wants() from (eval 62)[C:/Dwimperl/perl/lib/perl5db.pl:640 +]:2 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 0 undef 1 undef DB<70> x use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( s +hift @d, shift @d ) : shift @d }; wants( undef @b ) in $=CODE(0x3025f1c)() from (eval 63)[C:/Dwimperl/perl/lib/perl5db.pl +:640]:2 in $=strict::import('strict') from (eval 63)[C:/Dwimperl/perl/lib/pe +rl5db.pl:640]:2 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); in @=main::wants(undef) from (eval 63)[C:/Dwimperl/perl/lib/perl5db.p +l:640]:2 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 0 undef 1 undef DB<71> x use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( s +hift @d, shift @d ) : shift @d }; wants( @c, undef @c ) in $=CODE(0x30280a4)() from (eval 64)[C:/Dwimperl/perl/lib/perl5db.pl +:640]:2 in $=strict::import('strict') from (eval 64)[C:/Dwimperl/perl/lib/pe +rl5db.pl:640]:2 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); in @=main::wants(undef) from (eval 64)[C:/Dwimperl/perl/lib/perl5db.p +l:640]:2 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 0 undef 1 undef DB<72>
After attempting to do as you suggested, and reading plenty (read not nearly enough) of documentation, I have a little more appreciation for the debugger and how it can be used. If not actually managing to get any closer to the OP.
As for using wantarray to view the contexts, for a moment there I thought there was a void built-in.But I see now that they are word-strings being returned to represent contexts.
documentation visited
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: shift on empty array in list context broken (show context)
by LanX (Saint) on Jul 20, 2019 at 19:31 UTC | |
by Don Coyote (Hermit) on Jul 21, 2019 at 09:48 UTC | |
by LanX (Saint) on Jul 21, 2019 at 17:56 UTC | |
by Don Coyote (Hermit) on Jul 22, 2019 at 22:23 UTC |