-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add global variable mapping and preserve primitives #416
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #416 +/- ##
===========================================
- Coverage 88.43% 88.33% -0.11%
===========================================
Files 110 110
Lines 12040 12000 -40
===========================================
- Hits 10648 10600 -48
- Misses 1392 1400 +8
|
Before merging need to document why this works, because the underlying mechanics are starting to become a bit unclear. |
Name
is interchangeable, use instead
a63c40a
to
14af09b
Compare
Something went wrong after rebase on develop. |
It seems that we are now also accidentally allowing any argument, regardless of type, to be passed to functions. |
617d51a
to
bb088a5
Compare
Must investigate significant drop in coverage first. One thing which I'm not sure about is what if we shadow a variable with another one of a different type.
In each test, make sure that we call methods only of that specific class. |
Name
is interchangeable, use insteadThis means that old unions are preserved. However, this doesn't quite explain to me why we get rid of the unnecessary unions. One would expect that we instead get even more unnecessary unions. As of now I can't quite yet explain this change in behaviour, but should be documented once I understand the change in behaviour.
Typically an indication that something somewhere else went wrong. However, an extra failsafe isn't too bad, though it does negatively affect coverage if we fix the problem elsewhere of course, though perhaps we're treating the metric with that line of thought.
By treating all primitives as their type, we are unable to properly substitute. However, does cause some tests to fail which relied on this behaviour: If expressions, however, no longer appear to be typed.
If as a whole is now typed. However, not when used, such as in function body or variable definition.
This is to ensure that the constraints are available outside the if. For instance, when we want to substitute the if with the then branch. We don't use the environment, so we shouldn't have any variable contamination.
We can now create multiple sets which are added to in parallel for diverging paths. The number of active sets is determined by the difference between two internal unsigend numbers.
We do now have cross contamination with variable names. Are not properly shadowed now. Remove drain filter in ConstrBuilder The method using this was used in a very specific context in with. If not reverted, can now compile with stable rust!
If mapping of new var non-existent, add it to mapping.
This takes precedent, meaning that local shadows are used. If not found, then use global. Useful if we have multiple execution paths and later down the line need to perform substitutions.
As opposed to creating a new constraint. When accessing self this should be dealt with using the global variable mapping now.
- Simplify class logic in environment - Add logic for self type in match_id. - Remove logic for adding constraints for any potential field access of self.
- Simplify class logic in environment - Add logic for self type in match_id. - Remove logic for adding constraints for any potential field access of self.
a595763
to
bc0cf86
Compare
Streamlined quite some logic. |
- Ignore type aliases explicitly for now - Remove unnecessary logic in match_id - Do actually shadow self, as self may de defined multiple times in sets inheriting from top-level set.
* If old name is interchangeable, use instead This means that old unions are preserved. However, this doesn't quite explain to me why we get rid of the unnecessary unions. One would expect that we instead get even more unnecessary unions. As of now I can't quite yet explain this change in behaviour, but should be documented once I understand the change in behaviour. * If expr of var declaration empty, ignore Typically an indication that something somewhere else went wrong. However, an extra failsafe isn't too bad, though it does negatively affect coverage if we fix the problem elsewhere of course, though perhaps we're treating the metric with that line of thought. * Fix any_super and is_superset_of in Name * Simplify Expression try_from AST By treating all primitives as their type, we are unable to properly substitute. However, does cause some tests to fail which relied on this behaviour: If expressions, however, no longer appear to be typed. * Split up constraints for if else arms If as a whole is now typed. However, not when used, such as in function body or variable definition. * Also gen then outside if This is to ensure that the constraints are available outside the if. For instance, when we want to substitute the if with the then branch. We don't use the environment, so we shouldn't have any variable contamination. * Constraintbuilder deals with diverging paths We can now create multiple sets which are added to in parallel for diverging paths. The number of active sets is determined by the difference between two internal unsigend numbers. * Remove old constr, prevent contamination We do now have cross contamination with variable names. Are not properly shadowed now. Remove drain filter in ConstrBuilder The method using this was used in a very specific context in with. If not reverted, can now compile with stable rust! * Move variable mapping to constraint builder * Make variable mapping top-level If mapping of new var non-existent, add it to mapping. * Add local variable mapping to environment This takes precedent, meaning that local shadows are used. If not found, then use global. Useful if we have multiple execution paths and later down the line need to perform substitutions. * Fix off-by-one for exit set * Define self when entering class using new system As opposed to creating a new constraint. When accessing self this should be dealt with using the global variable mapping now. * Ignore empty Name in push_ty * Add test for shadowing in script, class, function * Generate constraints for ast without access - Simplify class logic in environment - Add logic for self type in match_id. - Remove logic for adding constraints for any potential field access of self. * Explicitly destroy mapping in Environment * Only define self in functions, not class-level - Ignore type aliases explicitly for now - Remove unnecessary logic in match_id - Do actually shadow self, as self may de defined multiple times in sets inheriting from top-level set. * Use panic to denote bugs in the check stage
Relevant issues
transpile_file_not_src
test flaky on macosx #400We use
output
instead ofok
to check the output ofCommand::main_binary()
Summary
Quite a big PR as we had to change some fundamental behaviour.
More fundamentally how we deal with constraint generation.
Diff slightly larger due to some renaming of variables or consistent change in behaviour, namely how we reference
var_mapping
.Multiple constraint sets
We now change the behaviour of the
ConstrBuilder
such that we always add constraints to multiple sets in parallel.This allows us to generate constraints for all possible execution paths (for instance, after an if or match).
We can then either:
One can use bookmarks (
usize
) so one exits to the correct level at a later stage without knowing how many sets are being added to in parallel.Pushing types
Get rid of unnecessary unions by updating logic of how
push_ty
operates.Whether one has a union of types is determined there and whether any of the
Name
s is interchangeable.Expect
logic which was redundant, which got rid of primitives by directly substituting them.Instead, all constraints should be generated in the generate stage, including those for primitives.
This further simplifies the logic of primitives and makes them more like any other class, which they essentially are (like any good OOP-like language).
is_superset_of
logic inName
.Logic before was erroneous, but not caught due to faulty test.
Tests
Happy
input
function output.Sad