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(compiler): Return ability arrow [LNG-258] #935

Merged
merged 10 commits into from
Oct 23, 2023

Conversation

DieMyst
Copy link
Member

@DieMyst DieMyst commented Oct 18, 2023

Description

After this PR functions in abilities can be called with <- symbol, as common functions.

func create() -> TestAb:
    arrow = () -> i8, i8:
        <- 42, 76
    <- TestAb(inner = InnerAb(arrow = arrow))

func test() -> i8, i8:
    ababab <- create()
    res1, res2 <- ababab.inner.arrow()
    <- res1, res2

Implementation Details

Handle ApplyPropertyRaw with IntoArrowRaw for CallArrowRawTag

Checklist

  • Corresponding issue has been created and linked in PR title.
  • Proposed changes are covered by tests.
  • Documentation has been updated to reflect the changes (if applicable).
  • I have self-reviewed my code and ensured its quality.
  • I have added/updated necessary comments to aid understanding.

Reviewer Checklist

  • Tests have been reviewed and are sufficient to validate the changes.
  • Documentation has been reviewed and is up to date.
  • Any questions or concerns have been addressed.

@linear
Copy link

linear bot commented Oct 18, 2023

LNG-258 Can't use returned ability arrow

aqua:

ability TestAb:
    arrow() -> i8

func create() -> TestAb:
    arrow = () -> i8:
        <- 42
    <- TestAb(arrow = arrow)

func test():
    ab <- create()
    res <- ab.arrow()

error:

---- Error: /home/vagrant/aqua/aqua-src/antithesis.aqua:15:12
15     res <- ab.arrow()
              ^^========
     Expected arrow call, got var{ab: ability TestAb{arrow: ∅ -> i8 :: ∅}}.IntoArrowRaw(arrow,i8,List())

this snippets do not pass parsing stage:

Ab <- create()
res <- Ab.arrow()
AB <- create()
res <- AB.arrow()

possible workaround:

Ab = create()
res <- Ab.arrow()

But using ← should be allowed

@DieMyst DieMyst added the e2e Run e2e workflow label Oct 18, 2023
@DieMyst DieMyst marked this pull request as ready for review October 18, 2023 08:42
DieMyst and others added 2 commits October 18, 2023 13:04
…Inliner.scala

Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
Co-authored-by: InversionSpaces <InversionSpaces@vivaldi.net>
CallArrowRawInliner.unfold(CallArrowRaw.ability(n, name, at, args), exportTo).flatMap {
case (_, inline) =>
RawValueInliner
.inlineToTree(inline.copy(predo = Chain.fromOption(prevInline) ++ inline.predo))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Write Inline.prepend like Inline.append

closure = (x: i8) -> bool:
<- x > 20

MySSS = SSS(arrow = closure)
MyCCCC = CCCC(simple = MySSS, arrow = MySSS.arrow)
res1 <- MySSS.arrow(42)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this test the bug fix?
Let's create a separate test with:

  • Abilities returned from func
  • Abilities with names ab, Ab, AB (or similar in terms of case)

@DieMyst DieMyst merged commit fab46ee into main Oct 23, 2023
10 checks passed
@DieMyst DieMyst deleted the LNG-258-return-ability-arrow branch October 23, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants