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

Infer function types at compile time (or semantic-time currently) #30

Open
elimirks opened this issue Sep 2, 2021 · 0 comments
Open

Comments

@elimirks
Copy link
Member

elimirks commented Sep 2, 2021

To compile to LLVM or some other bytecode, we'll have to improve our inference.

For example:

def add(a, b):
  return (x): str(x) + "," + str(a + b)

x = add(3, 7)

y = x("hi")
# Generate def add(a: int, b: int) -> (str -> str):
z = x(3.14)
# Generate def add(a: int, b: int) -> (float -> str):

In the case where a function type cannot be inferred, it's considered a no-op.

e.g.

x = add(3,7)

This expression alone doesn't do anything, because the function returned by add and assigned to x is never used.

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

1 participant