fail_class_named_self.carbon 643 B

123456789101112131415161718192021
  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. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. package ExplorerTest api;
  9. // Error: Can't use keyword `Self` as the name of a class.
  10. // CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/class/fail_class_named_self.carbon:[[@LINE+1]]: syntax error, unexpected SELF, expecting identifier
  11. class Self {
  12. var x: i32;
  13. var y: i32;
  14. }
  15. fn Main() -> i32 {
  16. var p: Self = {.x = 1, .y = 2};
  17. return p.y - p.x - 1;
  18. }