fail_generic_import.carbon 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // --- fail_implicit.carbon
  11. package Implicit;
  12. // CHECK:STDERR: fail_implicit.carbon:[[@LINE+4]]:5: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  13. // CHECK:STDERR: let T:! type = i32;
  14. // CHECK:STDERR: ^~~~~~~~
  15. // CHECK:STDERR:
  16. let T:! type = i32;
  17. // --- fail_implicit.impl.carbon
  18. impl package Implicit;
  19. // TODO: Should this be valid?
  20. // CHECK:STDERR: fail_implicit.impl.carbon:[[@LINE+3]]:8: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  21. // CHECK:STDERR: let a: T = 0;
  22. // CHECK:STDERR: ^
  23. let a: T = 0;
  24. // CHECK:STDOUT: --- fail_implicit.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  28. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  29. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: .Int32 = %import_ref
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .T = @__global_init.%T
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: fn @__global_init() {
  52. // CHECK:STDOUT: !entry:
  53. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  54. // CHECK:STDOUT: %.loc8_19.1: type = value_of_initializer %int.make_type_32 [template = i32]
  55. // CHECK:STDOUT: %.loc8_19.2: type = converted %int.make_type_32, %.loc8_19.1 [template = i32]
  56. // CHECK:STDOUT: %T: type = bind_name T, %.loc8_19.2
  57. // CHECK:STDOUT: return
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: --- fail_implicit.impl.carbon
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: constants {
  63. // CHECK:STDOUT: %.1: i32 = int_literal 0 [template]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: imports {
  67. // CHECK:STDOUT: %import_ref: type = import_ref Implicit//default, inst+3, loaded
  68. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  69. // CHECK:STDOUT: import Core//prelude
  70. // CHECK:STDOUT: import Core//prelude/...
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: file {
  75. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  76. // CHECK:STDOUT: .T = imports.%import_ref
  77. // CHECK:STDOUT: .Core = imports.%Core
  78. // CHECK:STDOUT: .a = @__global_init.%a
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %Implicit.import = import Implicit
  81. // CHECK:STDOUT: %default.import = import <invalid>
  82. // CHECK:STDOUT: %Core.import = import Core
  83. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%import_ref
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: fn @__global_init() {
  87. // CHECK:STDOUT: !entry:
  88. // CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1]
  89. // CHECK:STDOUT: %a: <error> = bind_name a, <error>
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: