Skip to content

Commit

Permalink
bugfix: Gaurd for setting None tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
ypaliy-vdoo committed Nov 28, 2021
1 parent 1877fa0 commit bcffaac
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions luaparser/astnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ def first_token(self) -> Optional[CommonToken]:
return self._first_token

@first_token.setter
def first_token(self, val: CommonToken):
self._first_token = val.clone()
self._first_token.source = CommonToken.EMPTY_SOURCE
def first_token(self, val: Optional[CommonToken]):
if val is not None:
self._first_token = val.clone()
self._first_token.source = CommonToken.EMPTY_SOURCE

@property
def last_token(self) -> Optional[CommonToken]:
Expand All @@ -94,9 +95,10 @@ def last_token(self) -> Optional[CommonToken]:
return self._last_token

@last_token.setter
def last_token(self, val: CommonToken):
self._last_token = val.clone()
self._last_token.source = CommonToken.EMPTY_SOURCE
def last_token(self, val: Optional[CommonToken]):
if val is not None:
self._last_token = val.clone()
self._last_token.source = CommonToken.EMPTY_SOURCE

@property
def start_char(self) -> Optional[int]:
Expand Down

0 comments on commit bcffaac

Please sign in to comment.