-
Notifications
You must be signed in to change notification settings - Fork 589
Open
Description
If a tied scalar is localized with an initialization value, STORE is first called with undef, and then again with the initialization value. This breaks if the tie implementation is unable to store an undefined value.
Legalistically speaking, 'man perlsub' implies that this should not happen where says "If no initializer is given for a particular [localized] variable, it is created with an undefined value" (i.e. it should not be created with undef if an initializer is given).
Anyway, it would be great if either
- Undef is not first stored when an initializer is present, OR
- A documented way is provided for a STORE implementation to know that it is okay to ignore the call because another STORE with the initializer is coming.
#!/usr/bin/perl
use strict; use warnings;
package Tiepkg;
sub TIESCALAR { my ($class) = @_; bless {}, $class }
sub FETCH { print "**FETCH\n"; 42 }
sub STORE { print "**STORE ", ($_[1]//"undef"), "\n";
print "!! I can't do that !!\n" unless defined($_[1]);
}
package main;
our $tvar; tie $tvar, 'Tiepkg';
{
print "--Before localizing\n";
local $tvar = 100;
print "--After localizing\n";
}
Metadata
Metadata
Assignees
Labels
No labels