solidity
solidity copied to clipboard
Using with operators
Fixes https://github.com/ethereum/solidity/issues/11969
Can you add some more tests for the following cases, please?
using {a.b.f as +} for Int;- you need multiple files for that where you haveimport "b.sol" as b;and so on- using a library function as an operator (not sure if this is allowed, but we should have tests)
using {f as +} for *;using {f as +} for Int;statement inside a contract (instead of at file level) - not sure if it is allowed but we should have testsusing {f as +} for *;statement inside a contract (instead of at file level) - not sure if it is allowed but we should have tests - this is different forfor *at file-level, because we have different rules.
Can you add some more tests for the following cases, please?
using {a.b.f as +} for Int;- you need multiple files for that where you haveimport "b.sol" as b;and so on- using a library function as an operator (not sure if this is allowed, but we should have tests)
using {f as +} for *;using {f as +} for Int;statement inside a contract (instead of at file level) - not sure if it is allowed but we should have testsusing {f as +} for *;statement inside a contract (instead of at file level) - not sure if it is allowed but we should have tests - this is different forfor *at file-level, because we have different rules.
I added all suggested test cases. On using a library function as an operator, I did some small tweaks and it is possible now.
There was an error when running chk_coding_style for commit 308e26e409694b21ad9e219d318164441fa38072:
Error: Trailing whitespace found:
test/libsolidity/syntaxTests/operators/custom/operator_with_calldata_parameters.sol:5:}
Please check that your changes are working as intended.
There was an error when running chk_coding_style for commit 440d1f6c0473e222de8dec29dc865f4b5d071534:
Error: Trailing whitespace found:
test/libsolidity/syntaxTests/operators/custom/implicit_conversion_is_blocked.sol:9:}
test/libsolidity/syntaxTests/operators/custom/implicit_conversion_is_blocked.sol:13:}
test/libsolidity/syntaxTests/operators/custom/implicit_conversion_is_blocked.sol:17:
test/libsolidity/syntaxTests/operators/custom/implicit_conversion_is_blocked.sol:26: }
Please check that your changes are working as intended.
There was an error when running chk_coding_style for commit 1b4b20e9edbc937d67d2cd06bf692cadc6e33dbc:
Error: Trailing whitespace found:
docs/contracts/using-for.rst:25:- a list of assignments of functions to operators (``using {f as +, g as -} for T;``) -
docs/contracts/using-for.rst:170:
docs/contracts/using-for.rst:175:
docs/contracts/using-for.rst:180:
docs/contracts/using-for.rst:185:
Please check that your changes are working as intended.
@wechman Before you finish tomorrow, please squash the PR into a series of atomic commits. After such a big review there are naturally tons of fixups and normally we'd do it just before merge but not sure we'll get to that point in time. If not, I'll probably take over and deal with the remaining comments so having it squashed would be helpful.
This pull request is stale because it has been open for 14 days with no activity.
It will be closed in 7 days unless the stale label is removed.
This PR had 79 commits when I took over. I squashed that into a more manageable number. Most of these original commits were just review fixes and changes that ended up being reverted, which does not help in understanding what happened here.
~In case anyone actually cares about the original commits, I created a branch pointing at the old version: using-operators-backup-2022-09-27 so that we can go back. I don't think that will be useful in practice though.~ EDIT 2022-12-07: I removed the branch but it's original content is back in using-operators and my changes are in a new PR.
There's also a lot of tweaks here that would make sense as small standalone PRs. I'm going to extract them from there and merge separately. #13660 is the first one. Splitting it off reduces the number of files modified here from 180 to ~100.
I have just restored the code here to the state it was in on 2022-09-27, before I took over the PR and pushed any changed to it.
My version diverged enough that I'm opening a new PR for it (#13790) and I'm going to close this one.