Page 1 of 1
Switch bug, CaseSense is invalid.
Posted: 03 Jun 2023, 12:21
by XMB-7
Code: Select all
!T::
{
test_str := 'a'
switch(SwitchValue:=test_str, CaseSense:='Off')
{
case 'a': MsgBox('1')
case 'b': MsgBox('2')
default: MsgBox('0')
}
}
When triggering the above hotkey, 0 always pops up.
Only with `CaseSense:='Off'` removed, 1 would pop up as expected.
![image.png](./download/file.php?id=22113&sid=e81e76765d13a3f2e73a620796779f13)
- image.png (73.84 KiB) Viewed 686 times
[Mod action: Topic moved from "Bug Reports" since it is not a bug.]
Re: Switch bug, CaseSense is invalid.
Posted: 03 Jun 2023, 13:17
by swagfag
ure misusing the parentheses, passing the value of whichever rightmost sub-expression gets evaluated last to switch's first parameter. get rid of them
Re: Switch bug, CaseSense is invalid.
Posted: 03 Jun 2023, 22:07
by XMB-7
Does the switch statement still use the v1 syntax? I only learned v2, and just thought anything that accepts arguments should be considered a function and all arguments can be enclosed in parentheses.
If so, when implementing something like `switch(SwitchValue:=test_str, CaseSense:='Off')`, it would be better for the interpreter to report an error.
Re: Switch bug, CaseSense is invalid. Topic is solved
Posted: 03 Jun 2023, 22:56
by swagfag
it uses whatever syntax is documented, which clearly isnt the one u seem to be thinking of
switch is a built-in keyword, a control-flow statement. not a function, not a command nor anything else u might have thought it was
the interpreter cant report an error, because this usage is not erroneous