fail_field_modifiers.carbon 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_field_modifiers.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_field_modifiers.carbon
  12. class Class {
  13. // CHECK:STDERR: fail_field_modifiers.carbon:[[@LINE+4]]:3: error: `default` not allowed on `var` declaration [ModifierNotAllowedOnDeclaration]
  14. // CHECK:STDERR: default var j: i32;
  15. // CHECK:STDERR: ^~~~~~~
  16. // CHECK:STDERR:
  17. default var j: i32;
  18. // CHECK:STDERR: fail_field_modifiers.carbon:[[@LINE+4]]:3: error: `final` not allowed on `var` declaration [ModifierNotAllowedOnDeclaration]
  19. // CHECK:STDERR: final var k: i32;
  20. // CHECK:STDERR: ^~~~~
  21. // CHECK:STDERR:
  22. final var k: i32;
  23. // CHECK:STDERR: fail_field_modifiers.carbon:[[@LINE+4]]:3: error: `default` not allowed; requires interface scope [ModifierRequiresInterface]
  24. // CHECK:STDERR: default let l: i32 = 0;
  25. // CHECK:STDERR: ^~~~~~~
  26. // CHECK:STDERR:
  27. default let l: i32 = 0;
  28. // CHECK:STDERR: fail_field_modifiers.carbon:[[@LINE+4]]:3: error: `final` not allowed; requires interface scope [ModifierRequiresInterface]
  29. // CHECK:STDERR: final let m: i32 = 1;
  30. // CHECK:STDERR: ^~~~~
  31. // CHECK:STDERR:
  32. final let m: i32 = 1;
  33. }