expression type check #1

Closed
pca006132 wants to merge 4 commits from pca006132/nac3:expression-type into master
Contributor

Implemented expression type check and limited type inference for type variables.

The error messages are just for debugging, would be modified later to include location and more precise error messages.

The implementation is equivalent to the python implementation in https://git.m-labs.hk/pca006132/nac3-spec/src/branch/master/toy-impl
Tweaks have been made to account for the differences between the AST of python and rustpython parser, lifetime and performance limitation, and fixed some bugs in inference.

  • Self parameter is not included in method argument list.
  • Type enum uses ID for referencing to the type definition, in order to prevent cyclic dependency.
  • Rc is used extensively to deal with lifetime issues, and minimize cloning.

Primitives cannot be made into static const, as Rc cannot be shared across threads safely, and Arc would probably add too much overhead which is not really needed.
One optimization might be to include the primitives in the context object as fields, to reduce overhead and memory usage of initializing many different Rcs containing the same object. Would be implemented later.

Expression and type inference are tested extensively.

Implemented expression type check and limited type inference for type variables. The error messages are just for debugging, would be modified later to include location and more precise error messages. The implementation is equivalent to the python implementation in https://git.m-labs.hk/pca006132/nac3-spec/src/branch/master/toy-impl Tweaks have been made to account for the differences between the AST of python and rustpython parser, lifetime and performance limitation, and fixed some bugs in inference. * Self parameter is not included in method argument list. * Type enum uses ID for referencing to the type definition, in order to prevent cyclic dependency. * Rc is used extensively to deal with lifetime issues, and minimize cloning. Primitives cannot be made into static const, as Rc cannot be shared across threads safely, and Arc would probably add too much overhead which is not really needed. One optimization might be to include the primitives in the context object as fields, to reduce overhead and memory usage of initializing many different `Rc`s containing the same object. Would be implemented later. Expression and type inference are tested extensively.
pca006132 force-pushed expression-type from 98d34e74ef to 50ffded020 2020-12-30 15:35:29 +08:00 Compare
pca006132 added 1 commit 2020-12-30 15:35:58 +08:00
pca006132 added 1 commit 2020-12-30 16:03:16 +08:00
pca006132 added 1 commit 2020-12-30 16:29:29 +08:00
Owner

Looks great!

As discussed parse_ functions in expression.rs should be renamed, and maybe break commits/PR into smaller chunks if possible.

Looks great! As discussed ``parse_`` functions in ``expression.rs`` should be renamed, and maybe break commits/PR into smaller chunks if possible.
pca006132 closed this pull request 2020-12-31 11:32:15 +08:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#1
No description provided.