asar icon indicating copy to clipboard operation
asar copied to clipboard

Function parameters are case-insensitive

Open exodustx0 opened this issue 10 months ago • 3 comments
trafficstars

asar 1.90
function Foo(bar) = BAR
print dec(Foo(42))

This prints 42. While the fix for this is relatively simple (replacing stribegin() with strncmp() in asar_call_user_function()), it would be a breaking change. Similarly:

asar 1.90
function Foo(bar, BAR) = 123
print dec(Foo(1, 2))

This prints error: (Eduplicate_param_name): Duplicated parameter name: bar in creation of function Foo [function Foo(bar,BAR) = 123]. This is an even simpler fix (replacing stricmp() with strcmp() in createuserfunc()), and isn't breaking, but depends on the first issue being fixed.

exodustx0 avatar Dec 31 '24 03:12 exodustx0

I'm fine by fixing this for 2.0, but i think in 1.9 (if we do another minor release) adding a warning for case 1.

It may be minor enough to just be a drive by fix though.

p4plus2 avatar Dec 31 '24 11:12 p4plus2

The 1.9 case 1 warning, would it after warning fall back to old behaviour? If so, I would also throw a warning in case 2 about how what the user is trying should work but cannot, due to the case 1 bug, and then also fall back to old behaviour: if a user defines function Foo(bar, BAR) = ..., and case 1 is not fixed but only warned over, BAR would be inaccessible.

exodustx0 avatar Dec 31 '24 12:12 exodustx0

oops, turns out i accidentally fixed it in asar 2.0 already. probably should add a warning then.

i think just a warning for the first case is enough. if you really need to have function foo(bar, BAR) then just port your stuff to asar 2 :)

trillllian avatar Mar 07 '25 23:03 trillllian