Skip to content

Unable to call object properties that are functions #589

@mhagmajer

Description

@mhagmajer

The following code produces a parsing error when run on the playground

ask {
  const sum = fun(a, b) {
      a + b
  }
  
  const diff = fun(a, b) {
      a - b
  }
  
  const myMath = { sum, diff }
   
  myMath.sum(2, 2)
}

It works fine, when myMath is destructured first:

const s = myMath.sum
s(2,2)

Used expression (myMath.sum(2, 2)) should be translated into

<call
  args={
    <list>
      {2}
      {2}
    </list>
  }
>
  <call
    name="at"
    args={
      <list>
        <ref name="myMath" />
        {"sum"}
      </list>
    }
  />
</call>

Note that call in AskJSX can accept either the name property in args or function expression in its first child.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions