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

unknown type #36

Closed
4 tasks done
H1ghBre4k3r opened this issue Feb 27, 2023 · 0 comments · Fixed by #40
Closed
4 tasks done

unknown type #36

H1ghBre4k3r opened this issue Feb 27, 2023 · 0 comments · Fixed by #40
Labels
enhancement New feature or request typechecker TypeChecker-related
Milestone

Comments

@H1ghBre4k3r
Copy link
Owner

H1ghBre4k3r commented Feb 27, 2023

Currently, Y support several builtin types:

  • int
  • str
  • bool
  • void

For function parameters, we also support any to declare that a certain function accepts any type of argument. As a "counterpart" for this, an unkown type would be great. unkown should indicate that we do not know what a function returns. This is usefull for syscall abstractions, since they can return a whole lot of different values/types:

declare syscall : (any) -> unkown

One could use any as the return type, but in my opinion, unkown and any are semantically different (as mentioned above) and should be treated like that.

To correctly work with unknown return values, we should allow for type conversion from unkown to every other type (through type annotation : TYPE at a variable definition or as a function return type). Conversions from any other type to unkown should be currently prohobited and throw a type error.

Condition of Satisfaction

  • new type unkown exists
  • unkown can be used as function return type
  • conversion from unkown to any other type work
  • conversion to unknown from any other type throw a TypeError
@H1ghBre4k3r H1ghBre4k3r added enhancement New feature or request typechecker TypeChecker-related labels Feb 27, 2023
@H1ghBre4k3r H1ghBre4k3r added this to the v0.2.0 milestone Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request typechecker TypeChecker-related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant