Skip Menu |
Report information
Id: 130959
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Str ~~ Range(with Str end points) gives wrong results
The smartmatch needs to give True, as the element is present in that range: 20:18 IOninja m: say "1117-11" ~~ "1126-12" .. "2017-11" 20:18 camelia rakudo-moar 3046d5: OUTPUT: «False␤» 20:18 IOninja m: say "1117-11" ∈ "1126-12" .. "2017-11" 20:18 camelia rakudo-moar 3046d5: OUTPUT: «True␤» The issue is that `before`/`after` comparators are used and the comparison gives False, because "1117-11" *is* before "1126-12" and supposedly out of range. 20:19 s: "1126-12" .. "2017-11", 'ACCEPTS', \("1117-11") 20:19 SourceBaby IOninja, Sauce is at https://github.com/rakudo/rakudo/b​lob/3046d57/src/core/Range.pm#L419 20:21 IOninja m: dd [ (not "1117-11" before "1126-12"), (not "1117-11" after "2017-11") ] 20:21 camelia rakudo-moar 3046d5: OUTPUT: «[Bool::False, Bool::True]␤» P.S.: Range looks like it's itching to split into Int, Numeric, and Str subclasses (with Ranged role tying them up or something). P.P.S.: confusion with string Ranges is common, perhaps the weird stuff should be left to the sequence op, with Range doing something very simple.
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Subject: Re: [perl #130959] [BUG] Str ~~ Range(with Str end points) gives wrong results
To: "Zoffix Znet (via RT)" <perl6-bugs-followup [...] perl.org>
Date: Wed, 8 Mar 2017 22:26:20 +0100
Download (untitled) / with headers
text/plain 1.5k
Show quoted text
> On 8 Mar 2017, at 21:29, Zoffix Znet (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Zoffix Znet > # Please include the string: [perl #130959] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=130959 > > > > The smartmatch needs to give True, as the element is present in that range: > > 20:18 IOninja m: say "1117-11" ~~ "1126-12" .. "2017-11" > 20:18 camelia rakudo-moar 3046d5: OUTPUT: «False␤» > 20:18 IOninja m: say "1117-11" ∈ "1126-12" .. "2017-11" > 20:18 camelia rakudo-moar 3046d5: OUTPUT: «True␤» > > The issue is that `before`/`after` comparators are used and the comparison gives False, because > "1117-11" *is* before "1126-12" and supposedly out of range. > > 20:19 s: "1126-12" .. "2017-11", 'ACCEPTS', \("1117-11") > 20:19 SourceBaby IOninja, Sauce is at https://github.com/rakudo/rakudo/b​lob/3046d57/src/core/Range.pm#L419 > 20:21 IOninja m: dd [ (not "1117-11" before "1126-12"), (not "1117-11" after "2017-11") ] > 20:21 camelia rakudo-moar 3046d5: OUTPUT: «[Bool::False, Bool::True]␤» > > P.S.: Range looks like it's itching to split into Int, Numeric, and Str subclasses (with Ranged role tying them up or something).
FWIW, I’ve already tried the IntRange approach about 2 years ago. It was shot down then. Maybe things have changed. I certainly hope so. Show quoted text
> P.P.S.: confusion with string Ranges is common, perhaps the weird stuff should be left to the sequence op, > with Range doing something very simple.
Agree.


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

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org