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

v0.3.5 | Error handling #388

Merged
merged 16 commits into from
Dec 28, 2022
Merged

v0.3.5 | Error handling #388

merged 16 commits into from
Dec 28, 2022

Conversation

JSAbrahams
Copy link
Owner

@JSAbrahams JSAbrahams commented Dec 27, 2022

Relevant issues

Closes milestone 0.3.5 | Error handling.

Executive Summary

JSAbrahams and others added 7 commits December 22, 2022 18:29
* Scan top-level imports and create dummy classes

In future we will need a system to get the actual
signature of these classes as well.
This is a future milestone.

* Add sad test for too many aliases
* Add rule for parsing comments

* Filter out comments in input when parsing

Also remove all references to comments in parser,
check, and generate stages.

* Revert parse_statement default logic

No need to change in this PR.

* Remove parse comment logic from parse_statements
* Generate ids for variables in match arm conds

Match arms treated same way as if arms:
- For each new arm create new constraint set
- Use similar logic to for loop variable
  initialisation.

In future should have way to have some sort of
union between constraints, much like env.
This allows us to type check all possible
execution paths.

* Test undefined variable in match arm
* Update logic for raises in handle

We now check in the generate stage whether a
raise is covered correctly.
Looks like we might not even need it in the
unification stage.

* Add expr type to covered expressions in handle

- Fix generate stage to insert return (and assign)
  in proper locations within try except.

* Check whether parents of exception covered

Which is also valid.

Remove `Raises` `Expect`, which gets rid of a lot
of unnecessary logic in the unification stage.

* Cleanup

* Restore logic for same value of two types

* Move shared logic match, handle to constrain_cases

* Dynamically add raises to Environment

Useful if exceptions in Mamba are not dealt with
locally, but say in the function signature, which
is allowed.

* Add return in nested_exception_check.py

The fact that the test still passed means that
something is going wrong here under the hood.
An issue has been made: #386
* Don't return copy of ConstraintBuilder

Also fix a lot of environment contamination
issues.

* Fix nested exception test

* Fun body must be expr if ret type present

* Uncomment function with stmt body test

* Don't preserve environment in condition

- Remove unnecessary Environment references
- Use variables directly in format! where in files
  from diff as suggested by clippy.
@JSAbrahams JSAbrahams added the enhancement: general General enhancement not relevant to a single module label Dec 27, 2022
@JSAbrahams JSAbrahams added this to the v0.3.5 | Error handling milestone Dec 27, 2022
@JSAbrahams JSAbrahams self-assigned this Dec 27, 2022
@codecov
Copy link

codecov bot commented Dec 27, 2022

Codecov Report

Merging #388 (bd4340e) into main (63cc218) will increase coverage by 0.52%.
The diff coverage is 89.85%.

❗ Current head bd4340e differs from pull request most recent head 2840e7d. Consider uploading reports for the commit 2840e7d to get more accurate results

@@            Coverage Diff             @@
##             main     #388      +/-   ##
==========================================
+ Coverage   87.00%   87.52%   +0.52%     
==========================================
  Files         109      109              
  Lines       11950    12035      +85     
==========================================
+ Hits        10397    10534     +137     
+ Misses       1553     1501      -52     
Impacted Files Coverage Δ
src/check/ast/mod.rs 94.59% <ø> (+0.84%) ⬆️
src/generate/ast/mod.rs 94.51% <ø> (+1.65%) ⬆️
src/generate/ast/node.rs 77.69% <ø> (+0.59%) ⬆️
src/parse/ast/mod.rs 100.00% <ø> (ø)
src/parse/ast/node.rs 83.61% <0.00%> (+3.73%) ⬆️
src/parse/block.rs 100.00% <ø> (ø)
src/check/name/string_name/mod.rs 78.35% <37.50%> (+1.15%) ⬆️
src/check/constrain/unify/mod.rs 62.06% <50.00%> (ø)
src/check/name/true_name/mod.rs 74.75% <50.00%> (ø)
src/generate/convert/mod.rs 93.82% <50.00%> (-0.08%) ⬇️
... and 57 more

@JSAbrahams JSAbrahams marked this pull request as draft December 27, 2022 19:02
@JSAbrahams JSAbrahams changed the title Error Handling Error handling Dec 27, 2022
- Don't allow return outside function
* Isa logic takes class identifier

* Test that isa expects identifier
* [ci skip] Primitives take union of types

- Define input function as part of std

Don't get why primitives_ast_fails.
Somehow the argument types get leaked out.
The class and constructor are properly created so
something is likely going wrong with positional
information.

* Remove unnecessary same value expect logic

This for some reason caused call to primitive
constructors to trip up.

* Proper constraint generation for call sit args

* Define is_digit for string

* Verify call super right way round
@JSAbrahams JSAbrahams changed the title Error handling v0.3.5 | Error handling Dec 28, 2022
Noticed that the error messages looked weird.
Turns out return token is 6 wide not 5.
* [ci skip] Add test assign to nullable class field

* [ci skip] Fix field access constraint generation

However now we have an issue that primitive
comparisons seems to trip up.

Something is up with how we generate constraints
on the fly for field access in conjunction with
function access.

If we flip back the field_ty_exp, then we no
longer get the failed definition_ast_verify test.
It seems that if we fix the issue with the Union,
we get nullability check issues and vice versa.

* Some cleanup

* Substitute also assumes constraints mutable ref

- reinsert also assumes constraint mutable ref
- Improve Position Display
- Improve Constraint Display
- Improve access logic

* [ci skip] Field type super in field access gen

* Add exception that Name may be super of any

This means that in certain situations, a Name is
a superset of another if it is a superset of just
one of the types of other.

For now, this is useful at a function call site
where we generate such constraints on the fly.
There, we only need the current expression to be
super of one.

However, seeing as we only have one use case at
the moment, I'm not sure this logic belongs in
Name itself.
Perhaps this might be useful in future for fixing
other issues.
Issues such as #296 come to mind.

- Unignore certain mutability test.

* Cleanup
* Generate constr for match expression and arm conds

* Do not propagate for handle

- Add factorial test from README
* Don't generate access for equality check

Also inherit constraints when entering class.
Useful if you have defined variables you use
within the class outside the class.

* Add test for equality of different types
* Add tests for files in README

Test readme examples to make sure:
- Language is at the point where we expect it to
  be.
- And that the examples themselves are correct.

This servers as a baseline for current hotfixes.
We will also update the examples in the README
accordingly so that it conforms the current
grammar.

* Rename factorial check file

* Update some README examples

* is a logic excepts class identifier

* [ci skip] is a logic excepts class identifier

Bunch of other small modifications uncovered
while trying to fix the README examples.

* Fix handle test

* Update version numbers in README
@JSAbrahams JSAbrahams marked this pull request as ready for review December 28, 2022 21:14
* Run test, quality, coverage on push to any branch

* Run test on release
@JSAbrahams JSAbrahams merged commit dbeb53e into main Dec 28, 2022
@JSAbrahams JSAbrahams deleted the v-0-3-5 branch December 28, 2022 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: general General enhancement not relevant to a single module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant