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. // TIP: To test this file alone, run:
  15. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lex/testdata/fail_mismatched_brackets_2.carbon
  16. // TIP: To dump output, run:
  17. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lex/testdata/fail_mismatched_brackets_2.carbon
  18. // CHECK:STDERR: fail_mismatched_brackets_2.carbon:[[@LINE-9]]:1: error: closing symbol without a corresponding opening symbol [UnmatchedClosing]
  19. // CHECK:STDERR: }
  20. // CHECK:STDERR: ^
  21. // CHECK:STDOUT: - filename: fail_mismatched_brackets_2.carbon
  22. // CHECK:STDOUT: tokens:
  23. // CHECK:STDOUT: - { index: 1, kind: 'Fn', line: {{ *}}[[@LINE-18]], column: 1, indent: 1, spelling: 'fn', has_leading_space: true }
  24. // CHECK:STDOUT: - { index: 2, kind: 'Identifier', line: {{ *}}[[@LINE-19]], column: 4, indent: 1, spelling: 'F', identifier: 0, has_leading_space: true }
  25. // CHECK:STDOUT: - { index: 3, kind: 'OpenParen', line: {{ *}}[[@LINE-20]], column: 5, indent: 1, spelling: '(', closing_token: 4 }
  26. // CHECK:STDOUT: - { index: 4, kind: 'CloseParen', line: {{ *}}[[@LINE-21]], column: 6, indent: 1, spelling: ')', opening_token: 3 }
  27. // CHECK:STDOUT: - { index: 5, kind: 'OpenCurlyBrace', line: {{ *}}[[@LINE-22]], column: 8, indent: 1, spelling: '{', closing_token: 12, has_leading_space: true }
  28. // CHECK:STDOUT: - { index: 6, kind: 'If', line: {{ *}}[[@LINE-22]], column: 3, indent: 3, spelling: 'if', has_leading_space: true }
  29. // CHECK:STDOUT: - { index: 7, kind: 'OpenParen', line: {{ *}}[[@LINE-23]], column: 6, indent: 3, spelling: '(', closing_token: 9, has_leading_space: true }
  30. // CHECK:STDOUT: - { index: 8, kind: 'Identifier', line: {{ *}}[[@LINE-24]], column: 7, indent: 3, spelling: 'thing1', identifier: 1 }
  31. // CHECK:STDOUT: - { index: 9, kind: 'CloseParen', line: {{ *}}[[@LINE-25]], column: 13, indent: 3, spelling: ')', opening_token: 7 }
  32. // CHECK:STDOUT: - { index: 10, kind: 'Identifier', line: {{ *}}[[@LINE-25]], column: 5, indent: 5, spelling: 'thing2', identifier: 2, has_leading_space: true }
  33. // CHECK:STDOUT: - { index: 11, kind: 'Semi', line: {{ *}}[[@LINE-26]], column: 11, indent: 5, spelling: ';' }
  34. // CHECK:STDOUT: - { index: 12, kind: 'CloseCurlyBrace', line: {{ *}}[[@LINE-26]], column: 3, indent: 3, spelling: '}', opening_token: 5, has_leading_space: true }
  35. // CHECK:STDOUT: - { index: 13, kind: 'Error', line: {{ *}}[[@LINE-26]], column: 1, indent: 1, spelling: '}', has_leading_space: true }