HaveItem does not work if uppercase letters are used

Report any Hollywood bugs here
Post Reply
amiga23
Posts: 33
Joined: Thu Jan 30, 2014 6:01 pm

HaveItem does not work if uppercase letters are used

Post by amiga23 »

If I put a key with uppercase letters into a table, HaveItem does not find it. I found some similar issues in the forum, but these claim that table keys are case sensitive, so I consider this a bug in HaveItem().

I guess there is a LowerStr() in HaveItem, which should not be there.

Code: Select all

table = {}
table["Hello AMIGA"] = "AMIGA"

DebugPrint(table["Hello AMIGA"])
DebugPrint(HaveItem(table, "Hello AMIGA"))  ; Does not find it -> BUG
DebugPrint(HaveItem(table, "hello amiga"))  ; Does not find it -> correct

table = {}
table["HelloAMIGA"] = "AMIGA"

DebugPrint(table["HelloAMIGA"])
DebugPrint(HaveItem(table, "HelloAMIGA"))   ; Does not find it -> BUG
DebugPrint(HaveItem(table, "helloamiga"))   ; Does not find it -> correct

table = {}
table["hello amiga"] = "AMIGA"

DebugPrint(table["hello amiga"])
DebugPrint(HaveItem(table, "Hello AMIGA"))  ; Does find it -> BUG
DebugPrint(HaveItem(table, "hello amiga"))  ; Does find it -> correct

table = {}
table["helloamiga"] = "AMIGA"

DebugPrint(table["helloamiga"])
DebugPrint(HaveItem(table, "HelloAMIGA"))  ; Does find it -> BUG
DebugPrint(HaveItem(table, "helloamiga"))  ; Does find it -> correct
amiga23
Posts: 33
Joined: Thu Jan 30, 2014 6:01 pm

Re: HaveItem does not work if uppercase letters are used

Post by amiga23 »

Hmm okay, RawGet() is the function to use. But that is confusing, what is this automatic lower case good for?
User avatar
airsoftsoftwair
Posts: 5450
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: HaveItem does not work if uppercase letters are used

Post by airsoftsoftwair »

amiga23 wrote: Tue Apr 04, 2023 10:13 pm Hmm okay, RawGet() is the function to use. But that is confusing, what is this automatic lower case good for?
In contrast to Lua, Hollywood doesn't distinguish between upper and lower case for convenience's sake. Some internal VM mechanics make it necessary that Hollywood does an upper/lower case distinction when it comes to table items. It tries to hide the fact that it does that from users as much as possible but in some scenarios it's impossible to avoid. See here for some more info: viewtopic.php?p=16467#p16467
Post Reply