| // Expect 3 errors |
| |
| // TODO(skia:12137) Today, we detect these as errors because we do not allow calls to undefined |
| // functions. That produces three errors (one for each function calling an undefined function). |
| // After we support calling declared (but not defined) functions, we should instead emit one |
| // error per cycle. |
| |
| // Simple recursion is not allowed, even with branching: |
| int fibonacci(int n) { return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2); } |
| |
| // We also detect more complex cycles in the call-graph of functions: |
| bool is_even(int n); |
| bool is_odd (int n) { return n == 0 ? false : is_even(n - 1); } |
| bool is_even(int n) { return n == 0 ? true : is_odd (n - 1); } |