See chrstphrchvz/perl-tcl-ptk#17: assigning undef to a widget textvariable should behave the same as assigning an empty string, but unlike Perl/Tk a Use of uninitialized value in subroutine entry warning is emitted for programs with use warnings 'uninitialized'.
The issue is due to something affecting Tcl::Var, which is what widget textvariables are tied to. A more general example:
use warnings 'uninitialized';
use strict;
use Tcl;
my $i = new Tcl;
$i->Init;
my $t = ';l;;gmlxzssaw';
tie $t, 'Tcl::Var', $i, 'tvar';
$t = undef;
The STORE implementation for Tcl::Var in Tcl.xs uses TclObjFromSv() without first checking SvOK() (i.e. to not pass it an undef SV). TclObjFromSv() has several cases for possible types of SVs, but not one specifically for undef SVs, and the existing fallback case uses SvPV(sv, length) without first checking SvOK(sv), which causes the warning message to be emitted.
I would argue that this should be fixed by adding proper handling of undef SVs to TclObjFromSv(). Making it the first case checked could be ideal.
See chrstphrchvz/perl-tcl-ptk#17: assigning
undef
to a widget textvariable should behave the same as assigning an empty string, but unlike Perl/Tk aUse of uninitialized value in subroutine entry
warning is emitted for programs withuse warnings 'uninitialized'
.The issue is due to something affecting Tcl::Var, which is what widget textvariables are tied to. A more general example:
The
STORE
implementation for Tcl::Var in Tcl.xs usesTclObjFromSv()
without first checkingSvOK()
(i.e. to not pass it anundef
SV).TclObjFromSv()
has several cases for possible types of SVs, but not one specifically forundef
SVs, and the existing fallback case usesSvPV(sv, length)
without first checkingSvOK(sv)
, which causes the warning message to be emitted.I would argue that this should be fixed by adding proper handling of
undef
SVs toTclObjFromSv()
. Making it the first case checked could be ideal.