fail_mismatched_brackets_2.carbon 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. // TODO: For this example, we should ideally report a missing `{` on the `if`
  5. // line, for example based on the indentation of the surrounding lines.
  6. fn F() {
  7. if (thing1)
  8. thing2;
  9. }
  10. }
  11. // The check lines are inserted at the end so that they don't disrupt the
  12. // indentation of lines in the text.
  13. // AUTOUPDATE
  14. // CHECK:STDERR: fail_mismatched_brackets_2.carbon:[[@LINE-5]]:1: ERROR: Closing symbol without a corresponding opening symbol.
  15. // CHECK:STDERR: }
  16. // CHECK:STDERR: ^
  17. // CHECK:STDOUT: - filename: fail_mismatched_brackets_2.carbon
  18. // CHECK:STDOUT: tokens: [
  19. // CHECK:STDOUT: { index: 0, kind: 'FileStart', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true },
  20. // CHECK:STDOUT: { index: 1, kind: 'Fn', line: {{ *}}[[@LINE-15]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true },
  21. // CHECK:STDOUT: { index: 2, kind: 'Identifier', line: {{ *}}[[@LINE-16]], column: 4, indent: 1, spelling: 'F', identifier: 0 },
  22. // CHECK:STDOUT: { index: 3, kind: 'OpenParen', line: {{ *}}[[@LINE-17]], column: 5, indent: 1, spelling: '(', closing_token: 4 },
  23. // CHECK:STDOUT: { index: 4, kind: 'CloseParen', line: {{ *}}[[@LINE-18]], column: 6, indent: 1, spelling: ')', opening_token: 3, has_trailing_space: true },
  24. // CHECK:STDOUT: { index: 5, kind: 'OpenCurlyBrace', line: {{ *}}[[@LINE-19]], column: 8, indent: 1, spelling: '{', closing_token: 12, has_trailing_space: true },
  25. // CHECK:STDOUT: { index: 6, kind: 'If', line: {{ *}}[[@LINE-19]], column: 3, indent: 3, spelling: 'if', has_trailing_space: true },
  26. // CHECK:STDOUT: { index: 7, kind: 'OpenParen', line: {{ *}}[[@LINE-20]], column: 6, indent: 3, spelling: '(', closing_token: 9 },
  27. // CHECK:STDOUT: { index: 8, kind: 'Identifier', line: {{ *}}[[@LINE-21]], column: 7, indent: 3, spelling: 'thing1', identifier: 1 },
  28. // CHECK:STDOUT: { index: 9, kind: 'CloseParen', line: {{ *}}[[@LINE-22]], column: 13, indent: 3, spelling: ')', opening_token: 7, has_trailing_space: true },
  29. // CHECK:STDOUT: { index: 10, kind: 'Identifier', line: {{ *}}[[@LINE-22]], column: 5, indent: 5, spelling: 'thing2', identifier: 2 },
  30. // CHECK:STDOUT: { index: 11, kind: 'Semi', line: {{ *}}[[@LINE-23]], column: 11, indent: 5, spelling: ';', has_trailing_space: true },
  31. // CHECK:STDOUT: { index: 12, kind: 'CloseCurlyBrace', line: {{ *}}[[@LINE-23]], column: 3, indent: 3, spelling: '}', opening_token: 5, has_trailing_space: true },
  32. // CHECK:STDOUT: { index: 13, kind: 'Error', line: {{ *}}[[@LINE-23]], column: 1, indent: 1, spelling: '}', has_trailing_space: true },
  33. // CHECK:STDOUT: { index: 14, kind: 'FileEnd', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' },
  34. // CHECK:STDOUT: ]