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

Any chance of changing assignment in conditional from error to warning? #31210

Closed
rslepon opened this issue Aug 8, 2019 · 2 comments
Closed

Comments

@rslepon
Copy link

rslepon commented Aug 8, 2019

Godot version:
Godot_v3.1.1-stable_win64

Issue description:
At the moment, gdscript does not allow assignment in conditionals, such as "if a = b:", yielding an "Unexpected assign" error.

While I understand the wisdom of this, I can also see some scenarios where allowing these would make code more readable and maintainable, which is no less important. Here is one example, for parsing a string that may have a host of different formats:

if regexmatch = regex1.search(string):
   [extract some data from groups collected in regexmatch]
elif regexmatch = regex2.search(string):
   [extract some data from groups collected in regexmatch]
elif regexmatch = regex3.search(string):
   [extract some data from groups collected in regexmatch]
elif regexmatch = regex4.search(string):
   [extract some data from groups collected in regexmatch]

So, any chance of changing assignment in conditional from error to warning?

@KoBeWi
Copy link
Member

KoBeWi commented Aug 8, 2019

Oooh, this reminds me of #7222

I was going to revive it after the warnings were added. There's no reason to reject it now 😏

@vnen
Copy link
Member

vnen commented Jun 22, 2020

Duplicate of #7222 and proposals have their own tracker now.

See also the proposal for a similar feature: godotengine/godot-proposals#1103

@vnen vnen closed this as completed Jun 22, 2020
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

4 participants