fail_generic_import.carbon 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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: %pattern_type.98f: type = pattern_type type [concrete]
  29. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  30. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  31. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  32. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  37. // CHECK:STDOUT: .Int = %Core.Int
  38. // CHECK:STDOUT: import Core//prelude
  39. // CHECK:STDOUT: import Core//prelude/...
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .T = %T
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: name_binding_decl {
  51. // CHECK:STDOUT: %T.patt: %pattern_type.98f = binding_pattern T [concrete]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %T: type = bind_name T, @__global_init.%i32
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @__global_init() {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  59. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: --- fail_implicit.impl.carbon
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: constants {
  66. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: imports {
  70. // CHECK:STDOUT: %Implicit.T: type = import_ref Implicit//default, T, loaded
  71. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  72. // CHECK:STDOUT: import Core//prelude
  73. // CHECK:STDOUT: import Core//prelude/...
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: file {
  78. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  79. // CHECK:STDOUT: .T = imports.%Implicit.T
  80. // CHECK:STDOUT: .Core = imports.%Core
  81. // CHECK:STDOUT: .a = %a
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %Implicit.import = import Implicit
  84. // CHECK:STDOUT: %default.import = import <none>
  85. // CHECK:STDOUT: %Core.import = import Core
  86. // CHECK:STDOUT: name_binding_decl {
  87. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a [concrete]
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%Implicit.T
  90. // CHECK:STDOUT: %a: <error> = bind_name a, <error>
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @__global_init() {
  94. // CHECK:STDOUT: !entry:
  95. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  96. // CHECK:STDOUT: return
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: