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.Int inconsistent about spaces on empty string #5419

Closed
p6rt opened this issue Jul 5, 2016 · 6 comments
Closed

Str.Int inconsistent about spaces on empty string #5419

p6rt opened this issue Jul 5, 2016 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 5, 2016

Migrated from rt.perl.org#128543 (status was 'resolved')

Searchable as RT128543$

@p6rt
Copy link
Author

p6rt commented Jul 5, 2016

From zefram@fysh.org

Is it permitted to have no digits at all when coercing a Str to Int?
The behaviour is inconsistent​:

"".Int
0
" ".Int
Cannot coerce NaN to an Int
  in block <unit> at <unknown file> line 1

Observing that spaces are permitted when there are digits, it would
seem that for consistency spaces should also make no difference to the
treatment of an otherwise-empty string.

-zefram

@p6rt
Copy link
Author

p6rt commented Jul 13, 2016

From @zoffixznet

Thanks for the report.

This was fixed [accidentally] in rakudo/rakudo@e28305c

Tests added in Raku/roast@c10df8395e

@p6rt
Copy link
Author

p6rt commented Jul 13, 2016

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

@p6rt
Copy link
Author

p6rt commented Jul 13, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 13, 2016
@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @LLFourn

I think this is to be consistent with p5.
perl -E 'say "" + 1' #-> 1

I'm not really making an argument it should be this way. But that's
probably the reason.

On Wed, Jul 6, 2016 at 2​:13 AM Zefram <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Zefram
# Please include the string​: [perl #​128543]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=128543 >

Is it permitted to have no digits at all when coercing a Str to Int?
The behaviour is inconsistent​:

"".Int
0
" ".Int
Cannot coerce NaN to an Int
in block <unit> at <unknown file> line 1

Observing that spaces are permitted when there are digits, it would
seem that for consistency spaces should also make no difference to the
treatment of an otherwise-empty string.

-zefram

@p6rt
Copy link
Author

p6rt commented Jul 28, 2016

From @LLFourn

err now that I actually check with warnings it seems I'm wrong and "" " "
both give the same warning.

perl -E 'use warnings; use strict; say 1 + ""'
Argument "" isn't numeric in addition (+) at -e line 1.
1
perl -E 'use warnings; use strict; say 1 + " "'
Argument " " isn't numeric in addition (+) at -e line 1.
1

me bad.

On Wed, Jul 6, 2016 at 2​:22 AM Lloyd Fournier <lloyd.fourn@​gmail.com> wrote​:

I think this is to be consistent with p5.
perl -E 'say "" + 1' #-> 1

I'm not really making an argument it should be this way. But that's
probably the reason.

On Wed, Jul 6, 2016 at 2​:13 AM Zefram <perl6-bugs-followup@​perl.org>
wrote​:

# New Ticket Created by Zefram
# Please include the string​: [perl #​128543]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=128543 >

Is it permitted to have no digits at all when coercing a Str to Int?
The behaviour is inconsistent​:

"".Int
0
" ".Int
Cannot coerce NaN to an Int
in block <unit> at <unknown file> line 1

Observing that spaces are permitted when there are digits, it would
seem that for consistency spaces should also make no difference to the
treatment of an otherwise-empty string.

-zefram

@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