Inability to pattern match a datatype from a remote contract #471

Open
opened 2023-07-17 17:52:48 +09:00 by ghallak · 1 comment
ghallak commented 2023-07-17 17:52:48 +09:00 (Migrated from gitlab.com)
contract C2 =
  datatype dt = Zero | One(int)

main contract C =
  entrypoint foo(d : Cx.dt) =
    switch (d)
      Cx.Zero => 0
      Cx.One(_) => 1

The above code fails with the following error message:

type_error:7:7: Invalid call to contract entrypoint `Cx.Zero`. (It must be called as `c.Zero` for some `c : Cx`.)
type_error:8:7: Invalid call to contract entrypoint `Cx.One`. (It must be called as `c.One` for some `c : Cx`.)

This issue is realted to the commit 5adeb6c93e that banned using contracts as namespaces.

``` contract C2 = datatype dt = Zero | One(int) main contract C = entrypoint foo(d : Cx.dt) = switch (d) Cx.Zero => 0 Cx.One(_) => 1 ``` The above code fails with the following error message: ``` type_error:7:7: Invalid call to contract entrypoint `Cx.Zero`. (It must be called as `c.Zero` for some `c : Cx`.) type_error:8:7: Invalid call to contract entrypoint `Cx.One`. (It must be called as `c.One` for some `c : Cx`.) ``` This issue is realted to the commit https://github.com/aeternity/aesophia/commit/5adeb6c93ee8a78feb6663578216021c4a61baef that banned using contracts as namespaces.
zxq9 commented 2023-08-27 10:09:38 +09:00 (Migrated from gitlab.com)

Created by: marc0olo

I am now also using a namespace as "workaround" as suggested by @radrow and @hanssv.

I think this is the core issue I ran into which I didn't dig into too deep. because of this issue I used a "solution" which was obviously a bug that has recently been fixed with https://gitlab.com/gajumaristas/aesophia/-/merge_requests/469.

IMO this issue should be prioritized if there is nothing more "urgent" on the list.

*Created by: marc0olo* I am now also using a namespace as "workaround" as suggested by @radrow and @hanssv. I think this is the core issue I ran into which I didn't dig into too deep. because of this issue I used a "solution" which was obviously a bug that has recently been fixed with https://gitlab.com/gajumaristas/aesophia/-/merge_requests/469. IMO this issue should be prioritized if there is nothing more "urgent" on the list.
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#471
No description provided.