Skip to content

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

@eldering

Description

@eldering

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions