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

Fix deference behavior on mixed subscript and arrow / dot operators #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChAoSUnItY
Copy link
Collaborator

@ChAoSUnItY ChAoSUnItY commented Mar 20, 2025

Summary by Bito

This pull request fixes a double free error in the globals file and enhances type safety in the parser by changing variable types from int to bool. It also introduces new tests for dynamic data structures, focusing on mixed subscript and arrow/dot operators to improve code reliability and safety.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 2

@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 20, 2025
@ChAoSUnItY ChAoSUnItY marked this pull request as ready for review March 20, 2025 11:28
@ChAoSUnItY ChAoSUnItY changed the title Fix deference behavior on mixed subscription and arrow operator Fix deference behavior on mixed subscript and arrow operators Mar 20, 2025
@ChAoSUnItY ChAoSUnItY requested a review from DrXiao March 20, 2025 16:25
Previously, using subscription operator (literally "[]") with arrow
operator (literally "->") or dot operator (literally ".") would cause
incorrect dereference result due to inappropriate delayed dereference
strategy. In this patch, by adding dereference instructin when encount-
ered subscription operator and under correct circumstances fixes the
issue.
@ChAoSUnItY ChAoSUnItY changed the title Fix deference behavior on mixed subscript and arrow operators Fix deference behavior on mixed subscript and arrow / dot operators Mar 20, 2025
Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Clarify the use of "deference" and "dereference" in the wording.

@@ -1260,6 +1260,22 @@ void read_lvalue(lvalue_t *lvalue,
while (lex_peek(T_open_square, NULL) || lex_peek(T_arrow, NULL) ||
lex_peek(T_dot, NULL)) {
if (lex_accept(T_open_square)) {
/* if subscripted member's is not yet resolved, deference to resolve
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a comma (,) appearing right after "e.g.". That is, e.g.,.

See https://www.scribbr.com/definitions/for-example-abbreviation/

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