Skip to content

Modifying substr expressions evaluate incorrectly #69

Description

@johannes-riecken

I'm very fascinated by all the work that went into this project and I have written quite a bit of Perl code with few dependencies that I could use Perlito on.
One issue that I think might be easy to fix with much benefit, is that I often like using modifying substr expressions as it's often faster than regexes, but in the generated JS code, the string doesn't get modified.
Here are three ways to modify substrings.

my $s = 'hello';
# 0
substr $s, 0, 1, 'H';
# 1
substr($s, 0, 1) = 'G';
# 2
my $ref = \substr $s, 0, 1;
$$ref = 'F';

Running any of these followed by say $s; should result in a modified string. Running with Perlito5 gives a compiler error in case[1] and results in output of unmodified hello in the other cases.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions