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

Error parsing and formatting set call #768

Open
4kxz opened this issue Dec 22, 2024 · 2 comments
Open

Error parsing and formatting set call #768

4kxz opened this issue Dec 22, 2024 · 2 comments
Labels

Comments

@4kxz
Copy link

4kxz commented Dec 22, 2024

Godot version

4.3

VS Code version

1.96.1

Godot Tools VS Code extension version

2.3.0

System information

Linux

Issue description

The following code is not parsed correctly:

func example():
    set("theme/font_color", Color.BLUE if value >= 1 else Color.RED)

The first argument is not parsed as a string (it's not coloured as one).

Then the formatter adds a space after the >, which breaks the script:

func example():
    set("theme/font_color", Color.BLUE if value > = 1 else Color.RED)

Steps to reproduce

Create a new GDScript file, paste the following code and format the document:

func example():
    set("theme/font_color", Color.BLUE if value >= 1 else Color.RED)
@4kxz 4kxz added the bug label Dec 22, 2024
@DaelonSuzuka
Copy link
Collaborator

The first argument is not parsed as a string (it's not coloured as one).

A little bit more than the first argument is broken, don't you think?

It appears that the rules for defining setters and getters are interfering here. I don't know what your 'set' function is, but as a workaround you can try explicitly adding self.:

func example():
    self.set("theme/font_color", Color.BLUE if value >= 1 else Color.RED)

The getter/setter highlighting rules were rather complicated to get working in the first place, so I can't promise a quick fix for this.

@4kxz
Copy link
Author

4kxz commented Dec 22, 2024

Thanks for looking into it.

A little bit more than the first argument is broken, don't you think?

Probably, but I read left to right and I noticed the error when I got to the first argument, so that's what I put in my exception.

I don't know what your 'set' function is,

It's actually a built-in method of the Object class, not a function I have defined:
https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-set

The getter/setter highlighting rules were rather complicated to get working in the first place, so I can't promise a quick fix for this.

I understand. It's not something that blocks development or could cause issues in-game, so no worries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants