strange lack of warnings #51

forwardever opened this Issue Nov 26, 2011 · 5 comments


None yet

3 participants


the following code does not provide any warnings -> method call on undef value

is this expected behaviour?

use Text::Xslate;

my $tx = Text::Xslate->new();

my %vars = (
    title => 'A list of books',
    oo    => undef

# for strings
my $template = q{
    <: $title :>
    <: $oo.unknown_method :>


print $tx->render_string($template, \%vars);
gfx commented Nov 27, 2011

Yes, any operation on nil(undef) says nothing by default while <: $title.unknown_method :> complains warnings.

You can change this behavior by setting Text::Xslate->new( verbose => 2 ).

Should verbose => be set by default? What do you think of it?


both type of warnings "Use of nil to print" and "Use of nil to invoke method foo" will be raised using verbose => 2

but while "Use of nil to print" is pretty common (I don't want to initialize all my values $value //= ""), calling methods on undef values just seem wrong and much less common

so both type of warnings might be activated on different levels?
"Use of nil to print" => verbose 2
"Use of nil to invoke method foo" => verbose 1

gfx commented Nov 28, 2011

Sure. I will change the level of two warning types as:

  • default verbose level to 2
  • "Use of nil to print" to level 3
  • Some of warnings on nil to level 3

Thanks to the suggestion.


thanks, hope this helps to make debugging a bit easier (as the old behavior produced some hard to find bugs at least in my use cases :)


@gfx "Sure. I will change the level of two warning types as:"

Has it been changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment