fail_method_args.carbon 705 B

1234567891011121314151617181920212223242526272829
  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. class Point {
  10. fn Origin() -> Point {
  11. return {.x = 0, .y = 0};
  12. }
  13. fn SetX[self: Point](x: i32) {
  14. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/let/fail_method_args.carbon:[[@LINE+1]]: Only a reference expression can be assigned to, but got `x`
  15. x = 10;
  16. }
  17. var x: i32;
  18. var y: i32;
  19. }
  20. fn Main() -> i32 {
  21. var p: Point = Point.Origin();
  22. p.SetX(42);
  23. return 0;
  24. }