fail_generic_import.carbon 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/let/fail_generic_import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/fail_generic_import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. let T:! type = i32;
  13. // --- fail_implicit.impl.carbon
  14. impl package Implicit;
  15. // TODO: Should this be valid?
  16. // CHECK:STDERR: fail_implicit.impl.carbon:[[@LINE+3]]:1: ERROR: Cannot implicitly convert from `i32` to `T`.
  17. // CHECK:STDERR: let a: T = 0;
  18. // CHECK:STDERR: ^~~~~~~~~~~~~
  19. let a: T = 0;
  20. // CHECK:STDOUT: --- implicit.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  24. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  25. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  26. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .T = @__global_init.%T
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: fn @__global_init() {
  41. // CHECK:STDOUT: !entry:
  42. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  43. // CHECK:STDOUT: %.loc4_19.1: type = value_of_initializer %int.make_type_32 [template = i32]
  44. // CHECK:STDOUT: %.loc4_19.2: type = converted %int.make_type_32, %.loc4_19.1 [template = i32]
  45. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, %.loc4_19.2 [symbolic = constants.%T]
  46. // CHECK:STDOUT: return
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: --- fail_implicit.impl.carbon
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: constants {
  52. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  53. // CHECK:STDOUT: %.1: i32 = int_literal 0 [template]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .T = %import_ref
  59. // CHECK:STDOUT: .Core = %Core
  60. // CHECK:STDOUT: .a = @__global_init.%a
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+2, loaded [symbolic = constants.%T]
  63. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  64. // CHECK:STDOUT: %T.ref: type = name_ref T, %import_ref [symbolic = constants.%T]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @__global_init() {
  68. // CHECK:STDOUT: !entry:
  69. // CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1]
  70. // CHECK:STDOUT: %a: %T = bind_name a, <error>
  71. // CHECK:STDOUT: return
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: