bcc icon indicating copy to clipboard operation
bcc copied to clipboard

[Generics] Crash, Possible C code casting bug?

Open thareh opened this issue 1 year ago • 2 comments

Good day,

Seems like I found another generics bug:

Framework BRL.Blitz
Import BRL.StandardIO

'Switch these
Import "Import2.bmx"
Import "Import1.bmx"

TFoo.map["test"] = "test"
TBar.map["test"] = "test"

For Local key:String = EachIn TFoo.map.Keys()
	Print TFoo.map[key]
Next

For Local key:String = EachIn TBar.map.Keys()
	Print TBar.map[key]
Next

Import1.bmx

Framework BRL.Blitz
Import BRL.Collections

Type TFoo
	
	Global map:TTreeMap<String, String> = New TTreeMap<String, String>()
	
EndType

Import2.bmx

Framework BRL.Blitz
Import BRL.Collections

Type TBar
	
	Global map:TTreeMap<String, String> = New TTreeMap<String, String>()
	
EndType

Seems the casting in the C code produced is wrong.

If you compile this, and have a look at the C code and then switch the order of the imports you'll see that the casting of the last import is applied "everywhere". (Sorry, can't find the proper words)

Anyway, not 100% sure that this is the issue, but that's my guess.

Thanks!

thareh avatar Apr 10 '24 08:04 thareh

Any chance you have time to take a look at this? @woollybah

thareh avatar Apr 10 '24 11:04 thareh

I've been experimenting in the blind, trying to find the issue - but I can't for the life of me figure it out. Seems to me like BCC equates the two classes and thus uses the second ones scope where it shouldn't.

Will be very interesting to see what the solution is!

Cheers.

thareh avatar Apr 21 '24 08:04 thareh