Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 99312
Status: resolved
Priority: 0/
Queue: Type-Tiny

Owner: Nobody in particular
Requestors: mt1957 [...]

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

Subject: inline_check code generation flaw/bug
Date: Sun, 05 Oct 2014 12:05:20 +0200
To: bug-Type-Tiny [...]
From: mt1957 <mt1957 [...]>
Download (untitled) / with headers
text/plain 1.2k
Hi Toby, Reading your blog 'Type::Tiny Tricks #4 Inlined Type Constraints' I've seen a small bug in your generated code from *$type->inline_check()*, where $type is from ArrayRef[Int], which I have tested to see if it wasn't a writing error. This bug does not give a wrong result but it takes more time than needed. Code run; * **use Modern::Perl;** **use Types::Standard -types;** ** **my $type = ArrayRef[Int];** **say $type->inline_check('$X');** * Generated code (beautified); *do ** **{ ref($X) eq 'ARRAY'** ** and do** ** { my $ok = 1;** ** for my $i (@{$X})** ** { $ok = 0 && last** ** unless (defined $i and $i =~ /\A-?[0-9]+\z/);** ** };** ** $ok** ** }** **}** ** *The problem lies in '*$ok = 0 && last*'. The *and* operator will never let *last* do its job because the result is already false hence let the whole array be tested even when a wrong entry is already found. A better solution would be '*($ok=0,last)*'. Saves an operation too I might add :-). Detail info; Package: Type-Tiny-1.000004 Perl: perl5 (revision 5 version 16 subversion 3) Os: Linux h03-fedora 3.14.17-100.fc19.x86_64 #1 SMP Thu Aug 14 17:17:26 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Greetings Marcel
Download (untitled) / with headers
text/plain 125b
Thanks. I'll get this fixed in a few days. I'm surprised I hadn't noticed this. Many of my benchmarks involve ArrayRef[Int].
Accidentally marked as resolved. Re-opening!
Fixed in 1.000005.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to