Skip to content

Commit b1b2e29

Browse files
authored
combined updates (#1)
* fix missing ident * support old style fallback function
1 parent 5b0977c commit b1b2e29

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

solidity_parser/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def visitFunctionDefinition(self, ctx: SolidityParser.FunctionDefinitionContext)
181181
elif fd.identifier():
182182
name = fd.identifier().getText()
183183
else:
184-
name = ctx.getText()
184+
name = '' # handle old style fallback function: function(){ ... }
185+
isFallback = True
185186

186187
parameters = self.visit(ctx.parameterList())
187188
returnParameters = self.visit(ctx.returnParameters()) if ctx.returnParameters() else []
@@ -744,9 +745,11 @@ def visitVariableDeclarationList(self, ctx: SolidityParser.VariableDeclarationLi
744745
if decl == None:
745746
return None
746747

748+
ident = decl.identifier()
749+
name = ident and ident.getText() or '_'
747750
result.append(self._createNode(ctx=ctx,
748751
type='VariableDeclaration',
749-
name=decl.identifier().getText(),
752+
name=name,
750753
typeName=self.visit(decl.typeName()),
751754
isStateVar=False,
752755
isIndexed=False,

0 commit comments

Comments
 (0)