Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Auto brace complete" cause tokenizer error with strings as comments #35994

Closed
Tracked by #40488
noidexe opened this issue Feb 7, 2020 · 6 comments
Closed
Tracked by #40488

"Auto brace complete" cause tokenizer error with strings as comments #35994

noidexe opened this issue Feb 7, 2020 · 6 comments

Comments

@noidexe
Copy link
Contributor

noidexe commented Feb 7, 2020

Godot version:
3.2

OS/device including version:
Description: Manjaro Linux
Release: 18.1.5
Codename: Juhraya
Kernel: Linux 5.4.15-2-MANJARO
Architecture: x86-64

Issue description:
When auto brace complete is turned on an one tries to use multiline strings (or standard strings) as comments the console will output the folowing error when opening a parenthesis or any bracket.

modules/gdscript/gdscript_tokenizer.cpp:1129 - Condition "tk_rb[ofs].type != TK_IDENTIFIER" is true. Returned: StringName()

It doesn't seem to break the editor in any way, however.

Steps to reproduce:

  • check that "Auto Brace Complete" is enabled in Editor Settings
  • on an empty line on any script type the following: "( or """(
    Expected:
  • no errors since ( [ { are valid characters inside a string
    Actual:
  • as soon as the bracket is auto closed the tokenizer will print the error described above
@dreamsComeTrue
Copy link
Contributor

When my Auto-brace complete is ON, and I typed " on new line I immediately got completing " character - so it's a valid String.
So the question is - is your Auto-Brace completion work as expected? You're showing in 'Steps to reproduce' unfinished Strings which are invalid of course - but what do you expect then?

Can you record a GIF showing that issue, it's hard to reproduce with above description.

@noidexe
Copy link
Contributor Author

noidexe commented Feb 11, 2020

@dreamsComeTrue maybe my instructions were not clear enough. You are supposed to type "( or """( and not only the " will be autocompleted but also the closing ) and that will trigger a tokenizer error

Here's a gif showing that (, [ and { trigger the error inside a normal string while only ( trigger the error inside a multiline string

https://gfycat.com/shockeddeadlyduckling

@dreamsComeTrue
Copy link
Contributor

OK, I was able to reproduce it, but only in one test case:

  • when I am on new, empty line (char pos: 0) and when I type: ", and then [ - I've got autocompletion,
    for both of those chars, but that error too.

BUT, when I moved in, into - for example 'func' block, so I am indented (like with 4 spaces), and I repeat the same process - there is no tokenizer error at all.

So I've basically confirmed your GIF.
BUT are those a real-word-use-cases? Can you provide some code sample, which will actually compile and use that process of creating Strings? Because if I try to combine that issue with, for example var declaration, like:

var a = """
[[]]
"""

then error is not showing (for each of the bracket type).

@noidexe
Copy link
Contributor Author

noidexe commented Feb 23, 2020

@dreamsComeTrue many people use multiline strings as comments, as it is also customary in python.
In any case, a bug with an uncommon use case is still a bug, even if you can classify it as lowest priority.
As I mentioned in the bug report, it doesn't seem to create any observable malfunction, just an error in the console. I still wanted to reported since it might appear to be something minor to me but maybe it's silently breaking something else and only the ones in charge of the code can know that.

@ThakeeNathees
Copy link
Contributor

it's because of the cursor splits the string into string, cursor, and some maybe invalid token
"(|)" (vertical line is cursor) is become
TK_CONST("("), TK_CURSOR, TK_BRACKET_CLOSE => which simply equal to "("|)<- the close bracket is unexpected token.

there is another way to cause this error

func f():
	$"/root|." ## now type something between the 't' and the '.'

@akien-mga
Copy link
Member

I can reproduce the issue on 3.x (7244ea7), but it seems fixed on master.

On 3.x, I can only reproduce it when typing these strings in the global scope, not in a function scope. So as discussed above it's a fairly uncommon use case, and since it's fixed in 4.0, I think this can be closed.

@akien-mga akien-mga added this to the 4.0 milestone Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants