mirror of https://github.com/t1meshift/js.git
Fix ghost nodes appearing in AST
Never _ever_ underestimate the power of testing. The previous state of the code was OK iff the only file needs to be parsed.master
parent
5be6f96098
commit
9f0646c6f0
|
@ -586,7 +586,10 @@ class StatementListener(JSBaseListener):
|
|||
class SourceElementListener(JSBaseListener):
|
||||
"""The proxy between Program and Statement."""
|
||||
|
||||
_elems: List[nodes.Statement] = []
|
||||
_elems: List[nodes.Statement]
|
||||
|
||||
def __init__(self):
|
||||
self._elems = []
|
||||
|
||||
@property
|
||||
def source_elements(self) -> List[nodes.Statement]:
|
||||
|
@ -605,9 +608,12 @@ class SourceElementListener(JSBaseListener):
|
|||
class ASTListener(JSBaseListener):
|
||||
"""AST listener."""
|
||||
|
||||
_program_node: Optional[nodes.Program] = None
|
||||
_program_node: Optional[nodes.Program]
|
||||
_source_type: nodes.SourceTypeLiteral
|
||||
|
||||
def __init__(self):
|
||||
self._program_node = None
|
||||
|
||||
@property
|
||||
def program_node(self) -> nodes.Program:
|
||||
"""The `Program` AST node generated after parse tree walking."""
|
||||
|
|
Loading…
Reference in New Issue