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

QuoteLike::Words->literal returns wrong results after contents change #296

Open
eldering opened this issue Mar 3, 2024 · 0 comments
Open

Comments

@eldering
Copy link

eldering commented Mar 3, 2024

After changing the contents of a PPI::Token::QuoteLike::Words element with the set_contents method, it seems that the changed contents is not reparsed and internal meta-data not updated. This leads to a call to literal returning wrong results.

The below MWE program

#!/usr/bin/env perl

use v5.24;
use strict;
use warnings;
use Data::Dumper;

use PPI;

my $doc = PPI::Document->new(\q!my @a = qw( 1 2 3);!);

my $qw = $doc->find_first('PPI::Token::QuoteLike::Words');

print Dumper([ $qw->literal ], $qw);

$qw->set_content($qw->content =~ s/ 2//r);

print Dumper([ $qw->literal ], $qw);

first returns the tokens 1,2,3 as expected, but the second time returns 1 and 3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant