-
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
[WIP] Allow constants access through contract names #3214
Conversation
Thanks, that's a very good start! |
@chriseth What other places do I need to change besides |
@kseo you could add test cases first and see what is not working and/or what was broken by the change and track it down from there |
aeaa6bb
to
2d25b91
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.
At the minimum this needs tests and changelog entry.
Since
The goal here is to ensure that |
This reminds me (it is not strictly related to this PR), but we could add tests for |
b43eaf9
to
dea1ae2
Compare
dea1ae2
to
43636e7
Compare
@chriseth this needs to be reviewed |
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.
Please add a test for
- cross-contract cycle checks
compileAndRun(sourceCode, 0, "Test"); | ||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1456))); | ||
} | ||
|
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.
Are there any other weird cases we have to test? Is it somehow possible to use super
or this
in that context?
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.
Is it possible to access constants via super
? If yes, does that work correctly if that constant is accessed from another contract?
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.
Access via super
is not allowed so far - I think it'd be better to have to use the name of the base explicitly instead. I can change that, though, if you think otherwise. In any case I added a test (for now with the expectation that access through super is not possible).
43636e7
to
69dab20
Compare
@chriseth I added some more test cases, but indeed cross-contract cycle detection does not currently work. Since this PR was not originally planned for 0.4.22, I suggest that I first continue to review the other PRs and then get back to this, unless you definitely want this in the current release. |
dfbc93e
to
a15a1ea
Compare
2290134
to
9012398
Compare
Cross contract cycle detection should work now and this is ready for review. |
Please add a test case for
and check what the value of |
Note that we currently still allow non-compile-time-constant constants - we only add a warning. Because of that I would say this is too dangerous to include in the release. |
Did we test accessing |
fe4cb56
to
6cdd5aa
Compare
I updated the PR to include @chriseth's test (before the latest changes the test contract would cause a fatal compiler error; now the expected value of However:
|
} | ||
contract X is Y { | ||
uint constant a = B.x; | ||
function g() pure returns (uint) { return a; } |
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.
@ekpyron why would you argue it would be reasonable to have this return 2?
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.
@axic I would definitely expect 1
here, but then I might also expect
BOOST_AUTO_TEST_CASE(super) |
to either result in 11 or 13 and not in 15... in that test super traverses the entire inheritance graph of the context from which it is first invoked - if I think about it that way, than I might expect it to prefer
X
's context, even if it occurs in B
...
I would still want the result here to be 1
, but I thought it might be good to discuss this wrt consistency issues anyways.
… dependency check.
…h also finds super contracts in the case of cross contract lookup.
What is the status of this? I am kind of lost. |
@axic The current status of this is "postponed". We could think about re-evaluating this now, though. |
Closing because it got stale and there are still discussions about the underlying feature. |
Fixes #1290.