Skip to content
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

Handle address payable in imports preprocessing parser #256

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading