Hello guys,

I think that new code in trunk/lib/Template/Plugin/Scalar.pm, rev 1201
is not correct:

       98       my $method;
       99      if (Scalar::Util::blessed($this)) {
       100     # lookup the method...
       101     $method = $this->can($item);
       102     }
       103     else {
       104     die $EXCEPTION->new( scalar => "invalid object method: $item" );
       105     }
       106

In theory, at line 101 this code: "$this->can($item)" could return undef, isn't?
And so, I think this should be written like this:

my $method;
# lookup the method...
(Scalar::Util::blessed($this) && $method = $this->can($item))
  || die $EXCEPTION->new( scalar => "invalid object method: $item" );

PS: I didn't run test suite, but I'm sure that this change will not
break anything.

Thanks for attention.


2009/5/12 Slaven Rezic <[email protected]>:
> Clinton Gormley wrote:
>> On Tue, 2009-05-12 at 12:47 +0100, Andy Wardley wrote:
>>
>>> On 12/5/09 12:27, Chisel Wright wrote:
>>>
>>>> They did all pass:
>>>>
>>> Fair enough, patch applied.
>>>
>>>    http://template-toolkit.org/svnweb/Template2/revision/?rev=1201
>>>
>>> Thanks Chisel.  That'll get the UNIVERSAL::can() crowd off my back :-)
>>>
>>
>> Hmm, the patch uses Scalar::Util, which pretty much rules out using TT
>> on Windows (not that I do):
>>
>> http://matrix.cpantesters.org/?dist=Scalar-List-Utils+1.19
>> http://matrix.cpantesters.org/?dist=Template-Toolkit+2.20
>>
>>
>>
> Scalar::Util is already in a Perl core module since 5.7.3. But as TT
> should also run on 5.6.x, it should list Scalar::Util in PREREQ_PM.
>
> Regards,
>    Slaven
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>

-- 
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to