Permalink
Browse files

Add location info to the 'redirect of assignment' error.

  • Loading branch information...
Andy Chu
Andy Chu committed Oct 18, 2017
1 parent de4b702 commit b900561364a315ee739b115727b14aeb4d1c2bac
Showing with 6 additions and 4 deletions.
  1. +1 −1 core/ui.py
  2. +4 −3 osh/cmd_parse.py
  3. +1 −0 osh/cmd_parse_test.py
View
@@ -91,7 +91,7 @@ def MakeStatusLines():
def PrettyPrintError(parse_error, arena, f):
#print(parse_error)
if parse_error.span_id:
if parse_error.span_id is not None:
span_id = parse_error.span_id
elif parse_error.token:
span_id = parse_error.token.span_id
View
@@ -592,9 +592,10 @@ def ParseSimpleCommand(self):
if not suffix_words: # ONE=1 TWO=2 (with no other words)
if redirects:
# TODO: redirect ops should have a token with location info instead of
# an op_id.
self.AddErrorContext('Got redirects in global assignment')
binding1 = prefix_bindings[0]
_, _, _, spid = binding1
self.AddErrorContext('Got redirects in global assignment',
span_id=spid)
return None
pairs = []
View
@@ -1254,6 +1254,7 @@ def testArraySyntax(self):
def testRedirectsInAssignment(self):
err = _assertParseCommandListError(self, 'x=1 >/dev/null')
err = _assertParseCommandListError(self, 'echo hi; x=1 >/dev/null')
err = _assertParseCommandListError(self, 'declare x=1 >/dev/null')
def testEofInDoubleQuoted(self):

0 comments on commit b900561

Please sign in to comment.