strange lack of warnings #51

Open
forwardever opened this Issue Nov 26, 2011 · 5 comments

Projects

None yet

3 participants

@forwardever

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
Member
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?

@forwardever

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
Member
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.

@forwardever

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 :)

@lestrrat
Member

@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