Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Simple CPAN distribution.

Report information
The Basics
Id: 122528
Status: open
Priority: 0/
Queue: Test-Simple

People
Owner: Nobody in particular
Requestors: zefram [...] fysh.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: constant sub construction on 5.19
Date: Tue, 18 Jul 2017 08:21:52 +0100
To: bug-Test-Simple [...] rt.cpan.org
From: Zefram <zefram [...] fysh.org>
A small part of Test-Simple fails on Perl 5.19.<3-11> because of changes in how constant subs are managed. The attached patch fixes it. It would be nice to have Test-Simple working on these older versions to enable testing of other modules that run into issues dependent on Perl version. The problem that arises is that Test2::Util::HashBase wants to construct subs that will be constant-foldable, but the way to do that changed. Prior to 5.19.3, "sub(){$val}" was sufficient. Perl 5.19.3 stopped that working, for the excellent reason that the $val variable can potentially still be mutated, so the old optimisation was actually breaking the closure abstraction. Perl 5.20.0 restored the old behaviour, for the good but disheartening reason that that behaviour was documented, so it shouldn't be changed without a deprecation cycle. We can anticipate that this will change again in some future Perl version. The patch that I have supplied keeps the module using the old mechanism on all the unaffected Perl versions, where the module already works. On 5.19.<3-11> it switches to a clunkier method that leaves the actual sub construction to the "constant" pragma, which can be trusted to know how to do it properly. -zefram

Message body is not shown because sender requested not to inline it.

Thank you for the patch! I will make sure this change makes it in before the next stable release. I am in the middle of a release-cycle currently, but also very short on time, I expect a week or so before I get to this.
Note for anyone else on Test-Simple who beats me to this: Test2::HashBase is generated by Object::Hashbase. Object::HashBase should be updated, and then Test2::HashBase should be regenerated from that update.