develooper Front page | perl.perl5.changes | Postings from January 2021

[Perl/perl5] 1da7e6: list assign in list context was over-optimising

From:
Leon Timmermans via perl5-changes
Date:
January 6, 2021 18:35
Subject:
[Perl/perl5] 1da7e6: list assign in list context was over-optimising
Message ID:
Perl/perl5/push/refs/heads/maint-5.32/65b6c7-9aff58@github.com
  Branch: refs/heads/maint-5.32
  Home:   https://github.com/Perl/perl5
  Commit: 1da7e62b5d41e8aff3a324906226a6b22ba7fce9
      https://github.com/Perl/perl5/commit/1da7e62b5d41e8aff3a324906226a6b22ba7fce9
  Author: David Mitchell <davem@iabyn.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M op.c
    M t/op/aassign.t

  Log Message:
  -----------
  list assign in list context was over-optimising

GH #17816

This code:

    my $x = 1;
    print (($x, undef) = (2 => $x));

was printing "22" when it should have been printing "21".
An optimisation skips the 'common values on both sides' test
when the LHS of an assign only contains a single var; as the example
above shows, this is not sufficient.

This was broken by v5.23.1-202-g808ce55782

This commit fixes it by counting undef's on the LHS towards the var
count if they don't appear first.

(cherry picked from commit 5b354d2a8a6fea46c62048464c6722560cb1c907)


  Commit: b802abc5f61d1342b480ab2dcad2eb9f8d28ca43
      https://github.com/Perl/perl5/commit/b802abc5f61d1342b480ab2dcad2eb9f8d28ca43
  Author: David Mitchell <davem@iabyn.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M pp_hot.c
    M t/op/aassign.t

  Log Message:
  -----------
  list assign in list context: honour LHS undef

GH #16685

In

    @a = ($x, undef, undef) = (1))

@a should have 3 elements. v5.25.6-79-gb09ed995ad broke this and was
returning one element.

The fix is simple: that previous commit made it so that elements were
pushed back onto the stack only if they weren't immortal, so
&PL_sv_undef was getting skipped. Make it so they always are.

(cherry picked from commit 282d9dfeb4cea3c2d0335ba78faa3a9db931f1ec)


  Commit: 6e48dfa8fc63a182a49aa7d935956f6d77d00e6b
      https://github.com/Perl/perl5/commit/6e48dfa8fc63a182a49aa7d935956f6d77d00e6b
  Author: Nicolas R <atoomic@cpan.org>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M pp_ctl.c
    M t/op/die_unwind.t

  Log Message:
  -----------
  die_unwind(): global destruction

Fix #18063

During global destruction make sure we preserve
the string by using mortalcopy.

This is an update on 8c86f0238ecb5f32c2e7fba36e3edfdb54069068
change which avoided sv_mortalcopy in favor of sv_2mortal.

(cherry picked from commit 042abef72d40ab7ff39127e2afae6e34dfc66404)


  Commit: d2f68b387a1247703a3be515c67907131c97b6b5
      https://github.com/Perl/perl5/commit/d2f68b387a1247703a3be515c67907131c97b6b5
  Author: Tony Cook <tony@develop-help.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M t/test.pl

  Log Message:
  -----------
  run_multiple_progs: allow fatal to be turned off too

in some cases we want to group a test that shouldn't croak with the
croak tests, in particular to catch regressions when we've
introduced a croak.

(cherry picked from commit dd4888cbd881ebd071701fbfef45812a8773a404)


  Commit: 7925f8dfc09ddebcbfa214fdcd854c52090586f9
      https://github.com/Perl/perl5/commit/7925f8dfc09ddebcbfa214fdcd854c52090586f9
  Author: Tony Cook <tony@develop-help.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M t/test.pl

  Log Message:
  -----------
  run_multiple_progs: allow the EXPECT to contain only OPTIONS

(cherry picked from commit a2f2a4e3143a7f85d874450cced74b7399fd6977)


  Commit: 536520b4a24d012a8aa0690f044f651300258171
      https://github.com/Perl/perl5/commit/536520b4a24d012a8aa0690f044f651300258171
  Author: Tony Cook <tony@develop-help.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M regcomp.c
    M t/lib/croak/regcomp

  Log Message:
  -----------
  don't croak when the \K follows the lookaround assertion

this also simplifies the flagging for these assertions, since this
error is now the only thing using in_lookhead and in_lookbehind they
can be combined into a single in_lookaround.

Rather than conditional increment/decrement as we recurse into S_reg
I simply save the value of in_lookaround and restore it before
returning.  Some unsuccessful or restart paths don't do the restore,
but they either result in a croak(), or a restart which reinitialises
in_lookaround anyway.

Also added tests to ensure that all the different zero-width assertions
with content trigger the error.

(cherry picked from commit 80f44cf4982e395989f886220e05dd2071bb205a)


  Commit: 57edf1d256c8267868c4c9c44962dd4721d8c2b5
      https://github.com/Perl/perl5/commit/57edf1d256c8267868c4c9c44962dd4721d8c2b5
  Author: Tony Cook <tony@develop-help.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M t/lib/croak/regcomp

  Log Message:
  -----------
  some extra tests as suggested by hvds

(cherry picked from commit 3c43dd64639f7fbccb6ff32f0e82d007d2cde710)


  Commit: b620a9f2859aa21d56e1b18ce0c9d3752abaadb0
      https://github.com/Perl/perl5/commit/b620a9f2859aa21d56e1b18ce0c9d3752abaadb0
  Author: Tony Cook <tony@develop-help.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M pod/perldiag.pod

  Log Message:
  -----------
  \K in lookaround might become permitted in the future

It was disallowed because:

- it was breaking things (GH #14638)

- at the time, no-one had the tuits and knowledge to select non-buggy
  semantics and implement them.

(cherry picked from commit 55afc78396d86da97ab07c25295b00c9a300f081)


  Commit: 95369ab82a0e3669e1631262db9025407341acac
      https://github.com/Perl/perl5/commit/95369ab82a0e3669e1631262db9025407341acac
  Author: Tony Cook <tony@develop-help.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M pod/perldiag.pod

  Log Message:
  -----------
  fix a typo

(cherry picked from commit 64a5950af609117d2098f7616334aff77df9ed63)


  Commit: 4493dfd4aef2b89c0516020ea0914ae02dfff863
      https://github.com/Perl/perl5/commit/4493dfd4aef2b89c0516020ea0914ae02dfff863
  Author: Leon Timmermans <fawaka@gmail.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M ext/DynaLoader/DynaLoader_pm.PL

  Log Message:
  -----------
  Make DynaLoader on MacOS check library existence with dlopen

A number of system libraries no longer exist as actual files, even
though dlopen will pretend they do, so now we fall back to dlopen if
a library file can not be found.

(cherry picked from commit d296ead16762852ec34d173616a271c856711f77)

(with a manual tweak to the $VERSION since maint is behind blead)


  Commit: 9aff587fd2011ad85668efc30ed29e794fdb484e
      https://github.com/Perl/perl5/commit/9aff587fd2011ad85668efc30ed29e794fdb484e
  Author: Leon Timmermans <fawaka@gmail.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M ext/POSIX/t/time.t

  Log Message:
  -----------
  Correctly set LC_CTYPE back in POSIX/t/time.t

(cherry picked from commit 1cd5f0d5fa70621757c327e1f6ff04bcb220e0a1)


Compare: https://github.com/Perl/perl5/compare/65b6c72dc5b1...9aff587fd201



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About