Git Product home page Git Product logo

Comments (7)

tobyink avatar tobyink commented on July 23, 2024

From [email protected] on 2020-12-13 04:27:25
:

On Wed Dec 09 23:36:18 2020, JWRIGHT wrote:

This code
use Types::Standard -types; use strict; use warnings; use Type::Utils
-all;
#use re 'debug'; local $Type::Tiny::AvoidCallbacks = 0; my $Distance =
declare
"Distance" => as StrMatch[ qr{^([0-9]+)\s*(mm|cm|m|km)$} ]; my $x =
"5ym"; my
$y = $Distance->($x);
throws (and warns) the following:
Cannot serialize regexp without callbacks; serializing using callbacks
at
/home/perl/perl5/perlbrew/perls/perl-
5.8.9/lib/site_perl/5.8.9/Type/Tiny.pm
line 853 Value "5ym" did not pass type constraint "Distance" at
./test-1.pl
line 13 "Distance" is a subtype of
"StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]" Value "5ym" did not
pass type
constraint "StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]"
"StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]" is defined as: do {
package
Type::Tiny; !ref($) and $ =~
$Types::Standard::StrMatch::expressions{"Regexp|(?-xism:^([0-
9]+)\s*(mm|cm|m|km)$)"}
}
on Perl 5.8.9 and 5.30.2 with or without Type::Tiny::XS installed,
with or
without AvoidCallbacks set
with AvoidCallbacks set to 1, this code throws the warning twice.

the warning is not thrown for ->check or ->validate, but it does appear on
calls to ->validate_explain.
The Type-Tiny pod does claim
"(StrMatch is sometimes unable to, and will issue a warning if it needs to rely
on callbacks when asked not to.)" but in this case, it isn't being asked to not
rely on callbacks

from p5-type-tiny.

tobyink avatar tobyink commented on July 23, 2024

From [email protected] on 2020-12-13 04:37:42
:

On Wed Dec 09 23:36:18 2020, JWRIGHT wrote:

This code
use Types::Standard -types; use strict; use warnings; use Type::Utils
-all;
#use re 'debug'; local $Type::Tiny::AvoidCallbacks = 0; my $Distance =
declare
"Distance" => as StrMatch[ qr{^([0-9]+)\s*(mm|cm|m|km)$} ]; my $x =
"5ym"; my
$y = $Distance->($x);
throws (and warns) the following:
Cannot serialize regexp without callbacks; serializing using callbacks
at
/home/perl/perl5/perlbrew/perls/perl-
5.8.9/lib/site_perl/5.8.9/Type/Tiny.pm
line 853 Value "5ym" did not pass type constraint "Distance" at
./test-1.pl
line 13 "Distance" is a subtype of
"StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]" Value "5ym" did not
pass type
constraint "StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]"
"StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]" is defined as: do {
package
Type::Tiny; !ref($) and $ =~
$Types::Standard::StrMatch::expressions{"Regexp|(?-xism:^([0-
9]+)\s*(mm|cm|m|km)$)"}
}
on Perl 5.8.9 and 5.30.2 with or without Type::Tiny::XS installed,
with or
without AvoidCallbacks set

from p5-type-tiny.

tobyink avatar tobyink commented on July 23, 2024

From [email protected] on 2020-12-13 04:38:04
:

On Wed Dec 09 23:36:18 2020, JWRIGHT wrote:

This code
use Types::Standard -types; use strict; use warnings; use Type::Utils
-all;
#use re 'debug'; local $Type::Tiny::AvoidCallbacks = 0; my $Distance =
declare
"Distance" => as StrMatch[ qr{^([0-9]+)\s*(mm|cm|m|km)$} ]; my $x =
"5ym"; my
$y = $Distance->($x);
throws (and warns) the following:
Cannot serialize regexp without callbacks; serializing using callbacks
at
/home/perl/perl5/perlbrew/perls/perl-
5.8.9/lib/site_perl/5.8.9/Type/Tiny.pm
line 853 Value "5ym" did not pass type constraint "Distance" at
./test-1.pl
line 13 "Distance" is a subtype of
"StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]" Value "5ym" did not
pass type
constraint "StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]"
"StrMatch[(?-xism:^([0-9]+)\s*(mm|cm|m|km)$)]" is defined as: do {
package
Type::Tiny; !ref($) and $ =~
$Types::Standard::StrMatch::expressions{"Regexp|(?-xism:^([0-
9]+)\s*(mm|cm|m|km)$)"}
}
on Perl 5.8.9 and 5.30.2 with or without Type::Tiny::XS installed,
with or
without AvoidCallbacks set

from p5-type-tiny.

abeltje avatar abeltje commented on July 23, 2024

Hi,

It looks like this hasn't gone away in version 1.012004. I get cpan-testers reports with this problem.
I cannot reproduce on my systems (MacOs, Ubuntu, Win10) and don't know where to start investigating...

Thanks in advance,
-- Abe.

from p5-type-tiny.

abeltje avatar abeltje commented on July 23, 2024

Hi,

It looks like this hasn't gone away in version 1.012004. I get cpan-testers reports with this problem. I cannot reproduce on my systems (MacOs, Ubuntu, Win10) and don't know where to start investigating...

Thanks in advance, -- Abe.

As it turns out, installing Regexp::Util removes this warning (from my test suite at least). Maybe add a hint in the documentation for this...

Good luck,
-- Abe.

from p5-type-tiny.

tobyink avatar tobyink commented on July 23, 2024

validate_explain deliberately sets $AvoidCallbacks = 1.

It might be worth having validate_explain also catch $SIG{__WARN__}.

from p5-type-tiny.

tobyink avatar tobyink commented on July 23, 2024

805c98d

from p5-type-tiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.