Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quoted encoding for Enum[] in Type::Tiny via EnumQ[] #12

Merged
merged 1 commit into from
Aug 17, 2020

Conversation

aeruder
Copy link
Contributor

@aeruder aeruder commented Aug 11, 2020

This is a better fix for perl rt 129729 (we can actually XS-ify this
sub now) and fixes the bug in perl rt 133141 which is much harder to
work around. We define a new encoding for "Enum" in the form of EnumQ
which has QUOTELIKE strings as parameters. This lets us unambiguously
handle any content in strings.

By defining a new encoding we should remain compatible with older versions
of Type::Tiny and newer versions of Type::Tiny will continue to work
with older versions of Type::Tiny::XS (just won't be able to inline).

@aeruder
Copy link
Contributor Author

aeruder commented Aug 15, 2020

Most discussion happening over on tobyink/p5-type-tiny#59

t/12enumq.t Outdated

use_ok('Type::Tiny::XS');

my $check = Type::Tiny::XS::get_coderef_for('EnumQ["a b", "c, d", "-\""]');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Enum, not EnumQ, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I have now figured out distinkt-dist :). Tests are passing now.

This is a better fix for perl rt 129729 (we can actually XS-ify this
sub now) and fixes the bug in perl rt 133141 which is much harder to
work around.  We define a new encoding for "Enum" which has QUOTELIKE
strings as parameters.  This lets us unambiguously handle any content
in strings.  Otherwise we have some serious issues handling spaces and
have some other issues when Type::Parser tries to parse a Tuple[Enum[...]]

We'll have some slightly complicated checks in place for now:

old Type::Tiny, old Type::Tiny::XS - old encoding, blows up on spaces
old Type::Tiny, new Type::Tiny::XS - old encoding, blows up on spaces
new Type::Tiny, new Type::Tiny::XS - new encoding, maximum XS-ification
new Type::Tiny, old Type::Tiny::XS - old encoding, skip XS in some cases
@tobyink tobyink merged commit ebb6a4a into tobyink:master Aug 17, 2020
@tobyink
Copy link
Owner

tobyink commented Aug 18, 2020

Needed to make this change to avoid fails when Type::Parser isn't installed. (Because it should be possible to install Type::Tiny::XS without Type::Tiny, so that other type constraint libraries can potentially use Type::Tiny::XS.)

clrpackages pushed a commit to clearlinux-pkgs/perl-Type-Tiny that referenced this pull request Aug 27, 2020
… version 1.010004

1.010004	2020-08-18

 [ Bug Fixes ]
 - Fix XSifying Enum[] where the strings contain certain non-word
   characters.
   Andrew Ruder++
   <tobyink/p5-type-tiny-xs#12>
   <tobyink/p5-type-tiny#59>
 - Type::Params compile_named using both the head and named_to_list options
   would cause compilation error.
   Fixes RT#132419.
   Hauke D++
   Sandor Patocs++
   <https://rt.cpan.org/Ticket/Display.html?id=132419>
 - Workaround RT#121957 by avoiding attempting to XSify Enum type

(NEWS truncated at 15 lines)
clrpackages pushed a commit to clearlinux-pkgs/perl-Type-Tiny-XS that referenced this pull request Aug 27, 2020
… version 0.021

0.021	2020-08-18

 [ Bug Fixes ]
 - Fix Enum test case for when Type::Parser is not available.

0.020	2020-08-17

 - Allow Enum[] to take a list of quoted strings rather than just
   barewords.
   Andrew Ruder++
   <tobyink/p5-type-tiny-xs#12>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 7, 2020
1.010006	2020-09-04

 [ Bug Fixes ]
 - Eliminate recusion warnings when Type::Parser needs to parse complex
   types.
   Fixes RT#121957.
   Diab Jerius++
   <https://rt.cpan.org/Ticket/Display.html?id=121957>

 [ Other ]
 - Better handling of coercions for pre-declared types in Type::Library.
   The type objects created before the type was properly defined will now
   lazily attempt to find coercions from the properly defined type once it
   becomes available.

1.010005	2020-08-26

 - Improvements to $AvoidCallbacks support for
   Type::Tiny::{Class,Role,Duck,Enum,Union,Intersection}, and LaxNum, Ref,
   RegexpRef, FileHandle, Object, Overload, and Tied types from
   Types::Standard.

1.010004	2020-08-18

 [ Bug Fixes ]
 - Fix XSifying Enum[] where the strings contain certain non-word
   characters.
   Andrew Ruder++
   <tobyink/p5-type-tiny-xs#12>
   <tobyink/p5-type-tiny#59>
 - Type::Params compile_named using both the head and named_to_list options
   would cause compilation error.
   Fixes RT#132419.
   Hauke D++
   Sandor Patocs++
   <https://rt.cpan.org/Ticket/Display.html?id=132419>
 - Workaround RT#121957 by avoiding attempting to XSify Enum type
   constraints with more than 50 possible strings.
   Fixes RT#121957.
   Diab Jerius++
   <https://rt.cpan.org/Ticket/Display.html?id=121957>

 [ Documentation ]
 - Link to HTTPS version of Type::Tiny web page.

1.010003	2020-08-08	The Crazy 88

 [ Bug Fixes ]
 - ClassName type constraint should treat empty @isa as if no @isa were
   defined, like Type::Tiny::XS.
   Fixes RT#132583.
   Szymon Nieznański++
   <https://rt.cpan.org/Ticket/Display.html?id=132583>
 - Fix for Type::Tiny->can called as a class method.
   Meredith Howard++
   <tobyink/p5-type-tiny#57>
 - Fix predeclared types in Type::Library.
   Meredith Howard++
   <tobyink/p5-type-tiny#58>

 [ Documentation ]
 - Document some edge cases for Types::Standard Int.
   <https://rt.cpan.org/Ticket/Display.html?id=132754>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 7, 2020
0.021	2020-08-18

 [ Bug Fixes ]
 - Fix Enum test case for when Type::Parser is not available.

0.020	2020-08-17

 - Allow Enum[] to take a list of quoted strings rather than just
   barewords.
   Andrew Ruder++
   <tobyink/p5-type-tiny-xs#12>

0.019	2020-08-05

 [ Packaging ]
 - Remove some cruft that was accidentally packaged.

0.018	2020-08-05

 [ Test Suite ]
 - Tests for InstanceOf

 [ Other ]
 - Slight speed boost for InstanceOf in cases where the object being tested
   overrides UNIVERSAL::isa.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants