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

Unable to call object properties that are functions #589

Open
mhagmajer opened this issue May 18, 2021 · 7 comments
Open

Unable to call object properties that are functions #589

mhagmajer opened this issue May 18, 2021 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@mhagmajer
Copy link
Collaborator

mhagmajer commented May 18, 2021

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.

@mhagmajer mhagmajer added the bug Something isn't working label May 18, 2021
@mhagmajer mhagmajer added this to the v1.3 (draft) milestone May 18, 2021
@pkarw
Copy link
Collaborator

pkarw commented May 18, 2021

yesterday, while digging into the parser I had an idea that maybe we just change how . works:

/ ws* '.' ws* i:identifier { return new ask.KeyIdentifierApplied(i) }
- somehow making it more like the : I mean adding an option for a MethodCallApplied transformation instead of KeyExpressionApplied

That's why it works by deconstruction - bc. when deconstructed it gets into:

functionCall = i:identifier ws* '(' cAL:callArgList ')' { return new ask.FunctionCall(i, cAL) }

@mhagmajer
Copy link
Collaborator Author

@czerwinskilukasz1 what do you think about this?

@pkarw
Copy link
Collaborator

pkarw commented May 18, 2021

@czerwinskilukasz1 we neeed your help! 🙏😁

@lukasz-xfaang
Copy link

Ack. I will try to reply tomorrow.

@mhagmajer
Copy link
Collaborator Author

@czerwinskilukasz1 friendly ping :)

@pkarw
Copy link
Collaborator

pkarw commented Jun 7, 2021

@czerwinskilukasz1 another friendly ping ;P

@pkarw
Copy link
Collaborator

pkarw commented Jun 17, 2021

@lukasz-xfaang i've stuck on this :( I really need your help @lukasz-xfaang @czerwinskilukasz1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants