fail_mix_in_global.carbon 867 B

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