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

Make lone No category type characters in Str convert to Int properly #5226

Closed
p6rt opened this issue Apr 9, 2016 · 6 comments
Closed

Make lone No category type characters in Str convert to Int properly #5226

p6rt opened this issue Apr 9, 2016 · 6 comments
Labels
RFC Request For Comments testneeded

Comments

@p6rt
Copy link

p6rt commented Apr 9, 2016

Migrated from rt.perl.org#127866 (status was 'rejected')

Searchable as RT127866$

@p6rt
Copy link
Author

p6rt commented Apr 9, 2016

From @zoffixznet

There are numerous No characters that may be entered, say, by a user being asked for numeric input​: http://www.fileformat.info/info/unicode/category/No/list.htm

However, Rakudo will fail to convert it into an Int, due to it not being a digit​:

<ZoffixWin> m​: say '௰'.Int
<camelia> rakudo-moar 40a953​: OUTPUT«Cannot convert string to number​: base-10 number must begin with valid digits or '.' in '⏏௰' (indicated by ⏏)␤ in block <unit> at /tmp/VabvZF4PiK line 1␤␤Actually thrown at​:␤ in block <unit> at /tmp/VabvZF4PiK line 1␤␤»

I think from the programmer's point of view, it should be expected that the conversion should succeed, where it makes sense. Since the same character can be used bare and work​:

<ZoffixWin> m​: say ௰
<camelia> rakudo-moar 40a953​: OUTPUT«10␤»

@p6rt
Copy link
Author

p6rt commented Apr 9, 2016

From @lizmat

Fixed with 1cb2e8d9e71797f576b3

On 09 Apr 2016, at 20​:32, Zoffix Znet (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

There are numerous No characters that may be entered, say, by a user being asked for numeric input​: http://www.fileformat.info/info/unicode/category/No/list.htm

However, Rakudo will fail to convert it into an Int, due to it not being a digit​:

<ZoffixWin> m​: say '௰'.Int
<camelia> rakudo-moar 40a953​: OUTPUT«Cannot convert string to number​: base-10 number must begin with valid digits or '.' in '⏏௰' (indicated by ⏏)␤ in block <unit> at /tmp/VabvZF4PiK line 1␤␤Actually thrown at​:␤ in block <unit> at /tmp/VabvZF4PiK line 1␤␤»

I think from the programmer's point of view, it should be expected that the conversion should succeed, where it makes sense. Since the same character can be used bare and work​:

<ZoffixWin> m​: say ௰
<camelia> rakudo-moar 40a953​: OUTPUT«10␤»

@p6rt
Copy link
Author

p6rt commented Apr 9, 2016

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

@p6rt
Copy link
Author

p6rt commented Jul 4, 2016

From @zoffixznet

Thanks.

I noticed this didn't make things like '௰' + 10 work and went to fix it and noticed val() too did not handle "No" chars.

And then TimToady ruled that val()/Str.Int/Str.Numeric should NOT handle No chars. If the programmer really needs such a feature, they should explicitly be using unival().

Relevant IRC conversation​: http://irclog.perlgeek.de/perl6/2016-07-04#i_12782986

PR to undo the handling of No chars in Str.Int​: rakudo/rakudo#808

And for the aforementioned reasons this ticket is rejected.

@p6rt
Copy link
Author

p6rt commented Jul 4, 2016

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

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

p6rt commented Jul 7, 2016

From @zoffixznet

Tests added in Raku/roast@6c01b3fdbf

@p6rt p6rt added RFC Request For Comments testneeded labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request For Comments testneeded
Projects
None yet
Development

No branches or pull requests

1 participant