Skip to content

Commit

Permalink
Handle 'address payable' in file-level definition parser. Introduce r…
Browse files Browse the repository at this point in the history
…elated test case. (#256)
  • Loading branch information
blitz-1306 authored Feb 16, 2024
1 parent 807be60 commit 0b42401
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compile/inference/file_level_definitions.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ ImportDirective =

// ==== Global Constants

// global constants don't support reference types I think?
// Global constants don't support reference types.
// Only other multi-word case is "address payable".
ConstantType =
Identifier (__ LBRACKET Number? RBRACKET)* { return text(); }
(ADDRESS (__ PAYABLE)?) / (Identifier (__ LBRACKET Number? RBRACKET)*) { return text(); }

Constant = ConstantType __ CONSTANT __ name: Identifier __ EQUAL __ value: NonSemicolonSoup __ SEMICOLON {
return { kind: FileLevelNodeKind.Constant, location: location(), name, value } as FLConstant;
Expand Down Expand Up @@ -324,6 +325,8 @@ LBRACKET = "["
RBRACKET = "]"
COMMA = ","
EQUAL = "="
ADDRESS = "address"
PAYABLE = "payable"
ABSTRACT = "abstract"
CONTRACT = "contract"
LIBRARY = "library"
Expand Down
23 changes: 23 additions & 0 deletions test/unit/compile/inference/file_level_definitions_parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,29 @@ is /*3*/ int24/*;*/;`,
anonymous: true
}
]
],
[
"address payable",
`address payable constant MY_CONST = payable(0x0);
event MyEvent(address payable indexed addr);
error MyError(address payable addr);`,
[
{
kind: "constant",
name: "MY_CONST",
value: "payable(0x0)"
},
{
kind: "event",
name: "MyEvent",
args: "(address payable indexed addr)"
},
{
kind: "error",
name: "MyError",
args: "(address payable addr)"
}
]
]
];

Expand Down

0 comments on commit 0b42401

Please sign in to comment.