fail_generic_import.carbon 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/let/fail_generic_import.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/fail_generic_import.carbon
  14. // --- fail_implicit.carbon
  15. package Implicit;
  16. // CHECK:STDERR: fail_implicit.carbon:[[@LINE+4]]:5: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  17. // CHECK:STDERR: let T:! type = i32;
  18. // CHECK:STDERR: ^~~~~~~~
  19. // CHECK:STDERR:
  20. let T:! type = i32;
  21. // --- fail_implicit.impl.carbon
  22. impl package Implicit;
  23. // TODO: Should this be valid?
  24. // CHECK:STDERR: fail_implicit.impl.carbon:[[@LINE+4]]:8: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  25. // CHECK:STDERR: let a: T = 0;
  26. // CHECK:STDERR: ^
  27. // CHECK:STDERR:
  28. let a: T = 0;
  29. // CHECK:STDOUT: --- fail_implicit.carbon
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: constants {
  32. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  33. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  34. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  35. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: imports {
  40. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  41. // CHECK:STDOUT: .Int = %Core.Int
  42. // CHECK:STDOUT: import Core//prelude
  43. // CHECK:STDOUT: import Core//prelude/...
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  50. // CHECK:STDOUT: .Core = imports.%Core
  51. // CHECK:STDOUT: .T = %T
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.import = import Core
  54. // CHECK:STDOUT: name_binding_decl {
  55. // CHECK:STDOUT: %T.patt: %pattern_type.98f = binding_pattern T [concrete]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %T: type = bind_name T, @__global_init.%i32
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @__global_init() {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  63. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  64. // CHECK:STDOUT: return
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: --- fail_implicit.impl.carbon
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: constants {
  70. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: imports {
  74. // CHECK:STDOUT: %Implicit.T: type = import_ref Implicit//default, T, loaded
  75. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  76. // CHECK:STDOUT: import Core//prelude
  77. // CHECK:STDOUT: import Core//prelude/...
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: file {
  82. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  83. // CHECK:STDOUT: .T = imports.%Implicit.T
  84. // CHECK:STDOUT: .Core = imports.%Core
  85. // CHECK:STDOUT: .a = %a
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: %Implicit.import = import Implicit
  88. // CHECK:STDOUT: %default.import = import <none>
  89. // CHECK:STDOUT: %Core.import = import Core
  90. // CHECK:STDOUT: name_binding_decl {
  91. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a [concrete]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%Implicit.T
  94. // CHECK:STDOUT: %a: <error> = bind_name a, <error> [concrete = <error>]
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: fn @__global_init() {
  98. // CHECK:STDOUT: !entry:
  99. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  100. // CHECK:STDOUT: return
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: