Skip to content

Releases: JSAbrahams/mamba

Dictionaries

21 Jan 13:44
Compare
Choose a tag to compare

Language Features

  • Add parsing and checking of dictionary (builders) (#438 )
  • Index uses __getitem__ magic method (#438)
  • Annotate collections with their type (#437)
  • Change String to Str (#435)
  • Allow arm conditions without identifier in handle (#423)

Bug Fixes

  • Verify that types actually exist (#429)
  • Can again infer type of an if expression (#367)
  • Don't generate ternary expression if it contains raises (#420)

Internal

  • Improve shadowing and branching logic in generate stage (#430)
  • Implement fully generics in checker internally (#439)
    • Not fully supported yet in definitions, however (#443)

Error Handling

28 Dec 21:59
Compare
Choose a tag to compare
  • Exceptions in handle arms used when checking #382
  • Variables declared in match arm conditions usable in match arm bodies #382
  • Create dummy classes in Context for import statements #379
  • Allow comments in source without issue by filtering them out in parse stage #381
  • Don't allow return outside functions #390
  • isa now properly expects an identifier, which identifies a class #391
  • Expression type of match propagated to arms #397
  • Types of equality don't need to be the same #399

Match and If Expressions

21 Dec 19:11
63cc218
Compare
Choose a tag to compare
  • Add if expressions, which are converted to Python ternary expressions
  • Allow match expressions (i.e. match to be treated as an expression)
  • For both if and match expressions:
    • Convert expressions in if and match arms to return in function if necessary
    • Propagate assign to variable inwards into arms if necessary
  • Check stage checks if body of function was empty
  • Interfaces specify that they are ABC in Python (Abstract Base Class)
  • None is treated as a special class, not as a special keyword

Match Statements

08 Jun 09:57
Compare
Choose a tag to compare
  • Make use of match statements in output source from Python 3.10.
  • Use new assign tokens: +=, -=, *=, /=, ^=, <<=, >>=
  • Change not equal token: /= -> !=
  • Add check that self fields can only be used if assigned to first.
  • Improve readability of some error messages.
  • Start annotating output, though currently annotations are inconsistent.
  • Checker can deal with chains of calls a.b.c....
  • Simplify grammar such that classes, type definitions, and imports can be placed in any block.
    The checker does not yet have logic to deal with such situations, however.

Range and Slice

18 May 08:41
Compare
Choose a tag to compare
  • Add Range and Slice to the language
    • A range is an expression, may be iterated over, and has the following notation: expression ( .. | ..= ) expression [ .. expression]
    • A slice is an expression, and has the following notation: expression ( :: | ::= ) expression [ :: expression ]
      Note that unlike Python, we use :: instead of : to separate single arguments to the slice.
  • Can iterate over all types which implement an iterator
  • Fix several bugs associated with constraining function call arguments with expressions and property calls

Tuples

08 May 15:51
Compare
Choose a tag to compare

v0.3.1 has been been published as a crate.

Changes

  • Assign to tuples
  • Allow tuple as top-level class construct
  • Type check tuples
  • Remove private token from language

Constraint generation, substitution, and unification

03 Mar 20:03
ff59766
Compare
Choose a tag to compare
  • Use new constraint substitution and unification algorithm for type inference
  • Check that statement raises exception that it mentions

A few language features have been removed, these will be re-added as time goes along:

  • Iterating over Tuples
  • Mutable fields within tuples
  • Nested function calls
  • Mutability checks

Remove retry and function default arguments

05 Jan 13:34
3065bcd
Compare
Choose a tag to compare
  • Parse docstrings (without checking if they are in the correct location)
  • Remove retry keyword from the language
  • Allow passing of default arguments to functions
  • Identify constructors in AST and desugar function call identifier as a class name if indeed constructor

Type check f-strings

03 Dec 13:43
0741180
Compare
Choose a tag to compare
  • Type check expressions within f-strings
  • Fix parsing of tuples
    • Allow mutable fields within tuples
    • Fields within tuples are class fields if the tuple is a top-level declaration in a class
  • Disallow access to private fields and functions from outside a class

Basic Type Checker

20 Nov 13:49
1ae4d16
Compare
Choose a tag to compare

We have a first basic version of the type checker:

  • Remove ?or from language, which is almost identical to ?
  • Build Contexts and Environments
  • Add simple analysis of project Python files and add these to the typing context
  • Check mutability of variables
  • Do very simple type checking (in future we should use constraint type checking)
  • Add desugaring of inline calls to super and inline constructor arguments
  • Add types to variables and functions where necessary
  • Check whether a type is iterable by checking that it defines an __iter()__ method
  • Implement null safety, with undefined representing null, or None in Python. This is done in a similar fashion to Kotlin, and is baked into the type checker. We opted to not use an Optional type solution, as this makes code slightly too verbose for our purposes

Note we have used the nightly TryFrom feature of Rust. So to build the project, you need the nightly version of Rustc.