fail_class_named_self.carbon 588 B

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