Parse_unary_postfix_expression shouldn't accept the token (i.e. advance to the next) if it's not processed. This caused a mismatch between the reported syntax error and the position where it should have been detected. Fixed.

Added corresponding regression test.
This commit is contained in:
Sei Lisa 2016-01-03 01:20:05 +01:00
parent ceb442e931
commit cfb9dee941
2 changed files with 28 additions and 5 deletions

View file

@ -467,6 +467,17 @@ class Test03_Optimizer(UnitTestCase):
self.assertRaises(EParseAlreadyDefined, self.parser.parse,
'default { timer() {} timer() {} }')
try:
self.parser.parse('default { timer() { return } }')
# should raise EParseSyntax, so it should never get here
self.assertFalse(True)
except EParseSyntax as e:
# should err before first closing brace
self.assertEqual(e.cno, 27)
except:
# should raise no other exception
self.assertFalse(True)
def tearDown(self):
del self.parser
del self.opt