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

Consistent returns for read_variable_declaration #1141

Merged
merged 3 commits into from
Dec 4, 2024

Conversation

genintho
Copy link
Collaborator

@genintho genintho commented Nov 25, 2024

While working on adding support for property hooks, I realized that the function parsing class property does not always call the "return" function with the same parameters: in some instance, the parameter readonly is not being passed done.

This PR fix that by having 1 call to return despite multiple branches in the logic.

} else {
this.expect([",", ";", "="]);
return result(propName, null, nullable, type, attrs || []);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here, readonly is not passed.

"kind": "property",
"name": Identifier {
"kind": "identifier",
"name": "onst",
},
"nullable": Name {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The snapshot show that what was set was incorrect: instead of a boolean value we had some objects.

type,
attrs || [],
);
value = this.next().read_expr();
} else {
this.expect([",", ";", "="]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to drop the "=" in th eexpect, we already handled that with the previous if condition.

Suggested change
this.expect([",", ";", "="]);
this.expect([",", ";"]);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"," and ";" are handled by the first if.
I think this line is here to show an error message indicating that we expect one of those 3 things.

I figured this out while working on adding support for property hooks.

Copy link
Collaborator

@cseufert cseufert 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, if we could just streamline the if else when looking for a default value, they we can merge this.

@genintho genintho requested a review from cseufert November 30, 2024 22:41
Copy link
Collaborator

@cseufert cseufert left a comment

Choose a reason for hiding this comment

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

LGTM

@genintho
Copy link
Collaborator Author

genintho commented Dec 2, 2024

I do not have permission to merge 😄 .

@czosel czosel merged commit 50d3bfb into glayzzle:main Dec 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants