Add position metadata to desugaring
[hiphop-php.git] / hphp / hack / test / typecheck / expression_trees / nested_splicing2.php
blobb634c724c0e5d67eb11920bff80d1563fc5a2640
1 <?hh
3 <<file:__EnableUnstableFeatures('expression_trees')>>
5 function test(): void {
6 Code`__splice__(1 + __splice__(4))`;
9 //// BEGIN DEFS
10 // Placeholder definition so we don't get naming/typing errors.
11 final class Code {
12 const type TAst = mixed;
13 // Simple literals.
14 public function intLiteral(?ExprPos $_, int $_): this::TAst {
15 throw new Exception();
17 public function boolLiteral(?ExprPos $_, bool $_): this::TAst {
18 throw new Exception();
20 public function stringLiteral(?ExprPos $_, string $_): this::TAst {
21 throw new Exception();
23 public function nullLiteral(?ExprPos $_): this::TAst {
24 throw new Exception();
26 public function localVar(?ExprPos $_, string $_): this::TAst {
27 throw new Exception();
29 public function lambdaLiteral(
30 ?ExprPos $_,
31 vec<string> $_args,
32 vec<this::TAst> $_body,
33 ): this::TAst {
34 throw new Exception();
37 // Operators
38 public function plus(
39 ?ExprPos $_,
40 this::TAst $_,
41 this::TAst $_,
42 ): this::TAst {
43 throw new Exception();
45 public function ampamp(
46 ?ExprPos $_,
47 this::TAst $_,
48 this::TAst $_,
49 ): this::TAst {
50 throw new Exception();
52 public function barbar(
53 ?ExprPos $_,
54 this::TAst $_,
55 this::TAst $_,
56 ): this::TAst {
57 throw new Exception();
59 public function exclamationMark(
60 ?ExprPos $_,
61 this::TAst $_,
62 ): this::TAst {
63 throw new Exception();
65 public function call(
66 ?ExprPos $_,
67 string $_fnName,
68 vec<this::TAst> $_args,
69 ): this::TAst {
70 throw new Exception();
73 public function assign(
74 ?ExprPos $_,
75 this::TAst $_,
76 this::TAst $_,
77 ): this::TAst {
78 throw new Exception();
81 // Statements.
82 public function ifStatement(
83 ?ExprPos $_,
84 this::TAst $_cond,
85 vec<this::TAst> $_then_body,
86 vec<this::TAst> $_else_body,
87 ): this::TAst {
88 throw new Exception();
90 public function whileStatement(
91 ?ExprPos $_,
92 this::TAst $_cond,
93 vec<this::TAst> $_body,
94 ): this::TAst {
95 throw new Exception();
97 public function returnStatement(
98 ?ExprPos $_,
99 ?this::TAst $_,
100 ): this::TAst {
101 throw new Exception();
103 public function forStatement(
104 ?ExprPos $_,
105 vec<this::TAst> $_,
106 this::TAst $_,
107 vec<this::TAst> $_,
108 vec<this::TAst> $_,
109 ): this::TAst {
110 throw new Exception();
112 public function breakStatement(?ExprPos $_): this::TAst {
113 throw new Exception();
115 public function continueStatement(?ExprPos $_,): this::TAst {
116 throw new Exception();
119 // Splice
120 public function splice<T>(
121 ?ExprPos $_,
122 ExprTree<this, this::TAst, T> $_,
123 ): this::TAst {
124 throw new Exception();
127 // TODO: Discard unsupported syntax nodes while lowering
128 public function unsupportedSyntax(string $msg): this::TAst {
129 throw new Exception($msg);
133 final class ExprTree<TVisitor, TResult, TInfer>{
134 public function __construct(
135 private ?ExprPos $pos,
136 private (function(TVisitor): TResult) $x,
137 private (function(): TInfer) $err,
138 ) {}
141 final class ExprPos {
142 public function __construct(
143 private int $begin_line,
144 private int $begin_col,
145 private int $end_line,
146 private int $end_col,
147 ) {}
149 //// END DEFS