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

feat(compiler): Structural typing for data and abilities [fixes LNG-215] #843

Merged
merged 5 commits into from
Aug 18, 2023

Conversation

DieMyst
Copy link
Member

@DieMyst DieMyst commented Aug 17, 2023

No description provided.

@linear
Copy link

linear bot commented Aug 17, 2023

LNG-215 Add structural subtyping for `data` and `ability`

This should compile:

aqua Main

export main

ability Smaller:
    arrow(x: i8) -> bool

ability Bigger:
    arrow(x: i8) -> bool
    field: string

func useSmaller{Smaller}() -> bool:
    <- Smaller.arrow(42)

data SmallerStruct:
    str: string

data BiggerStruct:
    str: string
    field: i8


func useSmallerStruct(s: SmallerStruct) -> string:
    <- s.str

func main():

    bigger = BiggerStruct(
        str = "bigger",
        field = 42
    )

    useSmallerStruct(bigger)

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

    bigger = Bigger(
        arrow = closure,
        field = "bigger"
    )

    useSmaller{bigger}()

Now compiler says that Number of fields does not match

@DieMyst DieMyst added the e2e Run e2e workflow label Aug 17, 2023
@DieMyst DieMyst merged commit 019611a into main Aug 18, 2023
@DieMyst DieMyst deleted the LNG-215-structural-typing branch August 18, 2023 13:15
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.

2 participants