fail_mix_in_global.carbon 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. __mixin Operations {
  10. fn Square[self: Self](x:i32) -> i32{
  11. return x * x;
  12. }
  13. }
  14. // CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/mixin/fail_mix_in_global.carbon:[[@LINE+1]]: syntax error, unexpected MIX, expecting END_OF_FILE
  15. __mix Operations;
  16. class Point {
  17. fn Origin() -> Point {
  18. return {.x = 0, .y = 0};
  19. }
  20. var x: i32;
  21. var y: i32;
  22. __mix Operations;
  23. }
  24. class Complex {
  25. fn Zero() -> Complex {
  26. return {.r = 0, .i = 0};
  27. }
  28. var r: i32;
  29. var i: i32;
  30. __mix Operations;
  31. }
  32. fn Main() -> i32 {
  33. var p: Point = Point.Origin();
  34. var c: Complex = Complex.Zero();
  35. p.x = 3;
  36. c.r = 3;
  37. return p.Square(p.y) - c.Square(c.i);
  38. }