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

Solidity binding fixes driven by Sanctuary #1149

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
aa18f14
Add test case which broke with query engine not skipping trivia in on…
ggiraldez Oct 24, 2024
42bfde6
Make using directives inherited in Solidity < 0.7.0
ggiraldez Oct 25, 2024
634b33b
Resolve elementary types in expressions and add their built-ins
ggiraldez Oct 25, 2024
458855c
Bind constants as library members
ggiraldez Oct 25, 2024
bcd0d1f
Propagate dynamic scopes when escaping a contract's lexical scope
ggiraldez Oct 28, 2024
915fbd8
Bind elementary casting and struct construction to the resulting type
ggiraldez Oct 28, 2024
f2ab055
Fix calling parent constructors in constructors
ggiraldez Oct 28, 2024
13cf7e5
Bind arithmetic, logical, bit-wise, comparison, etc. expressions
ggiraldez Oct 29, 2024
5d8c379
Propagate the dynamic scope with resolving contract bases
ggiraldez Oct 29, 2024
ddac849
Define a new scope for internal state variables for derived contracts
ggiraldez Oct 29, 2024
d3032c8
Propagate dynamic scope also from libraries
ggiraldez Oct 29, 2024
a5f3eda
Resolve using dynamic scope from an interface/contract casting
ggiraldez Oct 29, 2024
901501a
Resolve attached functions when applied to namespace qualified types
ggiraldez Oct 30, 2024
1d566b4
Public getters are used as functions, so bind them as such
ggiraldez Oct 30, 2024
a38e8bd
Functions can be called in derived contracts by qualifying with the name
ggiraldez Oct 30, 2024
3aab65d
Add support for binding unnamed function declarations
ggiraldez Oct 30, 2024
9d620d7
Support old `var` declarations
ggiraldez Oct 30, 2024
7daa1f4
Make inherited state vars accessible in all parent contracts
ggiraldez Oct 30, 2024
0d2802f
Normalize value type aliases to bind attached functions correctly
ggiraldez Oct 31, 2024
58ced15
Support binding literal hex addresses
ggiraldez Oct 31, 2024
438cb81
Prior to 0.5.0, `this` could be used as an `address`
ggiraldez Oct 31, 2024
9cbb4fc
Add binding test cases for most of the remaining Sanctuary issues
ggiraldez Nov 1, 2024
28640a4
Make pushing the dynamic scope optional for libraries
ggiraldez Nov 1, 2024
f7655e7
`_slot`/`_offset` suffixes for storage variables in Solidity < 0.7.0
ggiraldez Nov 4, 2024
b3bcf54
Bind to the output of both operands for all arithmetic and bitwise op…
ggiraldez Nov 4, 2024
d6b7174
Bind legacy call options `.value()` and `.gas()` on Solidity < 0.7.0
ggiraldez Nov 4, 2024
5ec110b
Bind user defined types `.wrap()` and `.unwrap()`
ggiraldez Nov 4, 2024
ac13986
Allow binding attached functions on typed casted expressions
ggiraldez Nov 4, 2024
6a560d5
Bind modifiers in libraries
ggiraldez Nov 4, 2024
4df6b54
Bind legacy constructor parent invocations
ggiraldez Nov 4, 2024
6268c9d
Allow qualified access to bind to internal members of parent contract
ggiraldez Nov 4, 2024
d8b5d90
Resolve qualified members in any position in the inheritance chain
ggiraldez Nov 4, 2024
92f5ebc
Support `.selector` field for custom error types
ggiraldez Nov 5, 2024
f798acd
Binding rules: remove @contract.state_vars, rename type_members to ns
ggiraldez Nov 5, 2024
6725fe5
Define `super` and push `using` extensions only when necessary
ggiraldez Nov 5, 2024
ad343ac
Reworked how resolution interacts with `using` directive extensions
ggiraldez Nov 6, 2024
5c4754a
Fix binding state variable initialization value through the extended …
ggiraldez Nov 7, 2024
b027ba5
Allow `using` directives to be inherited in Solidity < 0.7.0
ggiraldez Nov 14, 2024
d0945ef
Fix extension binding for function return parameters
ggiraldez Nov 7, 2024
05c9335
External functions have legacy call options
ggiraldez Nov 7, 2024
172d7a8
Ensure extensions are pushed before resolving `super` and `this`
ggiraldez Nov 7, 2024
0f7ff81
Attempt to simplify contract/interface instance scope
ggiraldez Nov 11, 2024
7aa82df
Remove the generic type resolution for arrays and hard-code built-in …
ggiraldez Nov 12, 2024
172e5ed
Bind user defined type's `wrap` and `unwrap` functions return types
ggiraldez Nov 12, 2024
757111d
Only connect the star extension scope `using for *` when there is one
ggiraldez Nov 12, 2024
aecab6f
Bind array and mappings accesses through public getter functions
ggiraldez Nov 12, 2024
a9f0986
Support attaching functions to mappings with `using`
ggiraldez Nov 12, 2024
54217b2
Clean up and add more documentation to the binding rules
ggiraldez Nov 15, 2024
05d27d6
Use PascalCase for most built-in types
ggiraldez Nov 18, 2024
4579182
Bind members of Yul external variables
ggiraldez Nov 20, 2024
9aab1b3
Fix binding structs as public getter results
ggiraldez Nov 20, 2024
2b3ae36
Rename built-in type for User Defined Value Types
ggiraldez Nov 20, 2024
1163b07
Add names to most parameters of built-in functions
ggiraldez Nov 20, 2024
576ae45
Define a `%this` built-in to use in the context of libraries
ggiraldez Nov 21, 2024
c6b73c6
Bind inherited public getters
ggiraldez Nov 21, 2024
a015082
Fix scope bindings for modifiers in libraries
ggiraldez Nov 22, 2024
fc929d3
Bind attached functions when there's a `using .. for *` in a library
ggiraldez Nov 22, 2024
90a4f26
Allow Yul functions to access external constants
ggiraldez Nov 22, 2024
d5823c0
`this` and `super` don't generate references
ggiraldez Nov 25, 2024
4768079
Refactor elementary types handling in binding rules
ggiraldez Nov 26, 2024
5ed161b
Bind `x_slot` in Solidity <= 0.5.0 to the `slot` built-in
ggiraldez Nov 26, 2024
a6b610c
Add test case with Yul identifiers with dots
ggiraldez Nov 26, 2024
4c19da0
Tweak some parameters of built-in functions
ggiraldez Nov 26, 2024
b62e37e
Merge remote-tracking branch 'upstream/main' into sanctuary-fixes-only
ggiraldez Nov 27, 2024
f6d3113
Update snapshots after merge
ggiraldez Nov 27, 2024
a865d10
Update performance test counts and ignore built-ins in them
ggiraldez Nov 27, 2024
c278a6c
Fix formatting
ggiraldez Nov 27, 2024
9c9193c
Merge remote-tracking branch 'upstream/main' into sanctuary-fixes-only
ggiraldez Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions crates/metaslang/bindings/src/resolver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::iter::once;

use metaslang_cst::kinds::KindTypes;
Expand Down Expand Up @@ -76,19 +76,28 @@ impl<'a, KT: KindTypes + 'static> Resolver<'a, KT> {
)
.expect("should never be cancelled");

let mut added_nodes = HashSet::new();
for reference_path in &reference_paths {
if reference_paths
.iter()
.all(|other| !other.shadows(&mut self.partials, reference_path))
let end_node = reference_path.end_node;

// Because of how we're using the scope stack to propagate dynamic
// scopes, we may get multiple results with different scope stack
// postconditions but reaching the exact same definition. We only
// care about the definition, so we check for uniqueness.
if !added_nodes.contains(&end_node)
&& reference_paths
.iter()
.all(|other| !other.shadows(&mut self.partials, reference_path))
{
self.results.push(ResolvedPath {
definition: self
.owner
.to_definition(reference_path.end_node)
.to_definition(end_node)
.expect("path to end in a definition node"),
partial_path: reference_path.clone(),
score: 0.0,
});
added_nodes.insert(end_node);
}
}
}
Expand Down
Loading
Loading