php-src/tests/lang
Alex Dowad 80598f1250 Syntax errors caused by unclosed {, [, ( mention specific location
Aside from a few very specific syntax errors for which detailed exceptions are
thrown, generally PHP just emits the default error messages generated by bison on syntax
error. These messages are very uninformative; they just say "Unexpected ... at line ...".

This is most problematic with constructs which can span an arbitrary number of lines, such
as blocks of code delimited by { }, 'if' conditions delimited by ( ), and so on. If a closing
delimiter is missed, the block will run for the entire remainder of the source file (which
could be thousands of lines), and then at the end, a parse error will be thrown with the
dreaded words: "Unexpected end of file".

Therefore, track the positions of opening and closing delimiters and ensure that they match
up correctly. If any mismatch or missing delimiter is detected, immediately throw a parse
error which points the user to the offending line. This is best done in the *lexer* and not
in the parser.

Thanks to Nikita Popov and George Peter Banyard for suggesting improvements.

Fixes bug #79368.
Closes GH-5364.
2020-04-14 11:22:23 +02:00
..
constants Use "float" and "integer" in typehint and zpp errors 2014-12-21 13:23:02 +00:00
include_files Use "float" and "integer" in typehint and zpp errors 2014-12-21 13:23:02 +00:00
operators Use serialize_precision for var_dump() 2020-02-25 09:51:32 +01:00
string Sync leading and final newlines in *.phpt sections 2018-10-15 04:33:09 +02:00
001.phpt
002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
003.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
005.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
006.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
007.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
008.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
009.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
010.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
011.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
012.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
013.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
014.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
015.inc Reindent phpt files 2020-02-03 22:52:20 +01:00
015.phpt
016.inc Reindent phpt files 2020-02-03 22:52:20 +01:00
016.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
017.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
018.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
019.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
020.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
021.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
022.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
023-1.inc Reindent phpt files 2020-02-03 22:52:20 +01:00
023-2.inc Remove trailing whitespace in inc files 2018-02-10 19:20:23 +01:00
023.phpt Remove trailing whitespace in inc files 2018-02-10 19:20:23 +01:00
024.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
025.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
026.phpt
027.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
028.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
030.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
032.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
033.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
034.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
035.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
036.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
037.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
038.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
039.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
040.phpt Clean DONE tags from tests 2019-11-07 21:31:47 +01:00
041.phpt Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
042.phpt Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
043.phpt Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
044.phpt Update exception names in tests after formatting changes. 2015-05-17 17:31:43 -05:00
045.phpt Skip test on ZTS build 2016-04-25 14:48:36 +03:00
array_shortcut_001.phpt
array_shortcut_002.phpt
array_shortcut_003.phpt
array_shortcut_005.phpt
bison1.phpt Improve undefined variable error messages 2020-03-31 13:02:32 +02:00
bug7515.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug18872.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug19566.phpt
bug19943.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug20175.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug21094.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug21600.phpt Reclassify E_STRICT notices 2015-04-01 11:17:55 +02:00
bug21669.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug21820.phpt
bug21849.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug21961.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug22231.phpt Remove assignment of new by reference 2015-01-26 21:00:22 +01:00
bug22510.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug22592.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug23279.phpt
bug23384.phpt Remove static calls to non-static methods 2019-01-30 09:19:02 +01:00
bug23489.phpt Deprecate PHP 4 constructors 2015-03-31 17:55:27 +02:00
bug23524.phpt Remove executable permission on phpt 2012-10-10 10:27:49 +08:00
bug23584.phpt Improve undefined variable error messages 2020-03-31 13:02:32 +02:00
bug23624.phpt Fix "forech" statemt behaviour according to https://wiki.php.net/rfc/php7_foreach 2015-02-12 13:57:12 +03:00
bug24054.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug24396.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
bug24436.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug24499.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug24573.phpt Sync leading and final newlines in *.phpt sections 2018-10-15 04:33:09 +02:00
bug24640.phpt Use serialize_precision for var_dump() 2020-02-25 09:51:32 +01:00
bug24652.phpt Remove executable permission on phpt 2012-10-10 10:27:49 +08:00
bug24658.phpt Change argument error message format 2020-02-26 15:00:08 +01:00
bug24783.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug24908.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug24951.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug25145.phpt Remove executable permission on phpt 2012-10-10 10:27:49 +08:00
bug25547.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug25652.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug25922.phpt Improve undefined variable error messages 2020-03-31 13:02:32 +02:00
bug26182.phpt
bug26696.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug26866.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug26869.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug27354.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug27439.phpt Improve error message of foreach 2020-03-09 11:29:40 +01:00
bug27443.phpt
bug27535.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug28213.phpt
bug28800.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug29566.phpt Improve error message of foreach 2020-03-09 11:29:40 +01:00
bug29893.phpt Promote write "use scalar as array" warning to Error 2019-09-27 15:49:18 +02:00
bug29944.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug30578.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
bug30638.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
bug30726.phpt
bug30862.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug32828.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug32924.phpt Replace dirname(__FILE__) by __DIR__ in tests 2019-03-15 22:55:30 +01:00
bug35176.phpt Make error messages more consistent by fixing capitalization 2020-01-17 14:52:46 +01:00
bug35382.phpt Use EXPECT instead of EXPECTF when possible 2018-02-20 21:53:48 +01:00
bug38579.inc Remove executable permission on inc 2012-10-10 10:44:34 +08:00
bug38579.phpt Replace dirname(__FILE__) by __DIR__ in tests 2019-03-15 22:55:30 +01:00
bug43958.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
bug44654.phpt Remove executable permission on phpt 2012-10-10 10:27:49 +08:00
bug44827.phpt Make constant() error handling consistent with plain const lookup 2020-01-10 13:39:56 +01:00
bug45392.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
bug55754.phpt
bug71897.phpt Replace "unexpected character" warning with ParseError 2019-10-04 11:28:58 +02:00
bug73172.inc Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
bug73172.phpt Replace dirname(__FILE__) by __DIR__ in tests 2019-03-15 22:55:30 +01:00
bug73329.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
catchable_error_001.phpt Change argument error message format 2020-02-26 15:00:08 +01:00
catchable_error_002.phpt Change argument error message format 2020-02-26 15:00:08 +01:00
comments2.phpt
comments.phpt
compare_objects_basic1.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
compare_objects_basic2.phpt Clean DONE tags from tests 2019-11-07 21:31:47 +01:00
empty_variation.phpt
engine_assignExecutionOrder_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
engine_assignExecutionOrder_002.phpt Promote write "use scalar as array" warning to Error 2019-09-27 15:49:18 +02:00
engine_assignExecutionOrder_003.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
engine_assignExecutionOrder_004.phpt Restore old evaluation order 2014-08-15 17:10:06 +02:00
engine_assignExecutionOrder_005.phpt
engine_assignExecutionOrder_006.phpt
engine_assignExecutionOrder_007.phpt Trim trailing whitespace in *.phpt 2018-10-14 19:46:15 +02:00
engine_assignExecutionOrder_008.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
engine_assignExecutionOrder_009.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
error_2_exception_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
execution_order.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
foreach_with_object_001.phpt Clean DONE tags from tests 2019-11-07 21:31:47 +01:00
foreach_with_references_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.003.phpt Improve error message of foreach 2020-03-09 11:29:40 +01:00
foreachLoop.004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.005.phpt Fix CRLF line-endings in tests 2016-11-20 22:31:24 +01:00
foreachLoop.006.phpt Fix CRLF line-endings in tests 2016-11-20 22:31:24 +01:00
foreachLoop.009.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.010.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.011.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.012.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.013.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.014.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.015.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.016.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoop.017.phpt Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
foreachLoopIterator.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopIterator.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopIteratorAggregate.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopIteratorAggregate.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopIteratorAggregate.003.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopIteratorAggregate.004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopObjects.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopObjects.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopObjects.003.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopObjects.004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopObjects.005.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
foreachLoopObjects.006.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_get_arg_variation.phpt Promote some warnings to Errors in Zend basic functions 2020-03-31 16:32:58 +02:00
func_get_arg.001.phpt Use "float" and "integer" in typehint and zpp errors 2014-12-21 13:23:02 +00:00
func_get_arg.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_get_arg.003.phpt Promote some warnings to Errors in Zend basic functions 2020-03-31 16:32:58 +02:00
func_get_arg.004.phpt Promote some warnings to Errors in Zend basic functions 2020-03-31 16:32:58 +02:00
func_get_arg.005.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_get_args.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_get_args.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_get_args.003.phpt Promote some warnings to Errors in Zend basic functions 2020-03-31 16:32:58 +02:00
func_get_args.004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_num_args.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_num_args.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
func_num_args.003.phpt Sync leading and final newlines in *.phpt sections 2018-10-15 04:33:09 +02:00
func_num_args.004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
inc_throw.inc
inc.inc
include_variation1.phpt
include_variation2.phpt
include_variation3.phpt Use "float" and "integer" in typehint and zpp errors 2014-12-21 13:23:02 +00:00
invalid_octal.phpt Throw ParseException from lexer 2015-04-02 16:31:17 +02:00
passByReference_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
passByReference_002.phpt Make ASSIGN, ASSIGN_OP, INC and DEC opcodes to return IS_TMP_VAR instead of IS_VAR. 2020-02-07 13:36:52 +03:00
passByReference_003.phpt Improve undefined variable error messages 2020-03-31 13:02:32 +02:00
passByReference_004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
passByReference_005.phpt Improve undefined variable error messages 2020-03-31 13:02:32 +02:00
passByReference_006.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
passByReference_007.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
passByReference_008.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
passByReference_009.phpt Fix #78880: Another bunch of spelling errors 2020-01-16 09:46:47 +01:00
passByReference_010.phpt Make ASSIGN, ASSIGN_OP, INC and DEC opcodes to return IS_TMP_VAR instead of IS_VAR. 2020-02-07 13:36:52 +03:00
passByReference_012.phpt Clean DONE tags from tests 2019-11-07 21:31:47 +01:00
returnByReference.001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.003.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.004.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.005.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.006.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.007.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.008.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
returnByReference.009.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
short_tags.001.phpt
short_tags.002.phpt
short_tags.004.phpt Improve undefined variable error messages 2020-03-31 13:02:32 +02:00
static_basic_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
static_basic_002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
static_variation_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
static_variation_002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
string_decimals_001.phpt Clean DONE tags from tests 2019-11-07 21:31:47 +01:00
syntax_errors.phpt Syntax errors caused by unclosed {, [, ( mention specific location 2020-04-14 11:22:23 +02:00
this_assignment.phpt Clean DONE tags from tests 2019-11-07 21:31:47 +01:00
throw_variation_001.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
type_hints_001.phpt Change argument error message format 2020-02-26 15:00:08 +01:00
type_hints_002.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00
type_hints_003.phpt Reindent phpt files 2020-02-03 22:52:20 +01:00