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

[GDScript] Prevent running String number functions on invalid literal #87941

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Feb 4, 2024

Prevents printing excessive errors.

We could also just remove the error print in hex_to_int but it was added quite a while ago and is a good indication of what's wrong when parsing strings IMO, and at least I don't think it should be removed just to prevent an annoying print in the GDScript parser (I'd even argue we might want to add errors to bin_to_int and the others)

Literals containing decimal points will already stop consuming input before them so that won't trigger an error print on that part (other than the GDScript tokenizer error, but the annoying part is the print to console)

@AThousandShips AThousandShips added bug topic:gdscript cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Feb 4, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone Feb 4, 2024
@AThousandShips AThousandShips requested a review from a team as a code owner February 4, 2024 12:56
Comment on lines +830 to +833
error.start_column = column;
error.leftmost_column = column;
error.end_column = column + 1;
error.rightmost_column = column + 1;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unsure if the full error info is required here, but added it for completeness, unsure what the difference here is to not using it like below

Copy link
Member

Choose a reason for hiding this comment

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

I think it is right. Such errors should be reported as a cursor rather than a selection.

Copy link
Member

@dalexeev dalexeev 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. push_error() vs return error can be improved later (like lines 844-845 and 848).

@akien-mga akien-mga merged commit 2f9ea3a into godotengine:master Feb 5, 2024
16 checks passed
@AThousandShips AThousandShips deleted the num_fix branch February 5, 2024 14:00
@akien-mga
Copy link
Member

Thanks!

@AThousandShips
Copy link
Member Author

Thank you!

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 11, 2024
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.

Invalid (or incomplete) hex number "0x" floods error messages
3 participants