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

Nil.chrs complains about the use of Nil in numeric context, but isn't it a string context? (Nil.chrs) #5845

Closed
p6rt opened this issue Dec 1, 2016 · 5 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Dec 1, 2016

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

Searchable as RT130231$

@p6rt
Copy link
Author

p6rt commented Dec 1, 2016

From @AlexDaniel

Code​:
Nil.chrs

Result​:
Use of Nil in numeric context
  in block <unit> at -e line 1

At the same time​:

Code​:
Nil.ords

Result​:
Use of Nil in string context
  in block <unit> at -e line 1

I think that both should say that it is in string context.

@p6rt
Copy link
Author

p6rt commented Dec 2, 2016

From @coke

On Thu, 01 Dec 2016 15​:11​:31 -0800, alex.jakimenko@​gmail.com wrote​:

Code​:
Nil.chrs

Result​:
Use of Nil in numeric context
in block <unit> at -e line 1

At the same time​:

Code​:
Nil.ords

Result​:
Use of Nil in string context
in block <unit> at -e line 1

I think that both should say that it is in string context.

chrs takes an array of Ints and returns a Str; it's trying to use Nil in a numeric context to get a number to work with.

ords takes a Str and returns an array of ints - it's trying to use Nil in a string context to get character to work with.

Seems fine. Rejecting ticket.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Dec 2, 2016

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

@p6rt
Copy link
Author

p6rt commented Dec 2, 2016

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

@p6rt p6rt closed this as completed Dec 2, 2016
@p6rt
Copy link
Author

p6rt commented Dec 2, 2016

From @zoffixznet

On Thu, 01 Dec 2016 15​:11​:31 -0800, alex.jakimenko@​gmail.com wrote​:

Code​:
Nil.chrs

Result​:
Use of Nil in numeric context
in block <unit> at -e line 1

At the same time​:

Code​:
Nil.ords

Result​:
Use of Nil in string context
in block <unit> at -e line 1

I think that both should say that it is in string context.

.chrs takes a list of numbers. The Nil is used in numeric context, resulting in a 0, which after being .chr'ed results in a null string​:

m​: quietly say Nil.chrs eq "\x[0]"; # True
rakudo-moar abc643​: OUTPUT«True␤»

The warning is accurate.

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant