fail_generic_import.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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+4]]:8: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  21. // CHECK:STDERR: let a: T = 0;
  22. // CHECK:STDERR: ^
  23. // CHECK:STDERR:
  24. let a: T = 0;
  25. // CHECK:STDOUT: --- fail_implicit.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  29. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: .Int = %Core.Int
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .T = %T
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: name_binding_decl {
  47. // CHECK:STDOUT: %T.patt: type = binding_pattern T
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %T: type = bind_name T, @__global_init.%i32
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @__global_init() {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  55. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  56. // CHECK:STDOUT: return
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: --- fail_implicit.impl.carbon
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: constants {
  62. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: imports {
  66. // CHECK:STDOUT: %Implicit.T: type = import_ref Implicit//default, T, loaded
  67. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  68. // CHECK:STDOUT: import Core//prelude
  69. // CHECK:STDOUT: import Core//prelude/...
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: file {
  74. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  75. // CHECK:STDOUT: .T = imports.%Implicit.T
  76. // CHECK:STDOUT: .Core = imports.%Core
  77. // CHECK:STDOUT: .a = %a
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: %Implicit.import = import Implicit
  80. // CHECK:STDOUT: %default.import = import <none>
  81. // CHECK:STDOUT: %Core.import = import Core
  82. // CHECK:STDOUT: name_binding_decl {
  83. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%Implicit.T
  86. // CHECK:STDOUT: %a: <error> = bind_name a, <error>
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: fn @__global_init() {
  90. // CHECK:STDOUT: !entry:
  91. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  92. // CHECK:STDOUT: return
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: