Move test definitions to bottom of file
[hiphop-php.git] / hphp / hack / test / typecheck / expression_trees / add.php
blob715e009f10280cd37127be7824aa626b4ec60f1a
1 <?hh
3 <<file:__EnableUnstableFeatures('expression_trees')>>
5 function foo(): void {
6 $addition = Code`1 + 2`;
10 //// BEGIN DEFS
11 // Placeholder definition so we don't get naming/typing errors.
12 final class Code {
13 const type TAst = mixed;
14 // Simple literals.
15 public function intLiteral(int $_): this::TAst {
16 throw new Exception();
18 public function boolLiteral(bool $_): this::TAst {
19 throw new Exception();
21 public function stringLiteral(string $_): this::TAst {
22 throw new Exception();
24 public function nullLiteral(): this::TAst {
25 throw new Exception();
27 public function localVar(string $_): this::TAst {
28 throw new Exception();
30 public function lambdaLiteral(
31 vec<string> $_args,
32 vec<this::TAst> $_body,
33 ): this::TAst {
34 throw new Exception();
37 // Operators
38 public function plus(this::TAst $_, this::TAst $_): this::TAst {
39 throw new Exception();
41 public function ampamp(this::TAst $_, this::TAst $_): this::TAst {
42 throw new Exception();
44 public function barbar(this::TAst $_, this::TAst $_): this::TAst {
45 throw new Exception();
47 public function exclamationMark(this::TAst $_): this::TAst {
48 throw new Exception();
50 public function call(string $_fnName, vec<this::TAst> $_args): this::TAst {
51 throw new Exception();
54 public function assign(this::TAst $_, this::TAst $_): this::TAst {
55 throw new Exception();
58 // Statements.
59 public function ifStatement(
60 this::TAst $_cond,
61 vec<this::TAst> $_then_body,
62 vec<this::TAst> $_else_body,
63 ): this::TAst {
64 throw new Exception();
66 public function whileStatement(
67 this::TAst $_cond,
68 vec<this::TAst> $_body,
69 ): this::TAst {
70 throw new Exception();
72 public function returnStatement(?this::TAst $_): this::TAst {
73 throw new Exception();
75 public function forStatement(
76 vec<this::TAst> $_,
77 this::TAst $_,
78 vec<this::TAst> $_,
79 vec<this::TAst> $_,
80 ): this::TAst {
81 throw new Exception();
83 public function breakStatement(): this::TAst {
84 throw new Exception();
86 public function continueStatement(): this::TAst {
87 throw new Exception();
90 // Splice
91 public function splice<T>(ExprTree<this, this::TAst, T> $_): this::TAst {
92 throw new Exception();
95 // TODO: Discard unsupported syntax nodes while lowering
96 public function unsupportedSyntax(string $msg): this::TAst {
97 throw new Exception($msg);
101 final class ExprTree<TVisitor, TResult, TInfer>{
102 public function __construct(
103 private (function(TVisitor): TResult) $x,
104 private (function(): TInfer) $err,
105 ) {}
107 //// END DEFS