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

Allow UInt to return a failure from Int #3289

Closed
wants to merge 1 commit into from

Conversation

m-dango
Copy link
Contributor

@m-dango m-dango commented Nov 7, 2019

Int can give a failure for e.g. X::Str::Numeric, which results in an exception when used with < 0. This is to check that $got actually contains an Int before checking that it is not negative.

@lizmat
Copy link
Contributor

lizmat commented Nov 8, 2019

I'm still not sure I understand what problem this is fixing? Could you provide some example code, that could be used in a test?

@vrurg
Copy link
Member

vrurg commented Nov 8, 2019

@lizmat I think it's the following case:

say "a".Int.WHAT; # Failure
say "a".UInt.WHAT; # Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏aaa' (indicated by ⏏)

The patch bypasses the Failure to the caller transparently, as I'd expect it.

@m-dango
Copy link
Contributor Author

m-dango commented Nov 8, 2019

Thank you @vrurg, that is indeed the issue being addressed.

lizmat added a commit that referenced this pull request Nov 8, 2019
Inspired by Daniel Mita++ in PR in #3289.

The original Failure of not being able to convert "a" to a number, is now
returned, rather than being thrown by the check whether the value is negative.
@lizmat
Copy link
Contributor

lizmat commented Nov 8, 2019

@mienaikage: thank you for this Pull Request. I've taken the liberty to address the problem in another way in 8f30cc7 . Please do keep those PR's coming!

Related: it would be very nice if you could create a PR to test the fix!

@lizmat lizmat closed this Nov 8, 2019
vrurg pushed a commit to vrurg/rakudo that referenced this pull request Nov 23, 2019
Inspired by Daniel Mita++ in PR in rakudo#3289.

The original Failure of not being able to convert "a" to a number, is now
returned, rather than being thrown by the check whether the value is negative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants