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

Allow boolean operators for all Variant types #74741

Merged
merged 2 commits into from
Jun 18, 2023

Conversation

vnen
Copy link
Member

@vnen vnen commented Mar 10, 2023

  • Add OP_NOT for all types in Variant.
  • Allow any opeand for and and or in GDScript. Those have short-circuit semantics and do not rely on Variant operators.

Fix #44688

To make consistent with previous behavior. Mostly to be used in
conditions for `if` and `while`.
@DaloLorn
Copy link

So... what's the status on this PR? I was hoping to continue porting my game to 4.x when 4.1 released (got halfway through before finding out about #44688 the hard way...), but at the rate it's going, I'm starting to worry it might not get into 4.1 in the first place. 😟

@akien-mga
Copy link
Member

akien-mga commented Jun 16, 2023

That hardly seems like a game breaking bug? You can simply be explicit about casting to booleans.

Edit: I just re-read that it's about porting a 3.x game, so if you have hundreds of occurrences I understand it can be a hassle.

@DaloLorn
Copy link

DaloLorn commented Jun 16, 2023

Yeah, I was just about to point that out. 😂

Mind you, given what I was doing with that particular bit of syntax, the simplicity is itself pretty valuable. Makes the code more legible when you have if not array instead of the multi-condition check required to emulate it in 4.0. (I can't even remember what it's like, but I'm pretty sure it was a combination of multiple checks, like array != null && array.length != 0 or something.)

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me for a merge in 4.1

Thanks @vnen for the PR and the extensive unit tests.

@akien-mga akien-mga merged commit 1a62f1e into godotengine:master Jun 18, 2023
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

GDScript: logical and/or between non boolean value cause a parser error
4 participants