-
Notifications
You must be signed in to change notification settings - Fork 56
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
Fix numeric == on room ver #1194
Conversation
Room versions are strings, so we should use string operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Was this implicitly parsing
$self->room_version
as an int before? - Is there a way to mark
$self->room_version
as a string so that== 1
throws up warnings? - Is there a reference for
==
versuseq
? I triedperldoc.perl.org
but wasn't especially illuminated.
Oh, I missed the "go here" on that linked page. https://perldoc.perl.org/perlop#Equality-Operators is useful. It describes |
(I'm assuming the test failure is a flake here?) |
Yeees. So, the problem is that perl doesn't really distinguish between ints and strings. (no, really). There are "strings that only contain digits", and "strings that contain things other than digits". (There's some optimisation under the hood to make that less horrifically inefficient than it sounds, but the visible effects are the same). So, And yes, this is hands-down the most horrifying part of a generally horrifying language.
Sadly no, I'm not aware of anything like type annotations for perl.
You found the main reference. A couple of examples of the differences:
|
In terms of comparing other things, you're really talking about casting those other things to numbers or strings, and then comparing the results. You can also force such a conversion by adding zero ( So...
TL;DR: there are a couple of cases where using |
I believe so. |
Room versions are strings, so we should use string operators.