fail_generic.carbon 2.1 KB

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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/var/no_prelude/fail_generic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_generic.carbon
  10. fn Main() {
  11. // CHECK:STDERR: fail_generic.carbon:[[@LINE+3]]:11: error: `var` declaration cannot declare a compile-time binding [CompileTimeBindingInVarDecl]
  12. // CHECK:STDERR: var x:! () = ();
  13. // CHECK:STDERR: ^~
  14. var x:! () = ();
  15. }
  16. // CHECK:STDOUT: --- fail_generic.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  22. // CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x [symbolic]
  23. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Main = %Main.decl
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: fn @Main() {
  34. // CHECK:STDOUT: !entry:
  35. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  36. // CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x, %x.var [symbolic = constants.%x]
  37. // CHECK:STDOUT: %.loc15_17.1: %empty_tuple.type = tuple_literal ()
  38. // CHECK:STDOUT: %.loc15_17.2: init %empty_tuple.type = tuple_init () to %x.var [template = constants.%empty_tuple]
  39. // CHECK:STDOUT: %.loc15_18: init %empty_tuple.type = converted %.loc15_17.1, %.loc15_17.2 [template = constants.%empty_tuple]
  40. // CHECK:STDOUT: assign %x.var, %.loc15_18
  41. // CHECK:STDOUT: return
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: