Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strange lack of warnings #51

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

strange lack of warnings #51

forwardever opened this issue Nov 26, 2011 · 5 comments

Comments

@forwardever
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
Contributor

@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
Projects
None yet
Development

No branches or pull requests

3 participants