11pub use solidity:: SolidityDefinition ;
22
3+ // Conflicting keywords
4+ // - this and super: Before version 0.8.0 they were regular identifiers, from 0.8.0 they still are identifiers, but they
5+ // are not allowed in certain declarations.
6+ // https://docs.soliditylang.org/en/latest/080-breaking-changes.html
7+ // I propose to treat them as identifiers, with a later pass to check that they're not used in invalid places.
8+ // - HexStringLiteral and StringLiteral: before only a single literal was allows, after version 0.5.14 multiple
9+ // literals are allowed. This presents a conflict, i propose only allowing the plural forms, with a later
10+ // pass to check that the singular forms are not used after 0.5.14
11+ // - Disabled when unreserved: These cases have no overlap between being unreserved and being enabled, so it makes no sense
12+ // to treat the unreserved lexeme as a keyword; or, alternatively, the lexer could emit an identifier lexeme instead
13+ // Cases:
14+ // - calldata
15+ // - override
16+ // - unchecked
17+ // - virtual
18+ // - fallback and receive: I think they should be disabled when unreserved, since they werent used as keywords in that range
19+ // Note: Leaving this commented from now, I think this should be enabled from 0.6.0,
20+ // together with the uses of it. Then it'll fall into the category of keywords
21+ // that are only used as keywords while reserved (a lot easier to solve)
22+ // Note: fallback and receive are strange, since they can be used as identifiers in functions
23+ // - a bunch of fixed/ufixed cases: similar to fallback and receive, they should be disabled when unreserved (since they
24+ // were identifiers). This is a bit trickier since they are single definitions within a keyword that has other
25+ // definitions that should be enabled throughout. We should discuss this a bit more.
26+
327language_v2_macros:: compile!( Language (
428 name = Solidity ,
529 root_item = SourceUnit ,
@@ -662,7 +686,7 @@ PragmaDirective: PragmaDirective = {
662686 name = CallDataKeyword ,
663687 enabled = From ( "0.5.0" ) ,
664688 definitions = [ KeywordDefinition (
665- // TODO(v2) removing conflict - calldata unreserved conflicts with identifier in Parameter
689+ // TODO(v2) Check header
666690 // reserved = From("0.5.0"),
667691 value = Atom ( "calldata" )
668692 ) ]
@@ -769,11 +793,7 @@ PragmaDirective: PragmaDirective = {
769793 Keyword (
770794 name = FallbackKeyword ,
771795 definitions = [ KeywordDefinition (
772- // TODO(v2) removing conflict - fallback unreserved before 0.6.0 conflicts with FunctionName
773- // Note: Leaving this commented from now, I think this should be enabled from 0.6.0,
774- // together with the uses of it. Then it'll fall into the category of keywords
775- // that are only used as keywords while reserved (a lot easier to solve)
776-
796+ // TODO(v2) check header
777797 // reserved = From("0.6.0"),
778798 value = Atom ( "fallback" )
779799 ) ]
@@ -894,7 +914,7 @@ PragmaDirective: PragmaDirective = {
894914 ] )
895915 ) ,
896916 KeywordDefinition (
897- // TODO(v2) removing conflict
917+ // TODO(v2) check header
898918 // reserved = From("0.4.14"),
899919 value = Sequence ( [
900920 Atom ( "fixed" ) ,
@@ -958,7 +978,7 @@ PragmaDirective: PragmaDirective = {
958978 ] )
959979 ) ,
960980 KeywordDefinition (
961- // TODO(v2) removing conflict
981+ // TODO(v2) check header
962982 // reserved = From("0.4.14"),
963983 value = Sequence ( [
964984 Atom ( "fixed" ) ,
@@ -1276,7 +1296,7 @@ PragmaDirective: PragmaDirective = {
12761296 name = OverrideKeyword ,
12771297 enabled = From ( "0.6.0" ) ,
12781298 definitions = [ KeywordDefinition (
1279- // TODO(v2) removing conflict - override unreserved before 0.5.0 conflicts with ModifierInvocation
1299+ // TODO(v2) check header
12801300 // reserved = From("0.5.0"),
12811301 value = Atom ( "override" )
12821302 ) ]
@@ -1321,7 +1341,7 @@ PragmaDirective: PragmaDirective = {
13211341 Keyword (
13221342 name = ReceiveKeyword ,
13231343 definitions = [ KeywordDefinition (
1324- // TODO(v2) removing conflict - receive unreserved before 0.6.0 conflicts with FunctionName
1344+ // TODO(v2) check header
13251345 // reserved = From("0.6.0"),
13261346 value = Atom ( "receive" )
13271347 ) ]
@@ -1395,7 +1415,7 @@ PragmaDirective: PragmaDirective = {
13951415 Keyword (
13961416 name = SuperKeyword ,
13971417 definitions = [ KeywordDefinition (
1398- // TODO(v2) this needs manual handling
1418+ // TODO(v2) Check header
13991419 // reserved = From("0.8.0"),
14001420 value = Atom ( "super" )
14011421 ) ]
@@ -1424,7 +1444,7 @@ PragmaDirective: PragmaDirective = {
14241444 Keyword (
14251445 name = ThisKeyword ,
14261446 definitions = [ KeywordDefinition (
1427- // TODO(v2) This needs manual handling
1447+ // TODO(v2) Check header
14281448 // reserved = From("0.8.0"),
14291449 value = Atom ( "this" )
14301450 ) ]
@@ -1568,7 +1588,7 @@ PragmaDirective: PragmaDirective = {
15681588 ] )
15691589 ) ,
15701590 KeywordDefinition (
1571- // TODO(v2) removing conflict
1591+ // TODO(v2) check header
15721592 // reserved = From("0.4.14"),
15731593 value = Sequence ( [
15741594 Atom ( "ufixed" ) ,
@@ -1632,7 +1652,7 @@ PragmaDirective: PragmaDirective = {
16321652 ] )
16331653 ) ,
16341654 KeywordDefinition (
1635- // TODO(v2) removing conflict
1655+ // TODO(v2) check header
16361656 // reserved = From("0.4.14"),
16371657 value = Sequence ( [
16381658 Atom ( "ufixed" ) ,
@@ -1794,7 +1814,7 @@ PragmaDirective: PragmaDirective = {
17941814 name = UncheckedKeyword ,
17951815 enabled = From ( "0.8.0" ) ,
17961816 definitions = [ KeywordDefinition (
1797- // TODO(v2) removing conflict - unchecked unreserved before 0.5.0 conflicts with identifier in UncheckedBlock
1817+ // TODO(v2) check header
17981818 // reserved = From("0.5.0"),
17991819 value = Atom ( "unchecked" )
18001820 ) ]
@@ -1817,7 +1837,7 @@ PragmaDirective: PragmaDirective = {
18171837 name = VirtualKeyword ,
18181838 enabled = From ( "0.6.0" ) ,
18191839 definitions = [ KeywordDefinition (
1820- // TODO(v2) removing conflict - virtual unreserved before 0.6.0 conflicts with ModifierInvocation
1840+ // TODO(v2) check header
18211841 // reserved = From("0.6.0"),
18221842 value = Atom ( "virtual" )
18231843 ) ]
@@ -2141,7 +2161,7 @@ BracedContractMembers: (OpenBrace, ContractMembers, CloseBrace) = {
21412161 reference = FallbackFunctionDefinition ,
21422162 enabled = From ( "0.6.0" )
21432163 ) ,
2144- // TODO(v2) removing conflict - UnnamedFunctionDefinition conflicts with FunctionDefinition
2164+ // TODO(v2) removing conflict - UnnamedFunctionDefinition conflicts with FunctionDefinition
21452165 // EnumVariant(
21462166 // reference = UnnamedFunctionDefinition,
21472167 // enabled = Till("0.6.0")
@@ -2576,7 +2596,7 @@ SpecialStateVariableAttribute: StateVariableAttribute = {
25762596 )
25772597 ]
25782598 ) ,
2579- // TODO(v2) removing conflict - UnnamedFunctionDefinition conflicts with FunctionDefinition
2599+ // TODO(v2) removing conflict - UnnamedFunctionDefinition conflicts with FunctionDefinition
25802600 // Struct(
25812601 // name = UnnamedFunctionDefinition,
25822602 // enabled = Till("0.6.0"),
@@ -4579,7 +4599,7 @@ HexNumberExpression: HexNumberExpression = {
45794599 Enum (
45804600 name = StringExpression ,
45814601 variants = [
4582- // TODO(v2) this conflicts with the one below
4602+ // TODO(v2) this conflicts with the one below
45834603 // EnumVariant(
45844604 // reference = StringLiteral,
45854605 // enabled = Till("0.5.14")
@@ -4588,7 +4608,7 @@ HexNumberExpression: HexNumberExpression = {
45884608 reference = StringLiterals ,
45894609 enabled = From ( "0.5.14" )
45904610 ) ,
4591- // TODO(v2) this conflicts with the one below
4611+ // TODO(v2) this conflicts with the one below
45924612 // EnumVariant(
45934613 // reference = HexStringLiteral,
45944614 // enabled = Till("0.5.14")
0 commit comments