-
Notifications
You must be signed in to change notification settings - Fork 6.2k
[Sol->Yul] Provide selector for some internal functions. #11015
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
contract B { | ||
function g() public {} | ||
} | ||
contract C is B { | ||
bytes4 constant s2 = B.g.selector; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this exactly the case that already worked before? |
||
function f() external pure returns (bytes4) { return s2; } | ||
} | ||
// ==== | ||
// compileViaYul: also | ||
// ---- | ||
// f() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract B { | ||
function ext() external {} | ||
function pub() public {} | ||
} | ||
|
||
contract C is B { | ||
function test() public returns (bytes4, bytes4, bytes4, bytes4) { | ||
return (B.ext.selector, B.pub.selector, this.ext.selector, pub.selector); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: true | ||
// ---- | ||
// test() -> 0xcf9f23b500000000000000000000000000000000000000000000000000000000, 0x7defb41000000000000000000000000000000000000000000000000000000000, 0xcf9f23b500000000000000000000000000000000000000000000000000000000, 0x7defb41000000000000000000000000000000000000000000000000000000000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract B { | ||
function ext() external {} | ||
function pub() public {} | ||
} | ||
|
||
contract D { | ||
function test() public returns (bytes4, bytes4) { | ||
return (B.ext.selector, B.pub.selector); | ||
} | ||
} | ||
// ==== | ||
// compileViaYul: true | ||
// ---- | ||
// test() -> 0xcf9f23b500000000000000000000000000000000000000000000000000000000, 0x7defb41000000000000000000000000000000000000000000000000000000000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
contract B { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file does not trigger an error when run through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we run IR generator on all syntax tests? That's good to know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acutally we do not. We compile to bytecode, but not via yul. I just tried it and it is kind of stuck in the optimizer :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just ran the IR on all syntax tests and found one unimplemented feature: #11024 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We did that a few weeks ago already (it used to be more like 9 cases or so), so that issue may be a duplicate... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find an equivalent issue. We probably missed that one. this was the CI job https://app.circleci.com/pipelines/github/ethereum/solidity/13394/workflows/42f7aa23-443b-4847-be5e-b37f8af856b3/jobs/621452/tests#failed-test-2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird... I do remember that we were wondering if it actually works and that I noted that it's a bit weird even in old codegen... but maybe we still didn't do anything about it or even file an issue :-). |
||
function ext() external {} | ||
function pub() public {} | ||
} | ||
|
||
contract C is B { | ||
function test() public pure { | ||
B.ext.selector; | ||
B.pub.selector; | ||
this.ext.selector; | ||
pub.selector; | ||
} | ||
} | ||
|
||
contract D { | ||
function test() public pure { | ||
B.ext.selector; | ||
B.pub.selector; | ||
} | ||
} | ||
// ---- | ||
// Warning 6133: (136-150): Statement has no effect. | ||
// Warning 6133: (160-174): Statement has no effect. | ||
// Warning 6133: (184-201): Statement has no effect. | ||
// Warning 6133: (289-303): Statement has no effect. | ||
// Warning 6133: (313-327): Statement has no effect. |
Uh oh!
There was an error while loading. Please reload this page.