RE: [tcltk-perl] return of 1=>1.0 transformation error
Brought to you by:
hobbs
|
From: Jeff H. <je...@Ac...> - 2004-04-28 17:01:15
|
This is the exact code being run:
my $row = 0;
foreach my $leaf('Tk.xbm','Xcamel.gif')
{
my $file = "./t/$leaf"; #Tk->findINC($leaf);
my $src = $mw->Photo(-file => $file);
ok(defined($src),1," Cannot load $file");
my $kind = 'Initial';
my $col = 0;
$mw->Label(-text => 'Initial')
->grid(-row => $row, -column => $col);
$mw->Label(-background => 'white',-image => $src)
->grid(-row => $row+1, -column => $col++);
...
We see that the problem is at -row 1, so that last line is the
issue. That this becomes SvNOK w/o being SvIOK in Perl 5.6
seems "just wrong" to me (and obviously to others as 5.8 corrects
the issue). You guys are right that I should try without the
SvIOK as well, but still, this is a wacky promotion behavior.
Jeff
> > > Tcl error 'bad grid value "1.0": must be a non-negative integer at
> > > d:/Perl56/site/lib/Tcl.pm line 363. ' while invoking scalar result
> > > call:
> > > "grid .lbl02 -row 1 -column 0" at
> > ...
> > > perl-5.8.2 passes test without this error, 5.6.0 and 5.6.1 fail.
> >
> > This is specifically supposed to be handled by this code in
> > TclObjFromSv:
> >
> > else if (SvNOK(sv)) {
> > double dval = SvNV(sv);
> > int ival;
> > /*
> > * Account for some perl versions aggressive NOK-ness where
> > * an int was all that was intented.
> > */
> > if (SvIOK(sv) && ((double)(ival = SvIV(sv)) == dval)) {
> > objPtr = Tcl_NewIntObj(ival);
> > } else {
> > objPtr = Tcl_NewDoubleObj(dval);
> > }
> > }
> >
> > as it was an issue that 5.6 decided to aggressively promote "1" with
> > SvNOK as well as SvIOK, whereas 5.8 is corrected to not do that.
>
> That code will not catch the case when the floating point
> value has already been stringified.
>
> What is weird thought is that Perl would still stringify an
> NV of value 1.0 as "1" and not "1.0". So is it possible that
> the value already got round-tripped through Tcl?
|