fail_method_args.carbon 911 B

1234567891011121314151617181920212223242526272829303132
  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. // RUN: %{not} %{executable_semantics} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{not} %{executable_semantics} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{executable_semantics} %s
  10. // CHECK: COMPILATION ERROR: {{.*}}/executable_semantics/testdata/let/fail_method_args.carbon:21: Cannot assign to rvalue 'x'
  11. package ExecutableSemanticsTest api;
  12. class Point {
  13. fn Origin() -> Point {
  14. return {.x = 0, .y = 0};
  15. }
  16. fn SetX[me: Point](x :i32) {
  17. x = 10;
  18. }
  19. var x: i32;
  20. var y: i32;
  21. }
  22. fn Main() -> i32 {
  23. var p: Point = Point.Origin();
  24. p.SetX(42);
  25. return 0;
  26. }