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

Implement semantic analysis #78

Open
Dandigit opened this issue Jul 8, 2020 · 0 comments
Open

Implement semantic analysis #78

Dandigit opened this issue Jul 8, 2020 · 0 comments

Comments

@Dandigit
Copy link
Member

Dandigit commented Jul 8, 2020

The old analyser module needs to go, particularly given the significant language changes that have occurred. I did start working on a sema module; I intend to pick up where I left off with that.

One pass over the AST (as was conducted by analyser) will not suffice. The minimum number of passes I think are reasonable is somewhere around 3, which is unfortunate but necessary.

  • Collect impl blocks and associate them with structs
  • Declare all variables and types in the symbol table
  • Attempt to associate all symbols with a value

This should allow for declarations in any order. I'm considering experimenting with bidirectional type checking, so that generics are a bit more elegant. Consider:

func cast(x $From) $To => x as $To;
func takesAnInt(x int) int => x;

// Without bidirectional type checking
takesAnInt(cast(2.5) as int);

// With bidirectional type checking
takesAnInt(cast(2.5));
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