JSAbrahams / mamba

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

Check assigned to in if and match branches #451

Closed JSAbrahams closed 1 year ago

JSAbrahams commented 1 year ago

Relevant issues

In future we can perhaps use this logic to also de-nullify types (i.e. Str? -> Str) as we move towards implementing type refinement

Summary

If we assign to a variable of a class in all possible execution paths of the constructor, we consider it to be assigned to.

Environment intersection and union functions only perform operations on the "must be assigned to" set. All other items in the Environment are left untouched. That is because

Added Tests

Happy

Sad

codecov[bot] commented 1 year ago

Codecov Report

Merging #451 (4e2af79) into develop (423f6ce) will increase coverage by 0.01%. The diff coverage is 91.11%.

@@             Coverage Diff             @@
##           develop     #451      +/-   ##
===========================================
+ Coverage    88.19%   88.20%   +0.01%     
===========================================
  Files          105      105              
  Lines        11476    11501      +25     
===========================================
+ Hits         10121    10145      +24     
- Misses        1355     1356       +1     
Impacted Files Coverage Δ
src/parse/ast/node.rs 81.00% <0.00%> (-0.17%) :arrow_down:
src/check/constrain/generate/control_flow.rs 91.39% <92.85%> (-0.74%) :arrow_down:
src/check/constrain/generate/definition.rs 90.62% <100.00%> (+0.56%) :arrow_up:
src/check/constrain/generate/env.rs 98.97% <100.00%> (+0.26%) :arrow_up:
src/check/ast/mod.rs 68.22% <0.00%> (+0.93%) :arrow_up: