-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Equality operator allowed for external function types #12470
Equality operator allowed for external function types #12470
Conversation
Looks good so far! Please also experiment a bit with comparing function pointers of non-identical type, i.e. compare view, pure, payable and non-payable function pointers to different function pointers. |
55f04b6
to
b3e1937
Compare
a53a76f
to
0e95c90
Compare
0e95c90
to
36fec51
Compare
36fec51
to
7bac171
Compare
d81ba8c
to
b649685
Compare
test/libsolidity/semanticTests/functionTypes/comparison_operators_for_external_functions.sol
Outdated
Show resolved
Hide resolved
18716ad
to
e24938c
Compare
As far as I can see, this mainly needs better tests now. |
33492fe
to
b993d90
Compare
test/libsolidity/semanticTests/functionTypes/comparison_operators_for_external_functions.sol
Outdated
Show resolved
Hide resolved
1efb3eb
to
649d3bc
Compare
6ada351
to
7951581
Compare
The antlr grammar test failure is probably actually a bug in the antlr grammar - maybe I'll take a look at that myself tomorrow to fix it. The rest of the test failures as far as I can see are due to a mismatching source location for one of the errors, so running |
7951581
to
4c51526
Compare
4c51526
to
1b1fa8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#12545 is merged, so this can be rebased.
.../semanticTests/functionTypes/comparison_operator_for_external_function_cleans_dirty_bits.sol
Show resolved
Hide resolved
17c444e
to
e7f48cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but we should still add, resp. add back, some assertions about the stack size of the types in both old and new code generation. (i.e. #12470 (comment) and #12470 (comment))
expr = m_utils.externalFunctionPointersEqualFunction() + | ||
"(" + | ||
IRVariable{_binOp.leftExpression()}.part("address").name() + "," + | ||
IRVariable{_binOp.leftExpression()}.part("functionSelector").name() + "," + | ||
IRVariable{_binOp.rightExpression()}.part("address").name() + "," + | ||
IRVariable{_binOp.rightExpression()}.part("functionSelector").name() + | ||
")"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this once more, it may also have been nice to build this as
expr = m_utils.externalFunctionPointersEqualFunction() + | |
"(" + | |
IRVariable{_binOp.leftExpression()}.part("address").name() + "," + | |
IRVariable{_binOp.leftExpression()}.part("functionSelector").name() + "," + | |
IRVariable{_binOp.rightExpression()}.part("address").name() + "," + | |
IRVariable{_binOp.rightExpression()}.part("functionSelector").name() + | |
")"; | |
expr = m_utils.externalFunctionPointersEqualFunction(functionType) + | |
"(" + | |
IRVariable{_binOp.leftExpression()}.commaSeparatedList() + | |
"," + | |
IRVariable{_binOp.rightExpression()}.commaSeparatedList() + | |
")"; |
and then have externalFunctionPointersEqualFunction
assert that the function type has only two stack slots...
But I'd say we can keep things like they are for now and change this, if we ever want to compare multi-slot function types (with additional gas slots, etc. - which I'm not sure we will, since it's probably not particularly useful).
So instead a simple assertion for the type having sizeOnStack() == 2
will also be fine.
d1139ba
to
ab93ce6
Compare
ab93ce6
to
0494cc3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Yul codegen part, we could probably have spent some more time unifying this with the other cases (e.g. args
is unused in the function type path now - we might have defined auxiliary variables containing cleaned up values in all cases and then defined a tuple comparison function as util function instead of the specialized external function pointer comparison function)...
But at a quick glance I see that that would require some more refactoring of the IRVariable
mechanism, so I'd say we stay with the current solution for now :-).
91820b0
to
13f692e
Compare
13f692e
to
a0d6c11
Compare
Closes #12411