Odin icon indicating copy to clipboard operation
Odin copied to clipboard

#4873 issue fixed

Open rezwanahmedsami opened this issue 10 months ago • 10 comments

Fixed: #4873

rezwanahmedsami avatar Feb 24 '25 18:02 rezwanahmedsami

This is not correct, == on strings does not just check the pointer, but also the content.

laytan avatar Feb 24 '25 20:02 laytan

This is not correct, == on strings does not just check the pointer, but also the content.

what you think ?

What will be the correct way?

rezwanahmedsami avatar Feb 25 '25 20:02 rezwanahmedsami

Also check the content?

laytan avatar Mar 13 '25 19:03 laytan

Or error in the frontend that this is not a valid thing

laytan avatar Mar 13 '25 19:03 laytan

Or error in the frontend that this is not a valid thing

If you can give me an explanation, what can be wrong?

Then it will be easy for me to catch it.

Because I stay busy with office work most of the time.

So I can't get much time to investigate it.

So, can you help me with that?

Just point out the right thing for me.

rezwanahmedsami avatar Mar 13 '25 22:03 rezwanahmedsami

I'm going to close this because I am not interested in holding your hand here

laytan avatar Mar 21 '25 22:03 laytan

This is not correct, == on strings does not just check the pointer, but also the content.

@laytan in this case a comparison is being made between an array and the nil value of an array (all zeroes) (lb_emit_comp_against_nil). Even though the array might store strings, we should still emit a memcmp 0 over the whole array right?

Could this be reopened if so?

FourteenBrush avatar Jul 19 '25 19:07 FourteenBrush

Ah you are right, my bad, I didn't clock that this was only for comparing against nil.

laytan avatar Jul 19 '25 20:07 laytan

One thing that would still be inconsistent here is that str == "" doesn't care about the pointer, just the length.

For example:

val := transmute(string)runtime.Raw_String{
	data = auto_cast uintptr(0xDEADBEEF),
	len  = 0,
}
assert(val == "")

holds true, no assertion, while with this patch, this would assert:

vals := [1]string{val}
assert(vals == "")

So this may still not be correct.

laytan avatar Jul 19 '25 20:07 laytan

Hmm I see that counts for other types too, consider an array of maps, dynamic arrays etc, those also only check their data pointer So yes sadly still incorrect

EDIT: never mind, these types are not simply comparable

FourteenBrush avatar Jul 19 '25 20:07 FourteenBrush