If-then-else Expression has Issues with Functions

Studio Bugs: if-then-else expressions not behaving as expected
The if-then-else expression recently added has end completion and indentation issues when either the ‘a’ or ‘b’ in if a then b else c is a function.

Repro
In studio, try and type any if-then-else expression that contains a function in either the ‘a’ or ‘b’ part of the expression. Then press enter to start new line and it will either attempt to auto complete or go back an indentation.
ScriptEditorBug

Expected behavior
It should behave in the same way the old syntax behaved. The same expression using and-or has no issues.

local str = workspace:FindFirstChild("Part") and "found" or "nope"

Whats wrong with doing it like:

local str = workspace:FFC("Part") and 'found' or 'nope'

The issue is that this is a bug report and workarounds don’t solve bugs. This is a new luau feature and is intended to do that job. The old way was merely a side effect of Lua’s logic behavior. It is better to use things which have been purpose built as there will be better long term support and optimization.

5 Likes

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up when we have an update for you.

2 Likes

Following up on this thread,
This issue should be fixed. Let me know if there are any other issues!