NorthstarLauncher icon indicating copy to clipboard operation
NorthstarLauncher copied to clipboard

Warn about incorrect use of `=` on squirrel table

Open emma-miler opened this issue 2 years ago • 5 comments

In squirrel, using assignment operator = to set a key on a table will result in memory corruption if that key does not already exist. We should see if its viable to warn against this and let the user know to use <- operator instead.

emma-miler avatar Dec 18 '22 21:12 emma-miler

Not just memory corruption, the script silently stops its current execution. No errors, no warnings, just stops. And then you get a nice crash a while later if you're unlucky.

Erlite avatar Dec 19 '22 06:12 Erlite

We should see if its viable to warn against this and let the user know to use <- operator instead.

I think we should just raise full script error and let it crash with appropriate error message.

Do we have a mention of this in the wiki btw? As in people should check if table contains before writing to it?

GeckoEidechse avatar Dec 19 '22 11:12 GeckoEidechse

I mean <- does everything = but better, = should never be used with tables really

ASpoonPlaysGames avatar Dec 19 '22 16:12 ASpoonPlaysGames

= should be used for reassigning a value in a table

uniboi avatar Dec 19 '22 16:12 uniboi

<- also does it, if you want to avoid setting a new value in a table with <- just check if it exists beforehand, which you would have to do with = anyway to avoid this issue

ASpoonPlaysGames avatar Dec 19 '22 16:12 ASpoonPlaysGames