fail_no_conversion.carbon 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/as/fail_no_conversion.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/as/fail_no_conversion.carbon
  10. // CHECK:STDERR: fail_no_conversion.carbon:[[@LINE+3]]:21: ERROR: Cannot convert from `i32` to `(i32, i32)` with `as`.
  11. // CHECK:STDERR: let n: (i32, i32) = 1 as (i32, i32);
  12. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  13. let n: (i32, i32) = 1 as (i32, i32);
  14. // CHECK:STDOUT: --- fail_no_conversion.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  18. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  19. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  20. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  21. // CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template]
  22. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  23. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Core = %Core
  29. // CHECK:STDOUT: .n = @__global_init.%n
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  33. // CHECK:STDOUT: %int.make_type_32.loc14_9: init type = call constants.%Int32() [template = i32]
  34. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  35. // CHECK:STDOUT: %int.make_type_32.loc14_14: init type = call constants.%Int32() [template = i32]
  36. // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%int.make_type_32.loc14_9, %int.make_type_32.loc14_14)
  37. // CHECK:STDOUT: %.loc14_17.2: type = value_of_initializer %int.make_type_32.loc14_9 [template = i32]
  38. // CHECK:STDOUT: %.loc14_17.3: type = converted %int.make_type_32.loc14_9, %.loc14_17.2 [template = i32]
  39. // CHECK:STDOUT: %.loc14_17.4: type = value_of_initializer %int.make_type_32.loc14_14 [template = i32]
  40. // CHECK:STDOUT: %.loc14_17.5: type = converted %int.make_type_32.loc14_14, %.loc14_17.4 [template = i32]
  41. // CHECK:STDOUT: %.loc14_17.6: type = converted %.loc14_17.1, constants.%.3 [template = constants.%.3]
  42. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  43. // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @__global_init() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %.loc14_21: i32 = int_literal 1 [template = constants.%.5]
  51. // CHECK:STDOUT: %int.make_type_32.loc14_27: init type = call constants.%Int32() [template = i32]
  52. // CHECK:STDOUT: %int.make_type_32.loc14_32: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc14_35.1: %.2 = tuple_literal (%int.make_type_32.loc14_27, %int.make_type_32.loc14_32)
  54. // CHECK:STDOUT: %.loc14_35.2: type = value_of_initializer %int.make_type_32.loc14_27 [template = i32]
  55. // CHECK:STDOUT: %.loc14_35.3: type = converted %int.make_type_32.loc14_27, %.loc14_35.2 [template = i32]
  56. // CHECK:STDOUT: %.loc14_35.4: type = value_of_initializer %int.make_type_32.loc14_32 [template = i32]
  57. // CHECK:STDOUT: %.loc14_35.5: type = converted %int.make_type_32.loc14_32, %.loc14_35.4 [template = i32]
  58. // CHECK:STDOUT: %.loc14_35.6: type = converted %.loc14_35.1, constants.%.3 [template = constants.%.3]
  59. // CHECK:STDOUT: %n: %.3 = bind_name n, <error>
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: