unexpected_runtime.carbon 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/convert.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/eval/unexpected_runtime.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/eval/unexpected_runtime.carbon
  12. // --- fail_unexpected_runtime_base.carbon
  13. library "[[@TEST_NAME]]";
  14. var x: type;
  15. interface Z {
  16. let T:! type;
  17. }
  18. class D {
  19. // CHECK:STDERR: fail_unexpected_runtime_base.carbon:[[@LINE+4]]:18: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  20. // CHECK:STDERR: extend impl as x where .T = () {}
  21. // CHECK:STDERR: ^
  22. // CHECK:STDERR:
  23. extend impl as x where .T = () {}
  24. }
  25. // --- fail_unexpected_runtime_rewrite_lhs.carbon
  26. library "[[@TEST_NAME]]";
  27. var x: type;
  28. interface Z {
  29. let T:! type;
  30. }
  31. class D {
  32. // CHECK:STDERR: fail_unexpected_runtime_rewrite_lhs.carbon:[[@LINE+8]]:18: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  33. // CHECK:STDERR: extend impl as Z where x = () {}
  34. // CHECK:STDERR: ^~~~~~~~~
  35. // CHECK:STDERR:
  36. // CHECK:STDERR: fail_unexpected_runtime_rewrite_lhs.carbon:[[@LINE+4]]:28: error: requirement can only use `=` after `.member` designator [RequirementEqualAfterNonDesignator]
  37. // CHECK:STDERR: extend impl as Z where x = () {}
  38. // CHECK:STDERR: ^
  39. // CHECK:STDERR:
  40. extend impl as Z where x = () {}
  41. }
  42. // --- fail_unexpected_runtime_rewrite_rhs.carbon
  43. library "[[@TEST_NAME]]";
  44. var x: type;
  45. interface Z {
  46. let T:! type;
  47. }
  48. class D {
  49. // CHECK:STDERR: fail_unexpected_runtime_rewrite_rhs.carbon:[[@LINE+4]]:31: error: expression is runtime; expected constant [EvalRequiresConstantValue]
  50. // CHECK:STDERR: extend impl as Z where .T = x {}
  51. // CHECK:STDERR: ^
  52. // CHECK:STDERR:
  53. extend impl as Z where .T = x {}
  54. }
  55. // --- fail_unexpected_runtime_impls_lhs.carbon
  56. library "[[@TEST_NAME]]";
  57. var x: type;
  58. interface Z {}
  59. class D {
  60. // CHECK:STDERR: fail_unexpected_runtime_impls_lhs.carbon:[[@LINE+4]]:29: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  61. // CHECK:STDERR: extend impl as type where x impls Z {}
  62. // CHECK:STDERR: ^
  63. // CHECK:STDERR:
  64. extend impl as type where x impls Z {}
  65. }
  66. // --- fail_unexpected_runtime_impls_rhs.carbon
  67. library "[[@TEST_NAME]]";
  68. var x: type;
  69. interface Z {}
  70. class D {
  71. // CHECK:STDERR: fail_unexpected_runtime_impls_rhs.carbon:[[@LINE+4]]:41: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  72. // CHECK:STDERR: extend impl as type where .Self impls x {}
  73. // CHECK:STDERR: ^
  74. // CHECK:STDERR:
  75. extend impl as type where .Self impls x {}
  76. }