invalid_members.carbon 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/named_constraint/invalid_members.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/named_constraint/invalid_members.carbon
  12. // --- todo_fail_invalid_fn.carbon
  13. library "[[@TEST_NAME]]";
  14. constraint E {
  15. // TODO: Any fn in a non-template constraint is an error.
  16. fn DeclaredFunction();
  17. fn DeclaredMethod[self: Self](b: Self);
  18. }
  19. constraint F {
  20. // TODO: Any fn in a non-template constraint is an error.
  21. fn DefinedFunction() {}
  22. fn DefinedMethod[self: Self](b: Self) {}
  23. }
  24. // --- todo_fail_invalid_var.carbon
  25. library "[[@TEST_NAME]]";
  26. constraint E {
  27. // TODO: Any var in a constraint is an error.
  28. var c: ();
  29. }
  30. // --- fail_todo_invalid_var_template.carbon
  31. library "[[@TEST_NAME]]";
  32. // CHECK:STDERR: fail_todo_invalid_var_template.carbon:[[@LINE+8]]:1: error: unrecognized declaration introducer [UnrecognizedDecl]
  33. // CHECK:STDERR: template constraint E {
  34. // CHECK:STDERR: ^~~~~~~~
  35. // CHECK:STDERR:
  36. // CHECK:STDERR: fail_todo_invalid_var_template.carbon:[[@LINE+4]]:1: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  37. // CHECK:STDERR: template constraint E {
  38. // CHECK:STDERR: ^~~~~~~~
  39. // CHECK:STDERR:
  40. template constraint E {
  41. // TODO: Any var in a constraint is an error.
  42. var c: ();
  43. }
  44. // --- todo_fail_invalid_let.carbon
  45. library "[[@TEST_NAME]]";
  46. constraint E {
  47. // TODO: Any let in a constraint is an error.
  48. var c: ();
  49. }
  50. // --- fail_todo_invalid_let_template.carbon
  51. library "[[@TEST_NAME]]";
  52. // CHECK:STDERR: fail_todo_invalid_let_template.carbon:[[@LINE+8]]:1: error: unrecognized declaration introducer [UnrecognizedDecl]
  53. // CHECK:STDERR: template constraint E {
  54. // CHECK:STDERR: ^~~~~~~~
  55. // CHECK:STDERR:
  56. // CHECK:STDERR: fail_todo_invalid_let_template.carbon:[[@LINE+4]]:1: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  57. // CHECK:STDERR: template constraint E {
  58. // CHECK:STDERR: ^~~~~~~~
  59. // CHECK:STDERR:
  60. template constraint E {
  61. // TODO: Any let in a constraint is an error.
  62. var c: ();
  63. }