JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
88 stars 4 forks source link

Add index language construct #256

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Relevant issues

Closes #251 Closes #252

See #260 for discussion about functionality which could not fully be implemented in this PR.

Summary

Implement indexes for collections. An index may either be:

Dictionaries ignored for now. If they are implemented, then an index may be something other than a slice or integer.

Added Tests

JSAbrahams commented 2 years ago

Actually, slices and indexes should be different language constructs, since Python does treat these slightly differently. This is especially complicated when we want functions to return either a Slice or a Range. If they are the same language construct, then we will run into issues when we have a function returning either. If Mamba has no way to differentiate the two, then both type checking and desugaring will be messy and produce applications with convoluted behavior. Or, Mamba will say an application that appears well typed is not well typed, for instance.

JSAbrahams commented 2 years ago

Probably would've been best to do this in little bits and pieces over multiple PR's (and to start with tests first), but I guess we'll do it like this. I had originally not anticipated that it would be much effort since I did not consider the Slice v Range debacle.

codecov[bot] commented 2 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (develop@73e3f19). Click here to learn what that means. The diff coverage is n/a.

@@            Coverage Diff             @@
##             develop     #256   +/-   ##
==========================================
  Coverage           ?   83.58%           
==========================================
  Files              ?       99           
  Lines              ?     9561           
  Branches           ?        0           
==========================================
  Hits               ?     7992           
  Misses             ?     1569           
  Partials           ?        0           

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more