Support error recovery for missing return type

The return type is set to "null" in this case.

Fixes #544.
This commit is contained in:
Nikita Popov 2018-10-25 16:56:50 +02:00
parent 69068722b7
commit 3d0f7843d4
4 changed files with 685 additions and 652 deletions

View File

@ -1,7 +1,9 @@
Version 4.1.1-dev
-----------------
Nothing yet.
### Added
* Support error recovery for missing return type (`function foo() : {}`).
Version 4.1.0 (2018-10-10)
--------------------------

View File

@ -477,6 +477,7 @@ optional_param_type:
optional_return_type:
/* empty */ { $$ = null; }
| ':' type_expr { $$ = $2; }
| ':' error { $$ = null; }
;
argument_list:

File diff suppressed because it is too large Load Diff

View File

@ -1373,4 +1373,31 @@ array(
)
)
)
)
-----
<?php
function foo() :
{
return $a;
}
-----
!!php7
Syntax error, unexpected '{' from 3:1 to 3:1
array(
0: Stmt_Function(
byRef: false
name: Identifier(
name: foo
)
params: array(
)
returnType: null
stmts: array(
0: Stmt_Return(
expr: Expr_Variable(
name: a
)
)
)
)
)