Permalink
Browse files

Loosen assertion that failed due to a file that ends with #.

Tickled by a freebsd file parsed by 'test/wild.sh all'.
  • Loading branch information...
Andy Chu
Andy Chu committed Jan 25, 2018
1 parent c467c1b commit 995faeafffce01fc5e2b3b3e83b145a3da2b8b26
Showing with 11 additions and 6 deletions.
  1. +1 −0 bin/oil.py
  2. +10 −6 osh/word_parse.py
View
@@ -345,6 +345,7 @@ def OshMain(argv, login_shell):
# TODO: Remove this older form of error handling.
if not node:
err = c_parser.Error()
assert err, err # can't be empty
ui.PrintErrorStack(err, arena, sys.stderr)
return 2 # parse error is code 2
View
@@ -1154,16 +1154,20 @@ def _ReadWord(self, lex_mode):
if self.token_type == Id.Lit_Pound:
self._Next(lex_mode_e.COMMENT)
self._Peek()
assert self.token_type == Id.Ignored_Comment, self.cur_token
# The next iteration will go into Kind.Ignored and set lex state
# to lex_mode_e.OUTER/etc.
# NOTE: The # could be the last character in the file. It can't be
# Eof_{RParen,Backtick} because #) and #` are comments.
assert self.token_type in (Id.Ignored_Comment, Id.Eof_Real), self.cur_token
# The next iteration will go into Kind.Ignored and set lex state to
# lex_mode_e.OUTER/etc.
return None, True # tell Read() to try again after comment
else:
w = self._ReadCompoundWord(lex_mode=lex_mode)
if not w:
self.AddErrorContext('Error reading command word',
token=self.cur_token)
self.AddErrorContext(
'Error reading command word', token=self.cur_token)
return None, False
return w, False
@@ -1206,7 +1210,7 @@ def ReadWord(self, lex_mode):
if not need_more:
break
if not w:
if not w: # Assumes AddErrorContext was already called
return None
self.cursor = w

0 comments on commit 995faea

Please sign in to comment.