菜谱项目

recovery.test 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  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 5:6 to 5:6
  535. A trailing comma is not allowed here from 6:13 to 6:13
  536. A trailing comma is not allowed here from 8:21 to 8:21
  537. A trailing comma is not allowed here from 9:10 to 9:10
  538. A trailing comma is not allowed here from 10:10 to 10:10
  539. A trailing comma is not allowed here from 11:25 to 11:25
  540. A trailing comma is not allowed here from 13:17 to 13:17
  541. A trailing comma is not allowed here from 14:14 to 14:14
  542. A trailing comma is not allowed here from 16:22 to 16:22
  543. A trailing comma is not allowed here from 18:9 to 18:9
  544. A trailing comma is not allowed here from 19:9 to 19:9
  545. A trailing comma is not allowed here from 21:13 to 21:13
  546. A trailing comma is not allowed here from 23:16 to 23:16
  547. A trailing comma is not allowed here from 24:7 to 24:7
  548. A trailing comma is not allowed here from 25:10 to 25:10
  549. A trailing comma is not allowed here from 26:10 to 26:10
  550. A trailing comma is not allowed here from 27:8 to 27:8
  551. A trailing comma is not allowed here from 29:8 to 29:8
  552. A trailing comma is not allowed here from 29:14 to 29:14
  553. A trailing comma is not allowed here from 29:20 to 29:20
  554. A trailing comma is not allowed here from 30:13 to 30:13
  555. A trailing comma is not allowed here from 30:24 to 30:24
  556. array(
  557. 0: Stmt_GroupUse(
  558. type: TYPE_UNKNOWN (0)
  559. prefix: Name(
  560. parts: array(
  561. 0: A
  562. )
  563. )
  564. uses: array(
  565. 0: Stmt_UseUse(
  566. type: TYPE_NORMAL (1)
  567. name: Name(
  568. parts: array(
  569. 0: B
  570. )
  571. )
  572. alias: B
  573. )
  574. )
  575. )
  576. 1: Stmt_GroupUse(
  577. type: TYPE_FUNCTION (2)
  578. prefix: Name(
  579. parts: array(
  580. 0: A
  581. )
  582. )
  583. uses: array(
  584. 0: Stmt_UseUse(
  585. type: TYPE_UNKNOWN (0)
  586. name: Name(
  587. parts: array(
  588. 0: b
  589. )
  590. )
  591. alias: b
  592. )
  593. )
  594. )
  595. 2: Stmt_Use(
  596. type: TYPE_NORMAL (1)
  597. uses: array(
  598. 0: Stmt_UseUse(
  599. type: TYPE_UNKNOWN (0)
  600. name: Name(
  601. parts: array(
  602. 0: A
  603. )
  604. )
  605. alias: A
  606. )
  607. )
  608. )
  609. 3: Stmt_Const(
  610. consts: array(
  611. 0: Const(
  612. name: A
  613. value: Scalar_LNumber(
  614. value: 42
  615. )
  616. )
  617. )
  618. )
  619. 4: Stmt_Class(
  620. flags: 0
  621. name: X
  622. extends: null
  623. implements: array(
  624. 0: Name(
  625. parts: array(
  626. 0: Y
  627. )
  628. )
  629. )
  630. stmts: array(
  631. 0: Stmt_TraitUse(
  632. traits: array(
  633. 0: Name(
  634. parts: array(
  635. 0: A
  636. )
  637. )
  638. )
  639. adaptations: array(
  640. )
  641. )
  642. 1: Stmt_TraitUse(
  643. traits: array(
  644. 0: Name(
  645. parts: array(
  646. 0: A
  647. )
  648. )
  649. )
  650. adaptations: array(
  651. 0: Stmt_TraitUseAdaptation_Precedence(
  652. trait: Name(
  653. parts: array(
  654. 0: A
  655. )
  656. )
  657. method: b
  658. insteadof: array(
  659. 0: Name(
  660. parts: array(
  661. 0: C
  662. )
  663. )
  664. )
  665. )
  666. )
  667. )
  668. 2: Stmt_ClassConst(
  669. flags: 0
  670. consts: array(
  671. 0: Const(
  672. name: A
  673. value: Scalar_LNumber(
  674. value: 42
  675. )
  676. )
  677. )
  678. )
  679. 3: Stmt_Property(
  680. flags: MODIFIER_PUBLIC (1)
  681. props: array(
  682. 0: Stmt_PropertyProperty(
  683. name: x
  684. default: null
  685. )
  686. )
  687. )
  688. )
  689. )
  690. 5: Stmt_Interface(
  691. name: I
  692. extends: array(
  693. 0: Name(
  694. parts: array(
  695. 0: J
  696. )
  697. )
  698. )
  699. stmts: array(
  700. )
  701. )
  702. 6: Stmt_Unset(
  703. vars: array(
  704. 0: Expr_Variable(
  705. name: x
  706. )
  707. )
  708. )
  709. 7: Expr_Isset(
  710. vars: array(
  711. 0: Expr_Variable(
  712. name: x
  713. )
  714. )
  715. )
  716. 8: Stmt_Declare(
  717. declares: array(
  718. 0: Stmt_DeclareDeclare(
  719. key: a
  720. value: Scalar_LNumber(
  721. value: 42
  722. )
  723. )
  724. )
  725. stmts: null
  726. )
  727. 9: Stmt_Function(
  728. byRef: false
  729. name: foo
  730. params: array(
  731. 0: Param(
  732. type: null
  733. byRef: false
  734. variadic: false
  735. name: a
  736. default: null
  737. )
  738. )
  739. returnType: null
  740. stmts: array(
  741. )
  742. )
  743. 10: Expr_FuncCall(
  744. name: Name(
  745. parts: array(
  746. 0: foo
  747. )
  748. )
  749. args: array(
  750. 0: Arg(
  751. value: Expr_Variable(
  752. name: a
  753. )
  754. byRef: false
  755. unpack: false
  756. )
  757. )
  758. )
  759. 11: Stmt_Global(
  760. vars: array(
  761. 0: Expr_Variable(
  762. name: a
  763. )
  764. )
  765. )
  766. 12: Stmt_Static(
  767. vars: array(
  768. 0: Stmt_StaticVar(
  769. name: a
  770. default: null
  771. )
  772. )
  773. )
  774. 13: Stmt_Echo(
  775. exprs: array(
  776. 0: Expr_Variable(
  777. name: a
  778. )
  779. )
  780. )
  781. 14: Stmt_For(
  782. init: array(
  783. 0: Expr_Variable(
  784. name: a
  785. )
  786. )
  787. cond: array(
  788. 0: Expr_Variable(
  789. name: b
  790. )
  791. )
  792. loop: array(
  793. 0: Expr_Variable(
  794. name: c
  795. )
  796. )
  797. stmts: array(
  798. )
  799. )
  800. 15: Expr_Closure(
  801. static: false
  802. byRef: false
  803. params: array(
  804. 0: Param(
  805. type: null
  806. byRef: false
  807. variadic: false
  808. name: a
  809. default: null
  810. )
  811. )
  812. uses: array(
  813. 0: Expr_ClosureUse(
  814. var: b
  815. byRef: false
  816. )
  817. )
  818. returnType: null
  819. stmts: array(
  820. )
  821. )
  822. )
  823. -----
  824. <?php
  825. foo(Bar::);
  826. -----
  827. !!php7,positions
  828. Syntax error, unexpected ')' from 3:10 to 3:10
  829. array(
  830. 0: Expr_FuncCall[3:1 - 3:10](
  831. name: Name[3:1 - 3:3](
  832. parts: array(
  833. 0: foo
  834. )
  835. )
  836. args: array(
  837. 0: Arg[3:5 - 3:9](
  838. value: Expr_ClassConstFetch[3:5 - 3:9](
  839. class: Name[3:5 - 3:7](
  840. parts: array(
  841. 0: Bar
  842. )
  843. )
  844. name: Expr_Error[3:10 - 3:9](
  845. )
  846. )
  847. byRef: false
  848. unpack: false
  849. )
  850. )
  851. )
  852. )