fail_storage_is_literal.carbon 1.9 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/fail_storage_is_literal.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/fail_storage_is_literal.carbon
  10. fn Main() {
  11. // CHECK:STDERR: fail_storage_is_literal.carbon:[[@LINE+3]]:10: ERROR: Cannot implicitly convert from `i32` to `type`.
  12. // CHECK:STDERR: var x: 1 = 1;
  13. // CHECK:STDERR: ^
  14. var x: 1 = 1;
  15. }
  16. // CHECK:STDOUT: --- fail_storage_is_literal.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  22. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .Core = %Core
  28. // CHECK:STDOUT: .Main = %Main.decl
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  31. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {}
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: fn @Main() {
  35. // CHECK:STDOUT: !entry:
  36. // CHECK:STDOUT: %.loc15_10: i32 = int_literal 1 [template = constants.%.2]
  37. // CHECK:STDOUT: %x.var: ref <error> = var x
  38. // CHECK:STDOUT: %x: ref <error> = bind_name x, %x.var
  39. // CHECK:STDOUT: %.loc15_14: i32 = int_literal 1 [template = constants.%.2]
  40. // CHECK:STDOUT: assign %x.var, <error>
  41. // CHECK:STDOUT: return
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: