-
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
Using global #12288
Using global #12288
Conversation
This is the "export using" statement and actually much easier to implement than I thought. |
c71320c
to
fb58f4a
Compare
What about |
2323490
to
67739e9
Compare
67739e9
to
af6dd26
Compare
4ee70a9
to
849e8ed
Compare
980f3ad
to
10e1dbc
Compare
This is ready for review, the name of the keyword is still up for debate. |
Idea for test: It should work even though neither |
Maybe
or something similar to check global and non-global using together? In general this looks good, but may need a few more tests. |
6f3398a
to
1a1ca44
Compare
80052b6
to
2e3394d
Compare
0723c25
to
4794861
Compare
4794861
to
672951c
Compare
If I see it correctly, the |
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 in general apart from the missing json ast part - but I also need another look after a rebase.
AST Json tests need updating. Looking at the rest regardless. |
libsolidity/ast/ASTJsonImporter.cpp
Outdated
@@ -359,7 +359,8 @@ ASTPointer<UsingForDirective> ASTJsonImporter::createUsingForDirective(Json::Val | |||
_node, | |||
move(functions), | |||
!_node.isMember("libraryName"), | |||
_node["typeName"].isNull() ? nullptr : convertJsonToASTNode<TypeName>(_node["typeName"]) | |||
_node["typeName"].isNull() ? nullptr : convertJsonToASTNode<TypeName>(_node["typeName"]), | |||
_node.isMember("global") && _node["global"].asBool() |
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.
_node.isMember("global") && _node["global"].asBool() | |
_node.isMember("global") && memberAsBool(_node, "global") |
?
Or only memberAsBool
or is the idea to default to false
instead of raising an error?
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.
The idea is to default to false.
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.
_node.isMember("global") && memberAsBool(_node, "global")
would still be more graceful I guess, if global
is there and not a boolean, but yeah, fine either way.
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.
Now it won't default to false
anymore, though, will it :-)? But yeah, it also doesn't have to, so also fine.
Just for the sake of completeness, it could have some tests for |
Added the test. |
I'm mainly wondering if we need more tests at this point...
So maybe coverage is already 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.
Looks good to me - should be squashed before merging, though.
Added another semantic test and squashed. |
This comment was marked as spam.
This comment was marked as spam.
…8.13 See ethereum/solidity#12288 It's impossible to specify a newly introduced keyword optionally in the YML spec directly or even as an additional inline parser (`null` definitions are treated as an undefined parser and error out), so this adds versioning to the UsingDirective to add the new `global` contextual keyword.
The alternative syntax for this is
The disadvantage is that you can only have one
using
statement per type and you cannot "mix" e.g. multiple modules, i.e. you cannot doexport using Modulename for MyFloat; export using {f, g, h} for MyFloat;
We can of course change the
using
statement so thatusing {f, M} for MyFloat;
is equivalent tousing f for MyFloat; using M for MyFloat
- currently modules and libraries cannot be used inside the braces.