Fix PreInc/PreDec of NeverType#1641
Conversation
|
Or, other idea: maybe I should further debug why UPDATE: found it, it comes from |
|
Just guesswork: maybe you could use Line 87 in 32353a9 |
it would still stay being the NeverType, which makes sense. But this info is lost in |
|
Hmm did only see that one new pmmp error now. Coming from https://github.com/pmmp/PocketMine-MP/blob/e0b07ff3087b652407439a29c941f3b66ca92c86/src/pocketmine/utils/Utils.php#L480 I cannot comprehend this now, need to check it though |
|
The pmmp types before the loop did not change, also according to https://phpstan.org/r/a0ce70a0-43ad-4324-8113-4eda1914b536 the loop is basically dead if I read the types and ranges right. I think I didn't break anything related to this but rather unhid a pmmp error or a phpstan bug. I'm not entirely sure if this loop is dead code or not, but at least I can't also simply trigger it via e.g. https://3v4l.org/DaGfU |
|
//cc @dktapps |
|
I think you should add a explicit |
|
I've no idea how that code works. @SOF3 can you shed any light on this? |
|
jfyi it looks close to some other java string hash functions that can be found online, e.g. https://github.com/openjdk/jdk/blob/jdk-20+11/src/java.base/share/classes/java/lang/StringUTF16.java#L414 but with additional things going on :) |
|
Thank you! |
Thanks. Looks like some overengineering going on here, probably to prevent overflowing into a float. |
Found this while working on something else. The problem is that with the NeverType being the bottom type the next if block
elseif ($stringType->isSuperTypeOf($varType)->yes())would always evaluate to true leading to a string. That could still be improved by usingisString()instead, but then the code afterwards would create Plus or Minus expressions leading to e.g. float.While reading https://www.php.net/manual/en/language.operators.increment.php
I thought those expressions should only be created for numbers or null but I also don't like to use
instanceoffor that. Therefore I decided to check explicitly if it is a NeverType. Maybe, but I'm really not sure, the Type interface should have a couple more primitive type methods likeisInteger,isFloat,isNullor so to deal with this a bit different. Those would definitely benofor a NeverType then.