Replies: 5 comments 74 replies
-
|
Sorry, I don't fully understand the details of what you need to achieve vs what the code is doing at the moment. It sounds like the edge case you need to handle can be captured with the help of negation, along the lines of There are more efficient ways to experss this, but this would be the idea. Can you formulate the rule that you'd like to write (or how you'd like to alter the behavior of an existing rule), and I'll try to propose a solution? |
Beta Was this translation helpful? Give feedback.
-
|
The first comment seems correct, with the addition that if |
Beta Was this translation helpful? Give feedback.
-
|
Here's another method that I was trying to suggest from the start: |
Beta Was this translation helpful? Give feedback.
-
|
I've been reading a Systematic Approach to Deriving Incremental Type Checkers and it mentions some things about improving performance within chapter 4, but I'm not really sure how to extrapolate their very specific examples into ddlog with my codebase or even how to understand a lot of it |
Beta Was this translation helpful? Give feedback.
-
|
So, I've investigated further and after finding out that linting a single file of what's still a hefty length, my ddlog code is absurdly fast. I applied the id fusion optimization that combines things like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a follow-up on the Gitter discussion for optimizing rslint's
NoShadowrelationI attempted this, but I run into the edge case of the top-level scope and I'm not entirely sure what to do. The clause I attempted was this
NoShadow(name, (initial_id, initial_span), (shadower_id, shadower_span), false, file) :- // Only do hoisted scopes when hoisting is enabled File(file, _, _, config), config.no_shadow_enabled() and config.no_shadow_hoisting(), // Get the shadowing variable VariableDeclarations(file, name, shadower_scope, Some { shadower_span }, shadower_id, false, false, _), // Make sure the shadower variable is able to be hoisted IsHoistable(shadower_id, file, true), // Get the hoisted scope of the shadowing variable FunctionLevelScope(shadower_scope, hoisted_scope, file, _), // See if a different name is in the scope preceding the hoisted one InputScope(parent_scope, hoisted_scope, file), NameInScope(file, name, parent_scope, initial_id), initial_id != shadower_id, // Get the shadowed variable VariableDeclarations(file, name, _, Some { initial_span }, initial_id, false, _, _), // Make sure the shadowing variable was declared after the initial. // This is counterintuitive, but is needed because of variable hoisting, // since the variable being shadowed occurs *before* the shadowing one initial_span < shadower_span.After thinking about this significantly more, I don't think the rule as a whole is correct, since
FunctionLevelScopeis automatically applied to everything that needs hoisting. However, the remaining three rules miss some test cases and I'm not sure how to go about fixing themNoShadow(name, (initial_id, initial_span), (shadower_id, shadower_span), false, file) :- // Only analyze a file if NoShadow is enabled File(file, _, _, config), config.no_shadow_enabled(), VariableDeclarations(file, name, initial_scope, Some { initial_span }, initial_id, false, true, _), ScopeFamily(initial_scope, child_scope, file), VariableDeclarations(file, name, child_scope, Some { shadower_span }, shadower_id, false, _, _), shadower_id != initial_id and initial_span < shadower_span. NoShadow(name, (initial_id, initial_span), (shadower_id, shadower_span), false, file) :- // Only analyze a file if NoShadow is enabled File(file, _, _, config), config.no_shadow_enabled(), VariableDeclarations(file, name, _, Some { initial_span }, initial_id, false, _, UserDefined { initial_scope }), ScopeFamily(initial_scope, child_scope, file), VariableDeclarations(file, name, child_scope, Some { shadower_span }, shadower_id, false, _, _), shadower_id != initial_id and initial_span < shadower_span. // Hoisted variables NoShadow(name, (initial_id, initial_span), (shadower_id, shadower_span), false, file) :- // Only analyze a file if NoShadow is enabled File(file, _, _, config), config.no_shadow_enabled() and config.no_shadow_hoisting(), VariableDeclarations(file, name, initial_scope, Some { initial_span }, initial_id, false, false, _), VariableDeclarations(file, name, initial_scope, Some { shadower_span }, shadower_id, false, _, _), shadower_id != initial_id and initial_span > shadower_span.These three rules (that all need optimization themselves to eliminate the
ScopeFamilylookups) miss the following test casesThe code is all located here
Beta Was this translation helpful? Give feedback.
All reactions