Repository navigation
Conversation
|
|
| Branch | ggiraldez/sdr-resolution-gaps |
| Testbed | ci |
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
🚨 3 Alerts
🐰 View full continuous benchmarking report in Bencher8cef9da to
6174cb8
Compare
6174cb8 to
40c10d5
Compare
40c10d5 to
c4a390b
Compare
c4a390b to
3827d9c
Compare
|
Flipping back to draft. I found additional cases of the mentioned SDR issues that make sense to fix here. |
3827d9c to
e235a85
Compare
teofr
left a comment
There was a problem hiding this comment.
Did a first pass, will continue later
| │ ╰───── ref: 2 | ||
| │ │ | ||
| │ ╰── ref: 4 | ||
| 12 │ a + a; |
There was a problem hiding this comment.
Should we add a ref: entry to the +? And other operators?
There was a problem hiding this comment.
Operators don't generate References so they cannot appear in binder snapshots.
There was a problem hiding this comment.
Makes sense, not for this PR, but I wonder if we should? In situations like this one the operator works almost like any othr function call, and refers to the add method, rather than a builtin.
There was a problem hiding this comment.
We can't do that without a sizeable refactor. References can currently only point to Identifiers. What we can do is use the AST's resolve_operator_to_function and only report the resolved operator in the binder report. That will still require some work, but it's doable.
| ir::StateVariableVisibility::Public | ||
| ) | ||
| } | ||
| _ => true, |
There was a problem hiding this comment.
I was randomly asking questions to claude about the pr, and it brought up that this may be wrong (I know, not part of this PR, but I think is relevant to these diagnostics). It suggests changing this to _ => false, this doesn't play nicely with other parts of our codebase, but may be worth a check (even in another PR).
This test fails in solc with error 9582 but it's accepted on slang
// SPDX-License-Identifier: MIT
pragma solidity *;
contract C {
struct S {
uint256 a;
}
function g() public view {
this.S;
}
}There was a problem hiding this comment.
That's probably true for p5 (ie. in an expression resolution context), but this function is also used for general qualified scope lookup (eg. for types/events/errors/etc) and in that case, it's not cut and dried. In fact, your previous question about event visibility from 0.8.21 onwards is one such case. I'll add it to my TODO list for later.
e235a85 to
c8d44d2
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c8d44d2 to
375332b
Compare
teofr
left a comment
There was a problem hiding this comment.
Looks good, just some questions and nits, but up to you
| /// Whether a member of a contract or interface can be reached through its | ||
| /// name from outside the contract's hierarchy: types, errors and | ||
| /// externally visible functions can, events only from 0.8.21, and | ||
| /// variables and internal functions never. |
There was a problem hiding this comment.
| /// variables and internal functions never. | |
| /// variables, modifiers, and internal functions never. |
| } else if let Some(member) = self.unreachable_qualified_member(identifier_path) { | ||
| self.binder | ||
| .fixup_reference(member.id(), Resolution::Unresolved); | ||
| let kind = namespace_member_not_found(identifier_path, identifier_path.len() - 1); | ||
| self.push_diagnostic(member, kind); |
There was a problem hiding this comment.
I'm not the biggest fan of this fixup, I wonder if we could make resolve_identifier_path_as_expression_in_scope do all the work. However, I don't have a stron idea on how to approach it, so I'd leave it for now. If you have any ideas or a strong reason why this should behave this way I'm interested in hearing it.
There was a problem hiding this comment.
Agreed it's not ideal. I've been thinking that we've outgrown the resolution capabilities of the binder and we're spilling binding policy all over the passes. I would defer it to another PR though.
375332b to
476b5cf
Compare
Closes most of the gaps left for NomicFoundation/slang-diagnostics-research#1473, NomicFoundation/slang-diagnostics-research#1686, NomicFoundation/slang-diagnostics-research#1750 and NomicFoundation/slang-diagnostics-research#1751, found by running each issue's listed solc tests through slang. The issues can be closed after merging both this PR and #2326.
Closes #2338
A library's external functions are no longer visible by bare name inside the library.
superskips unimplemented functions, so it reaches the next implemented base or reports the member as missing. Through the name of a contract or interface the code doesn't derive from, only its types, errors and externally visible functions are reachable (and events from 0.8.21). This applies to member access, emit paths and storage layout expressions, and emit/revert targets are now resolved inp5to keep that logic in one pass. A function attached withusingonly as an operator is no longer callable as a member. Binding a receiver to an attached function now checks data locations: by the internal or ABI rules depending on the function's visibility, and a storage parameter always needs a storage receiver.There's a remaining case for
.selectoron a ternary of library functions, eg.(cond ? L.f : L.f).selector, which needs a separate function-type redesign.