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

Bug in ast/index_access.go #190

Closed
xianlinc opened this issue Apr 3, 2024 · 3 comments · Fixed by #191
Closed

Bug in ast/index_access.go #190

xianlinc opened this issue Apr 3, 2024 · 3 comments · Fixed by #191
Assignees
Labels
ast Abstract Syntax Tree bug Something isn't working high priority High Priority Tasks

Comments

@xianlinc
Copy link

xianlinc commented Apr 3, 2024

Context

Found a bug while trying to print an index access node in the AST.
source code: myArray[idx]
Expected: myArray[idx]
Actual: idx[myArray]

Problem

I think that the (i *IndexAccess) Parse method has a bug where the index and base expressions are swapped.

Currently:

  • i.IndexExpression -> ctx.Expression(0)
  • i.BaseExpression -> ctx.Expression(1)

Should be:

  • i.IndexExpression -> ctx.Expression(1)
  • i.BaseExpression -> ctx.Expression(0)
@xianlinc
Copy link
Author

xianlinc commented Apr 3, 2024

On a side note, I can't seem to label the issue due to lack of permissions 🫡

@0x19 0x19 added bug Something isn't working ast Abstract Syntax Tree high priority High Priority Tasks labels Apr 3, 2024
@0x19 0x19 self-assigned this Apr 3, 2024
@0x19
Copy link
Contributor

0x19 commented Apr 3, 2024

Wow missed this one out. Thank you! Going to fix it tomorrow

@0x19
Copy link
Contributor

0x19 commented Apr 4, 2024

Alright @xianlinc it's resolved! Merging in soon the fix into the main. Thanks again for finding this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Abstract Syntax Tree bug Something isn't working high priority High Priority Tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants