recovery.test 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. Error recovery
  2. -----
  3. <?php
  4. foo()
  5. bar()
  6. baz()
  7. -----
  8. Syntax error, unexpected T_STRING from 4:1 to 4:3
  9. Syntax error, unexpected T_STRING from 5:1 to 5:3
  10. Syntax error, unexpected EOF from 5:6 to 5:6
  11. array(
  12. 0: Expr_FuncCall(
  13. name: Name(
  14. parts: array(
  15. 0: foo
  16. )
  17. )
  18. args: array(
  19. )
  20. )
  21. 1: Expr_FuncCall(
  22. name: Name(
  23. parts: array(
  24. 0: bar
  25. )
  26. )
  27. args: array(
  28. )
  29. )
  30. 2: Expr_FuncCall(
  31. name: Name(
  32. parts: array(
  33. 0: baz
  34. )
  35. )
  36. args: array(
  37. )
  38. )
  39. )
  40. -----
  41. <?php
  42. foo()
  43. bar();
  44. baz();
  45. -----
  46. Syntax error, unexpected T_STRING from 4:1 to 4:3
  47. array(
  48. 0: Expr_FuncCall(
  49. name: Name(
  50. parts: array(
  51. 0: foo
  52. )
  53. )
  54. args: array(
  55. )
  56. )
  57. 1: Expr_FuncCall(
  58. name: Name(
  59. parts: array(
  60. 0: bar
  61. )
  62. )
  63. args: array(
  64. )
  65. )
  66. 2: Expr_FuncCall(
  67. name: Name(
  68. parts: array(
  69. 0: baz
  70. )
  71. )
  72. args: array(
  73. )
  74. )
  75. )
  76. -----
  77. <?php
  78. foo();
  79. bar()
  80. baz();
  81. -----
  82. Syntax error, unexpected T_STRING from 5:1 to 5:3
  83. array(
  84. 0: Expr_FuncCall(
  85. name: Name(
  86. parts: array(
  87. 0: foo
  88. )
  89. )
  90. args: array(
  91. )
  92. )
  93. 1: Expr_FuncCall(
  94. name: Name(
  95. parts: array(
  96. 0: bar
  97. )
  98. )
  99. args: array(
  100. )
  101. )
  102. 2: Expr_FuncCall(
  103. name: Name(
  104. parts: array(
  105. 0: baz
  106. )
  107. )
  108. args: array(
  109. )
  110. )
  111. )
  112. -----
  113. <?php
  114. abc;
  115. 1 + ;
  116. -----
  117. Syntax error, unexpected ';' from 3:5 to 3:5
  118. array(
  119. 0: Expr_ConstFetch(
  120. name: Name(
  121. parts: array(
  122. 0: abc
  123. )
  124. )
  125. )
  126. 1: Scalar_LNumber(
  127. value: 1
  128. )
  129. )
  130. -----
  131. <?php
  132. function test() {
  133. 1 +
  134. }
  135. -----
  136. Syntax error, unexpected '}' from 4:1 to 4:1
  137. array(
  138. 0: Stmt_Function(
  139. byRef: false
  140. name: test
  141. params: array(
  142. )
  143. returnType: null
  144. stmts: array(
  145. 0: Scalar_LNumber(
  146. value: 1
  147. )
  148. )
  149. )
  150. )
  151. -----
  152. <?php
  153. $i = 0;
  154. while
  155. $j = 1;
  156. $k = 2;
  157. -----
  158. Syntax error, unexpected T_VARIABLE, expecting '(' from 6:1 to 6:2
  159. array(
  160. 0: Expr_Assign(
  161. var: Expr_Variable(
  162. name: i
  163. )
  164. expr: Scalar_LNumber(
  165. value: 0
  166. )
  167. )
  168. 1: Expr_Assign(
  169. var: Expr_Variable(
  170. name: j
  171. )
  172. expr: Scalar_LNumber(
  173. value: 1
  174. )
  175. )
  176. 2: Expr_Assign(
  177. var: Expr_Variable(
  178. name: k
  179. )
  180. expr: Scalar_LNumber(
  181. value: 2
  182. )
  183. )
  184. )
  185. -----
  186. <?php
  187. $i = 0;
  188. while () {
  189. $j = 1;
  190. }
  191. $k = 2;
  192. // The output here drops the loop - would require Error node to handle this
  193. -----
  194. Syntax error, unexpected ')' from 4:8 to 4:8
  195. array(
  196. 0: Expr_Assign(
  197. var: Expr_Variable(
  198. name: i
  199. )
  200. expr: Scalar_LNumber(
  201. value: 0
  202. )
  203. )
  204. 1: Expr_Assign(
  205. var: Expr_Variable(
  206. name: j
  207. )
  208. expr: Scalar_LNumber(
  209. value: 1
  210. )
  211. )
  212. 2: Expr_Assign(
  213. var: Expr_Variable(
  214. name: k
  215. )
  216. expr: Scalar_LNumber(
  217. value: 2
  218. )
  219. )
  220. 3: Stmt_Nop(
  221. comments: array(
  222. 0: // The output here drops the loop - would require Error node to handle this
  223. )
  224. )
  225. )
  226. -----
  227. <?php
  228. // Can't recover this yet, as the '}' for the inner_statement_list
  229. // is always required.
  230. $i = 0;
  231. while (true) {
  232. $i = 1;
  233. $i = 2;
  234. -----
  235. Syntax error, unexpected EOF from 8:12 to 8:12
  236. -----
  237. <?php
  238. $foo->
  239. ;
  240. -----
  241. !!positions
  242. Syntax error, unexpected ';', expecting T_STRING or T_VARIABLE or '{' or '$' from 3:1 to 3:1
  243. array(
  244. 0: Expr_PropertyFetch[2:1 - 2:6](
  245. var: Expr_Variable[2:1 - 2:4](
  246. name: foo
  247. )
  248. name: Expr_Error[3:1 - 2:6](
  249. )
  250. )
  251. )
  252. -----
  253. <?php
  254. function foo() {
  255. $bar->
  256. }
  257. -----
  258. !!positions
  259. Syntax error, unexpected '}', expecting T_STRING or T_VARIABLE or '{' or '$' from 4:1 to 4:1
  260. array(
  261. 0: Stmt_Function[2:1 - 4:1](
  262. byRef: false
  263. name: foo
  264. params: array(
  265. )
  266. returnType: null
  267. stmts: array(
  268. 0: Expr_PropertyFetch[3:5 - 3:10](
  269. var: Expr_Variable[3:5 - 3:8](
  270. name: bar
  271. )
  272. name: Expr_Error[4:1 - 3:10](
  273. )
  274. )
  275. )
  276. )
  277. )
  278. -----
  279. <?php
  280. new T
  281. -----
  282. Syntax error, unexpected EOF from 2:6 to 2:6
  283. array(
  284. 0: Expr_New(
  285. class: Name(
  286. parts: array(
  287. 0: T
  288. )
  289. )
  290. args: array(
  291. )
  292. )
  293. )
  294. -----
  295. <?php
  296. new
  297. -----
  298. !!php7,positions
  299. Syntax error, unexpected EOF from 2:4 to 2:4
  300. array(
  301. 0: Expr_New[2:1 - 2:3](
  302. class: Expr_Error[2:4 - 2:3](
  303. )
  304. args: array(
  305. )
  306. )
  307. )
  308. -----
  309. <?php
  310. $foo instanceof
  311. -----
  312. !!php7
  313. Syntax error, unexpected EOF from 2:16 to 2:16
  314. array(
  315. 0: Expr_Instanceof(
  316. expr: Expr_Variable(
  317. name: foo
  318. )
  319. class: Expr_Error(
  320. )
  321. )
  322. )
  323. -----
  324. <?php
  325. $
  326. -----
  327. !!php7
  328. Syntax error, unexpected EOF, expecting T_VARIABLE or '{' or '$' from 2:2 to 2:2
  329. array(
  330. 0: Expr_Variable(
  331. name: Expr_Error(
  332. )
  333. )
  334. )
  335. -----
  336. <?php
  337. Foo::$
  338. -----
  339. !!php7
  340. Syntax error, unexpected EOF, expecting T_VARIABLE or '{' or '$' from 2:7 to 2:7
  341. array(
  342. 0: Expr_StaticPropertyFetch(
  343. class: Name(
  344. parts: array(
  345. 0: Foo
  346. )
  347. )
  348. name: Expr_Error(
  349. )
  350. )
  351. )
  352. -----
  353. <?php
  354. Foo::
  355. -----
  356. !!php7
  357. Syntax error, unexpected EOF from 2:6 to 2:6
  358. array(
  359. 0: Expr_ClassConstFetch(
  360. class: Name(
  361. parts: array(
  362. 0: Foo
  363. )
  364. )
  365. name: Expr_Error(
  366. )
  367. )
  368. )
  369. -----
  370. <?php
  371. namespace Foo
  372. use A
  373. use function a
  374. use A\{B}
  375. const A = 1
  376. break
  377. break 2
  378. continue
  379. continue 2
  380. return
  381. return 2
  382. echo $a
  383. unset($a)
  384. throw $x
  385. goto label
  386. -----
  387. !!php7
  388. Syntax error, unexpected T_USE, expecting ';' or '{' from 3:1 to 3:3
  389. Syntax error, unexpected T_USE, expecting ';' from 5:1 to 5:3
  390. Syntax error, unexpected T_CONST, expecting ';' from 6:1 to 6:5
  391. Syntax error, unexpected T_BREAK, expecting ';' from 7:1 to 7:5
  392. Syntax error, unexpected T_THROW, expecting ';' from 15:1 to 15:5
  393. array(
  394. 0: Stmt_Namespace(
  395. name: Name(
  396. parts: array(
  397. 0: Foo
  398. )
  399. )
  400. stmts: array(
  401. 0: Stmt_Use(
  402. type: TYPE_NORMAL (1)
  403. uses: array(
  404. 0: Stmt_UseUse(
  405. type: TYPE_UNKNOWN (0)
  406. name: Name(
  407. parts: array(
  408. 0: A
  409. )
  410. )
  411. alias: A
  412. )
  413. )
  414. )
  415. 1: Stmt_Use(
  416. type: TYPE_FUNCTION (2)
  417. uses: array(
  418. 0: Stmt_UseUse(
  419. type: TYPE_UNKNOWN (0)
  420. name: Name(
  421. parts: array(
  422. 0: a
  423. )
  424. )
  425. alias: a
  426. )
  427. )
  428. )
  429. 2: Stmt_GroupUse(
  430. type: TYPE_UNKNOWN (0)
  431. prefix: Name(
  432. parts: array(
  433. 0: A
  434. )
  435. )
  436. uses: array(
  437. 0: Stmt_UseUse(
  438. type: TYPE_NORMAL (1)
  439. name: Name(
  440. parts: array(
  441. 0: B
  442. )
  443. )
  444. alias: B
  445. )
  446. )
  447. )
  448. 3: Stmt_Const(
  449. consts: array(
  450. 0: Const(
  451. name: A
  452. value: Scalar_LNumber(
  453. value: 1
  454. )
  455. )
  456. )
  457. )
  458. 4: Stmt_Break(
  459. num: null
  460. )
  461. 5: Stmt_Break(
  462. num: Scalar_LNumber(
  463. value: 2
  464. )
  465. )
  466. 6: Stmt_Continue(
  467. num: null
  468. )
  469. 7: Stmt_Continue(
  470. num: Scalar_LNumber(
  471. value: 2
  472. )
  473. )
  474. 8: Stmt_Return(
  475. expr: null
  476. )
  477. 9: Stmt_Return(
  478. expr: Scalar_LNumber(
  479. value: 2
  480. )
  481. )
  482. 10: Stmt_Echo(
  483. exprs: array(
  484. 0: Expr_Variable(
  485. name: a
  486. )
  487. )
  488. )
  489. 11: Stmt_Unset(
  490. vars: array(
  491. 0: Expr_Variable(
  492. name: a
  493. )
  494. )
  495. )
  496. 12: Stmt_Throw(
  497. expr: Expr_Variable(
  498. name: x
  499. )
  500. )
  501. 13: Stmt_Goto(
  502. name: label
  503. )
  504. )
  505. )
  506. )
  507. -----
  508. <?php
  509. use A\{B, };
  510. use function A\{b, };
  511. use A, ;
  512. const A = 42, ;
  513. class X implements Y, {
  514. use A, ;
  515. use A, {
  516. A::b insteadof C, ;
  517. }
  518. const A = 42, ;
  519. public $x, ;
  520. }
  521. interface I extends J, {}
  522. unset($x, );
  523. isset($x, );
  524. declare(a=42, );
  525. function foo($a, ) {}
  526. foo($a, );
  527. global $a, ;
  528. static $a, ;
  529. echo $a, ;
  530. for ($a, ; $b, ; $c, );
  531. function ($a, ) use ($b, ) {};
  532. -----
  533. !!php7
  534. A trailing comma is not allowed here from 3:9 to 3:9
  535. A trailing comma is not allowed here from 4:18 to 4:18
  536. A trailing comma is not allowed here from 5:6 to 5:6
  537. A trailing comma is not allowed here from 6:13 to 6:13
  538. A trailing comma is not allowed here from 8:21 to 8:21
  539. A trailing comma is not allowed here from 9:10 to 9:10
  540. A trailing comma is not allowed here from 10:10 to 10:10
  541. A trailing comma is not allowed here from 11:25 to 11:25
  542. A trailing comma is not allowed here from 13:17 to 13:17
  543. A trailing comma is not allowed here from 14:14 to 14:14
  544. A trailing comma is not allowed here from 16:22 to 16:22
  545. A trailing comma is not allowed here from 18:9 to 18:9
  546. A trailing comma is not allowed here from 19:9 to 19:9
  547. A trailing comma is not allowed here from 21:13 to 21:13
  548. A trailing comma is not allowed here from 23:16 to 23:16
  549. A trailing comma is not allowed here from 24:7 to 24:7
  550. A trailing comma is not allowed here from 25:10 to 25:10
  551. A trailing comma is not allowed here from 26:10 to 26:10
  552. A trailing comma is not allowed here from 27:8 to 27:8
  553. A trailing comma is not allowed here from 29:8 to 29:8
  554. A trailing comma is not allowed here from 29:14 to 29:14
  555. A trailing comma is not allowed here from 29:20 to 29:20
  556. A trailing comma is not allowed here from 30:13 to 30:13
  557. A trailing comma is not allowed here from 30:24 to 30:24
  558. array(
  559. 0: Stmt_GroupUse(
  560. type: TYPE_UNKNOWN (0)
  561. prefix: Name(
  562. parts: array(
  563. 0: A
  564. )
  565. )
  566. uses: array(
  567. 0: Stmt_UseUse(
  568. type: TYPE_NORMAL (1)
  569. name: Name(
  570. parts: array(
  571. 0: B
  572. )
  573. )
  574. alias: B
  575. )
  576. )
  577. )
  578. 1: Stmt_GroupUse(
  579. type: TYPE_FUNCTION (2)
  580. prefix: Name(
  581. parts: array(
  582. 0: A
  583. )
  584. )
  585. uses: array(
  586. 0: Stmt_UseUse(
  587. type: TYPE_UNKNOWN (0)
  588. name: Name(
  589. parts: array(
  590. 0: b
  591. )
  592. )
  593. alias: b
  594. )
  595. )
  596. )
  597. 2: Stmt_Use(
  598. type: TYPE_NORMAL (1)
  599. uses: array(
  600. 0: Stmt_UseUse(
  601. type: TYPE_UNKNOWN (0)
  602. name: Name(
  603. parts: array(
  604. 0: A
  605. )
  606. )
  607. alias: A
  608. )
  609. )
  610. )
  611. 3: Stmt_Const(
  612. consts: array(
  613. 0: Const(
  614. name: A
  615. value: Scalar_LNumber(
  616. value: 42
  617. )
  618. )
  619. )
  620. )
  621. 4: Stmt_Class(
  622. flags: 0
  623. name: X
  624. extends: null
  625. implements: array(
  626. 0: Name(
  627. parts: array(
  628. 0: Y
  629. )
  630. )
  631. )
  632. stmts: array(
  633. 0: Stmt_TraitUse(
  634. traits: array(
  635. 0: Name(
  636. parts: array(
  637. 0: A
  638. )
  639. )
  640. )
  641. adaptations: array(
  642. )
  643. )
  644. 1: Stmt_TraitUse(
  645. traits: array(
  646. 0: Name(
  647. parts: array(
  648. 0: A
  649. )
  650. )
  651. )
  652. adaptations: array(
  653. 0: Stmt_TraitUseAdaptation_Precedence(
  654. trait: Name(
  655. parts: array(
  656. 0: A
  657. )
  658. )
  659. method: b
  660. insteadof: array(
  661. 0: Name(
  662. parts: array(
  663. 0: C
  664. )
  665. )
  666. )
  667. )
  668. )
  669. )
  670. 2: Stmt_ClassConst(
  671. flags: 0
  672. consts: array(
  673. 0: Const(
  674. name: A
  675. value: Scalar_LNumber(
  676. value: 42
  677. )
  678. )
  679. )
  680. )
  681. 3: Stmt_Property(
  682. flags: MODIFIER_PUBLIC (1)
  683. props: array(
  684. 0: Stmt_PropertyProperty(
  685. name: x
  686. default: null
  687. )
  688. )
  689. )
  690. )
  691. )
  692. 5: Stmt_Interface(
  693. name: I
  694. extends: array(
  695. 0: Name(
  696. parts: array(
  697. 0: J
  698. )
  699. )
  700. )
  701. stmts: array(
  702. )
  703. )
  704. 6: Stmt_Unset(
  705. vars: array(
  706. 0: Expr_Variable(
  707. name: x
  708. )
  709. )
  710. )
  711. 7: Expr_Isset(
  712. vars: array(
  713. 0: Expr_Variable(
  714. name: x
  715. )
  716. )
  717. )
  718. 8: Stmt_Declare(
  719. declares: array(
  720. 0: Stmt_DeclareDeclare(
  721. key: a
  722. value: Scalar_LNumber(
  723. value: 42
  724. )
  725. )
  726. )
  727. stmts: null
  728. )
  729. 9: Stmt_Function(
  730. byRef: false
  731. name: foo
  732. params: array(
  733. 0: Param(
  734. type: null
  735. byRef: false
  736. variadic: false
  737. name: a
  738. default: null
  739. )
  740. )
  741. returnType: null
  742. stmts: array(
  743. )
  744. )
  745. 10: Expr_FuncCall(
  746. name: Name(
  747. parts: array(
  748. 0: foo
  749. )
  750. )
  751. args: array(
  752. 0: Arg(
  753. value: Expr_Variable(
  754. name: a
  755. )
  756. byRef: false
  757. unpack: false
  758. )
  759. )
  760. )
  761. 11: Stmt_Global(
  762. vars: array(
  763. 0: Expr_Variable(
  764. name: a
  765. )
  766. )
  767. )
  768. 12: Stmt_Static(
  769. vars: array(
  770. 0: Stmt_StaticVar(
  771. name: a
  772. default: null
  773. )
  774. )
  775. )
  776. 13: Stmt_Echo(
  777. exprs: array(
  778. 0: Expr_Variable(
  779. name: a
  780. )
  781. )
  782. )
  783. 14: Stmt_For(
  784. init: array(
  785. 0: Expr_Variable(
  786. name: a
  787. )
  788. )
  789. cond: array(
  790. 0: Expr_Variable(
  791. name: b
  792. )
  793. )
  794. loop: array(
  795. 0: Expr_Variable(
  796. name: c
  797. )
  798. )
  799. stmts: array(
  800. )
  801. )
  802. 15: Expr_Closure(
  803. static: false
  804. byRef: false
  805. params: array(
  806. 0: Param(
  807. type: null
  808. byRef: false
  809. variadic: false
  810. name: a
  811. default: null
  812. )
  813. )
  814. uses: array(
  815. 0: Expr_ClosureUse(
  816. var: b
  817. byRef: false
  818. )
  819. )
  820. returnType: null
  821. stmts: array(
  822. )
  823. )
  824. )
  825. -----
  826. <?php
  827. foo(Bar::);
  828. -----
  829. !!php7,positions
  830. Syntax error, unexpected ')' from 3:10 to 3:10
  831. array(
  832. 0: Expr_FuncCall[3:1 - 3:10](
  833. name: Name[3:1 - 3:3](
  834. parts: array(
  835. 0: foo
  836. )
  837. )
  838. args: array(
  839. 0: Arg[3:5 - 3:9](
  840. value: Expr_ClassConstFetch[3:5 - 3:9](
  841. class: Name[3:5 - 3:7](
  842. parts: array(
  843. 0: Bar
  844. )
  845. )
  846. name: Expr_Error[3:10 - 3:9](
  847. )
  848. )
  849. byRef: false
  850. unpack: false
  851. )
  852. )
  853. )
  854. )