fail_self_param_syntax.carbon 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon
  10. interface Foo {
  11. // CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+4]]:13: ERROR: Expected binding pattern.
  12. // CHECK:STDERR: fn Sub[me Self](b: Self) -> Self;
  13. // CHECK:STDERR: ^~~~
  14. // CHECK:STDERR:
  15. fn Sub[me Self](b: Self) -> Self;
  16. // CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+3]]:10: ERROR: Expected binding pattern.
  17. // CHECK:STDERR: fn Mul[Self](b: Self) -> Self;
  18. // CHECK:STDERR: ^~~~
  19. fn Mul[Self](b: Self) -> Self;
  20. }
  21. // CHECK:STDOUT: - filename: fail_self_param_syntax.carbon
  22. // CHECK:STDOUT: parse_tree: [
  23. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  24. // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'},
  25. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'Foo'},
  26. // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3},
  27. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  28. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'Sub'},
  29. // CHECK:STDOUT: {kind: 'ImplicitParamListStart', text: '['},
  30. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'me'},
  31. // CHECK:STDOUT: {kind: 'InvalidParse', text: 'Self', has_error: yes},
  32. // CHECK:STDOUT: {kind: 'BindingPattern', text: 'me', has_error: yes, subtree_size: 3},
  33. // CHECK:STDOUT: {kind: 'ImplicitParamList', text: ']', has_error: yes, subtree_size: 5},
  34. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  35. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
  36. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  37. // CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
  38. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 5},
  39. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  40. // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
  41. // CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 15},
  42. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  43. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'Mul'},
  44. // CHECK:STDOUT: {kind: 'ImplicitParamListStart', text: '['},
  45. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'Self', has_error: yes},
  46. // CHECK:STDOUT: {kind: 'InvalidParse', text: 'Self', has_error: yes},
  47. // CHECK:STDOUT: {kind: 'BindingPattern', text: 'Self', has_error: yes, subtree_size: 3},
  48. // CHECK:STDOUT: {kind: 'ImplicitParamList', text: ']', has_error: yes, subtree_size: 5},
  49. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  50. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'b'},
  51. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  52. // CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
  53. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 5},
  54. // CHECK:STDOUT: {kind: 'SelfTypeNameExpr', text: 'Self'},
  55. // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2},
  56. // CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 15},
  57. // CHECK:STDOUT: {kind: 'InterfaceDefinition', text: '}', subtree_size: 34},
  58. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  59. // CHECK:STDOUT: ]