fail_storage_is_literal.carbon 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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+7]]:10: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
  12. // CHECK:STDERR: var x: 1 = 1;
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR: fail_storage_is_literal.carbon:[[@LINE+4]]:10: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  15. // CHECK:STDERR: var x: 1 = 1;
  16. // CHECK:STDERR: ^
  17. // CHECK:STDERR:
  18. var x: 1 = 1;
  19. }
  20. // CHECK:STDOUT: --- fail_storage_is_literal.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  24. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  25. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/...
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = imports.%Core
  39. // CHECK:STDOUT: .Main = %Main.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @Main() {
  46. // CHECK:STDOUT: !entry:
  47. // CHECK:STDOUT: name_binding_decl {
  48. // CHECK:STDOUT: %x.patt: <error> = binding_pattern x
  49. // CHECK:STDOUT: %.loc19_3: <error> = var_pattern %x.patt
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %x.var: ref <error> = var x
  52. // CHECK:STDOUT: %int_1.loc19_14: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  53. // CHECK:STDOUT: assign %x.var, <error>
  54. // CHECK:STDOUT: %.1: <error> = splice_block <error> [template = <error>] {
  55. // CHECK:STDOUT: %int_1.loc19_10: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  56. // CHECK:STDOUT: %.loc19_10: type = converted %int_1.loc19_10, <error> [template = <error>]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %x: <error> = bind_name x, <error>
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: