[4.0dev] GDScript - Mixed tabs and spaces not allowed in multiline declarations
Godot version:
364ea7f280a3f074795e542b16b1d0ec76cf6ce2
OS/device including version:
Windows 10 (20H2) x64
Issue description:
This issue is similar to the issue in #30937, except it might not be considered a regression as the language has had some fundamental changes between 3.x and 4.x. Multiline declarations such as arrays and dicts do not support the same multiline syntax as in 3.x, popping up an error about mixed tabs and spaces when writing these declarations in a way to align them to a user's screen. See example in next section, and the related issue for examples which still produce the issue in the new version of GDScript.
Steps to reproduce:

Workaround (tldr: only use spaces):
I think this issue could actually be much mitigated at the level of the text editor. Let's say that the indentation is set to 4 spaces, pressing TAB could actually add 4 spaces. In this way, we retain the comfort of adding such spaces in a quick way, but the error is much less likely to happen, as you would really need to copy/paste a \t for this to happen. Most modern editors such as VS Code and PyCharm do exactly that when writing in Python.
P.S.: I just realised how to set the text editor to achieve what I was suggesting.
In the top menu, find and press on Editor -> Editor Settings. It will open a new window and you will find on the left, the item Text Editor with subitem Indentation. There you can change Type from Tabs to Spaces. I recommend you leave Size to 4 and that you enable Draw Spaces.
@fcole90 The above report uses tabs for indentation but spaces for alignemnt. This is a common pattern to format code in programming. (You can see it with the indentation icons on the left which represent tabs, not spaces.)
The GDScript style guide uses tabs, so tabs will remain the default. Personally, I only use tabs ever (including for alignment), since I consider it to be less effort. However, some people like to use spaces to "complete" their alignment so that things are perfectly aligned.
@Calinou I know tabs take less effort, and that's why I was looking for a solution that achieves exactly that level of comfort. With my workaround, pressing TAB inserts 4 spaces, so you can just press TAB as you used to do, but 4 spaces will appear, hence keeping the same effect as proper tabs. I too use spaces to complete alignment, especially with dictionaries, lists or functions with many parameters, and this workaround really helped me into that. I have no tabs at all in my Python code but I achieve the same effect. I think, indeed, that Python forbids entirely mixing tabs and spaces in the same file (except for docstrings).
I would recommend revising the GDScript style guide then, as using just spaces in such a way could really improve everything.
Python3 indentation guidelines: https://docs.python.org/3/reference/lexical_analysis.html#indentation
P.S. I created a proposal to change the guidelines: https://github.com/godotengine/godot-proposals/issues/2800
But many people will want to use tabs, and have actual tab characters show up in their source files and. Removing the ability to use actual tabs would be annoying. It's not just about tabs being easier to type or something.
Yes, my suggestion here is just a workaround, I never suggested tabs being removed from the language. At most I suggested spaces being the default :wink:
Just downloaded new 4.0 and see this is still an issue but appears to no longer have an explicit timeline for addressing it. Is the discussion tag for deciding if this is still considered a regression? (I'm encountering it again when migrating projects)
Edit: This also affects comment lines
I don't think this needs more discussion. It is a bug since the contents of a multiline expression should not consider indentation and it's a regression because it worked in 3.x.
Regarding the time to fix, there's only so much we can do in a certain time frame, some fixes will have to be postponed. I didn't even notice it was assigned to me until now TBH.
Changing the if (mixed) { around line 1100 in modules/gdscript/gdscript_tokenizer.cpp to if (mixed && !(line_continuation || multiline_mode)) { seems to be enough to solve it.
@MystMagus feel free to open a PR with your change BTW.
Hope that's correct, have not contributed before.