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

.Int-ing a non-numeric Str no longer throws, but returns a Failure instead (my $i = 'a'.Int) #5945

Closed
p6rt opened this issue Dec 30, 2016 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Dec 30, 2016

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

Searchable as RT130450$

@p6rt
Copy link
Author

p6rt commented Dec 30, 2016

From @AlexDaniel

Code​:
my $i = 'a'.Int

Result (2015.12, 2016.03)​:
Cannot convert string to number​: base-10 number must begin with valid digits or '.' in '⏏a' (indicated by ⏏)
  in block <unit> at /tmp/2R0qtbz9ME line 1

Actually thrown at​:
  in block <unit> at /tmp/2R0qtbz9ME line 1
«exit code = 1»

Result (HEAD)​:
(Failure)

So instead of throwing it just gives a Failure object.

Bisectable points to rakudo/rakudo@1cb2e8d

I find the current behavior a bit surprising, but feel free to argue with that.

@p6rt
Copy link
Author

p6rt commented Dec 30, 2016

From @lizmat

To me, that’s ENOTABUG, because that’s exactly what fail / Failure is supposed to do. Only when you actually *use* the value unprotected, will it throw.

# protected usage
$ 6 'my $i = "a".Int; say $i // 42’
42

# unprotected usage
$ 6 'my $i = "a".Int; say $i'
Cannot convert string to number​: base-10 number must begin with valid digits or '.' in '⏏a' (indicated by ⏏)

The commit fixes behaviour.

On 30 Dec 2016, at 02​:59, Aleks-Daniel Jakimenko-Aleksejev (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Code​:
my $i = 'a'.Int

Result (2015.12, 2016.03)​:
Cannot convert string to number​: base-10 number must begin with valid digits or '.' in '⏏a' (indicated by ⏏)
in block <unit> at /tmp/2R0qtbz9ME line 1

Actually thrown at​:
in block <unit> at /tmp/2R0qtbz9ME line 1
«exit code = 1»

Result (HEAD)​:
(Failure)

So instead of throwing it just gives a Failure object.

Bisectable points to rakudo/rakudo@1cb2e8d

I find the current behavior a bit surprising, but feel free to argue with that.

@p6rt
Copy link
Author

p6rt commented Dec 30, 2016

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

@p6rt
Copy link
Author

p6rt commented Dec 30, 2016

From @AlexDaniel

You are right. This is not a regression, but we still need some tests for this I think.

On 2016-12-30 02​:23​:30, elizabeth wrote​:

To me, that’s ENOTABUG, because that’s exactly what fail / Failure is
supposed to do. Only when you actually *use* the value unprotected,
will it throw.

# protected usage
$ 6 'my $i = "a".Int; say $i // 42’
42

# unprotected usage
$ 6 'my $i = "a".Int; say $i'
Cannot convert string to number​: base-10 number must begin with valid
digits or '.' in '⏏a' (indicated by ⏏)

The commit fixes behaviour.

On 30 Dec 2016, at 02​:59, Aleks-Daniel Jakimenko-Aleksejev (via RT)
<perl6-bugs-followup@​perl.org> wrote​:

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

Code​:
my $i = 'a'.Int

Result (2015.12, 2016.03)​:
Cannot convert string to number​: base-10 number must begin with valid
digits or '.' in '⏏a' (indicated by ⏏)
in block <unit> at /tmp/2R0qtbz9ME line 1

Actually thrown at​:
in block <unit> at /tmp/2R0qtbz9ME line 1
«exit code = 1»

Result (HEAD)​:
(Failure)

So instead of throwing it just gives a Failure object.

Bisectable points to
rakudo/rakudo@1cb2e8d

I find the current behavior a bit surprising, but feel free to argue
with that.

@p6rt
Copy link
Author

p6rt commented Dec 31, 2016

@p6rt
Copy link
Author

p6rt commented Dec 31, 2016

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

@p6rt p6rt closed this as completed Dec 31, 2016
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant