NomicFoundation / slang

Solidity compiler tooling by @NomicFoundation
https://nomicfoundation.github.io/slang/
MIT License
242 stars 19 forks source link

Solidity binding fixes driven by Sanctuary #1149

Open ggiraldez opened 1 week ago

ggiraldez commented 1 week ago

This PR contains fixes to bindings for issues that were found by trying to resolve all references in Sanctuary, as well as test cases to verify them. It also improves documentation of the rules and improvements (renames and rearrangements) for readability. The built-in types are also standardized with a PascalCase naming convention.

Most notably, it introduces extension scopes to support resolving attached function set via using directives. These extension scopes need to be accessible at any point during the resolution of a symbol stack if the originating reference is located in a lexical scope which is affected by a using directive. This forced a refactor of the lexical scope node structure, introducing a new .extended_scope available in nodes where references may need to resolve to attached functions (ie. function bodies, constant initialization expressions, etc.) Also, for Solidity < 0.7.0 using directives are inherited, so we need to propagate the new extension scopes for all sub-contracts relative to where the directive is located.

The extension scope mechanism is implemented using the jump to scope and scope stack features of the stack graphs. The extended scope would optionally push the extension scope for the current contract and then continue resolution through the normal lexical scope. This effectively doubles the search space in the graph when performing a resolution, and this happens every time we inject a new extension scope to the scope stack. This has the potential to exponentially increase the running times and memory requirements. This is a known caveat which will be addressed in a future PR.

changeset-bot[bot] commented 1 week ago

⚠️ No Changeset found

Latest commit: a865d10fafb7a96b59996a7517ab186202a95d67

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

ggiraldez commented 5 days ago

Re-running the tests against Sanctuary I noticed some things broke with the last few changes. Expect a couple more commits added to this PR.