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

Str ~~ Range(with Str end points) gives wrong results #6137

Open
p6rt opened this issue Mar 8, 2017 · 3 comments
Open

Str ~~ Range(with Str end points) gives wrong results #6137

p6rt opened this issue Mar 8, 2017 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 8, 2017

Migrated from rt.perl.org#130959 (status was 'open')

Searchable as RT130959$

@p6rt
Copy link
Author

p6rt commented Mar 8, 2017

From @zoffixznet

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.

@p6rt
Copy link
Author

p6rt commented Mar 8, 2017

From @lizmat

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-archive.perl.org/perl6/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.

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.

@p6rt
Copy link
Author

p6rt commented Mar 8, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant