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

errors in return expressions #12

Open
2 tasks
bennn opened this issue Jun 18, 2024 · 1 comment
Open
2 tasks

errors in return expressions #12

bennn opened this issue Jun 18, 2024 · 1 comment

Comments

@bennn
Copy link
Member

bennn commented Jun 18, 2024

The syntax for return expressions is very limited. Below are two tiny examples.

Issue #8 has a bigger example where the choreography ends with an if/else. It wants to return a value in one branch (fine) and loop in the other branch (error).

  • return value ==> ProjectionError
  defmodule TestChor do
    defchor [Buyer, Seller] do
      Buyer.get_book_title() ~> Seller.(b)
      Seller.get_price("book:" <> b) ~> Buyer.(p)
      0 # ** (Chorex.ProjectionError) Unrecognized code: 0
    end
  end
  • function call ==> MatchError
  defmodule TestChor do
    def double(n), do: n + n

    defchor [Buyer, Seller] do
      Buyer.get_book_title() ~> Seller.(b)
      Seller.get_price("book:" <> b) ~> Buyer.(p)
      double(3) # ** (MatchError) no match of right hand side value: 3
    end
  end
@ashton314
Copy link
Member

Return values need to be tied to an actor; e.g.:

defchor [Buyer, Seller] do
  ...
  Seller.(0)
end

We should have some better syntax/better error messages around this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants