-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Parser support for explicit storage locations #15463
base: develop
Are you sure you want to change the base?
Conversation
42172bc
to
a632251
Compare
libsolidity/ast/AST.h
Outdated
@@ -591,6 +593,7 @@ class ContractDefinition: public Declaration, public StructurallyDocumented, pub | |||
std::vector<ASTPointer<ASTNode>> m_subNodes; | |||
ContractKind m_contractKind; | |||
bool m_abstract{false}; | |||
ASTPointer<Expression> m_storageBaseLocationExpression; |
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.
Should we create a dedicated AST node for it?
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.
We'll likely allow more and more expressions in the future - just packing it into an expression seems fine to me.
We can still promote it to a full AST node, once we add more complex layout specifiers.
libsolidity/parsing/Parser.cpp
Outdated
); | ||
|
||
advance(); | ||
return parseExpression(); |
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.
I guess it should be something more specific, because expression will accept anything. Or is it fine?
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.
Yes, I also believe that we should have something more specific. If I recall correctly, it must be a constant expression that can be evaluate at compile-time. So maybe we should have a new parse
function that is restricted to TokenTraits::isArithmeticOp
, Literals and the erc7201
helper only.
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.
I am assuming that we will check those kind of things later (constant, compile-time eval, etc) at type checking phase.
I am worried about parsing something weird (like a function declaration or a nested contract declaration), but I think I should look more closely to the behaviour of parseExpression
to get a better feeling for that.
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.
Parsing arbitrary expressions here and then rejecting complex expressions later (in type checking or even already in syntax checking) seems fine to me.
Might be valuable to quickly confirm that there's no really pathological weird cases that may arise because of it, but I don't anticipate any out of my head.
fef6ff4
to
26bb5e5
Compare
26bb5e5
to
bf640be
Compare
This pull request is stale because it has been open for 14 days with no activity. |
bf640be
to
666b499
Compare
fb75168
to
2579486
Compare
This pull request is stale because it has been open for 14 days with no activity. |
This pull request was closed due to a lack of activity for 7 days after it was stale. |
This pull request is stale because it has been open for 14 days with no activity. |
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.
First step for #597.
Do we have another issue detailing the actual steps? I.e. syntax/parsing (this), type checking/analysis, code gen, docs, etc.?
Otherwise, this particular PR looks good, you seem to have covered all of the edge cases I could think of.
m_errorReporter.parserError( | ||
6668_error, | ||
m_scanner->currentLocation(), | ||
SecondarySourceLocation().append("First inheritance definition is here", baseContracts[0]->location()), |
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 this actually output anywhere? I can't see the secondary source location messages anywhere in the tests (not just for this particular one, but all of them in general).
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.
They appear in the CLI, not sure if they do in the JSON output.
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.
Hmm, weird, I did a bit of grepping around and didn't see any occurrences in the tests, but I might be mistaken.
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.
Yeah, I hadn't added any cmdline tests, so the secondary source location/error message was not showing.
I added two more tests covering this case (inheritance) and the repetead base location definition.
f0f7997
to
2839eed
Compare
I just created #15727 in order to keep track of the tasks. |
7a42733
to
c2d5d9a
Compare
First step for #597.