Skip to content

Bug in ast/index_access.go #190

@xianlinc

Description

@xianlinc

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)

Metadata

Metadata

Assignees

Labels

astAbstract Syntax TreebugSomething isn't workinghigh priorityHigh Priority Tasks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions