Open XSven opened 1 year ago
Hmmm, interesting. StrMatch is supposed to be a child of Str, which does do a definedness check. It looks like StrMatch's inlining code is not being strict as its parent type, so isn't checking definedness. That's definitely a bug.
A workaround would be something like:
ArrayRef[
( Defined ) & ( StrMatch[ qr/\A [0-9A-Z]{3} \z/x ] ),
1,
]
I'll get this fixed in 2.4.1 though.
I actually can't reproduce this error, as eval_closure
normally compiles code without use warnings
. However, I still think StrMatch
ought to be checking definedness, so I'll add that check.
Ah, I see. You're using Eval::Closure, which does switch on warnings. Eval::TypeTiny does not.
I have used Params::ValidationCompiler that depends ot Eval::Closure. Now I have switched to Type::Params. I don't understand your decision not to turn on warnings in Eval::TypeTiny. How should we have detected such an issue without warnings being raised?
These two lines are exactly equivalent in functionality:
!ref( $foo ) and $foo =~ m/.../
defined( $foo ) and !ref( $foo ) and $foo =~ m/.../
The only difference is that the first one will raise a warning if warnings are enabled and $foo
is undef. They'll always give exactly the same boolean result.
How should we have detected such an issue without warnings being raised?
Skipping defined( $foo )
is only an issue because warnings are being raised.
I have understood this before. I like warnings and I treat them as issues. This is a matter of taste of course. I am very much appreciating your effort. I have triggered an initiative in the company that I am working for to sponsor your work. Let's see. You may close this issue unless you need it to track the changes included in the next Type::Tiny release.
Oh yeah, in normal code, I'd keep the warnings on for sure and would check definedness. Inline-generated code, I tend to value performance over maintainability and readability though.
I'll keep the issue open until the next release. Just adds a bit of visibility in case somebody else tried to report the same issue. (Unlikely, but can happen.)
Type-Tiny: 2.002001
This
defines a KeyList type constraint that is applied to a list with 3 elements. The second element is undef. If I set the environment variable EVAL_CLOSURE_PRINT_SOURCE to true the output is
Can this warning
be avoided?