non_generic.carbon 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/where_expr/non_generic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/non_generic.carbon
  10. interface I { let T:! type; }
  11. // Ensure that we don't crash when checking this `where` in a non-generic context.
  12. fn NotGenericF(U: I where .T == i32) {}
  13. // CHECK:STDOUT: --- non_generic.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %I.type: type = interface_type @I [template]
  17. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  18. // CHECK:STDOUT: %.1: type = assoc_entity_type %I.type, type [template]
  19. // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @I.%T [template]
  20. // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic]
  21. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  23. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  24. // CHECK:STDOUT: %NotGenericF.type: type = fn_type @NotGenericF [template]
  25. // CHECK:STDOUT: %NotGenericF: %NotGenericF.type = struct_value () [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .Int32 = %import_ref
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/operators
  33. // CHECK:STDOUT: import Core//prelude/types
  34. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  35. // CHECK:STDOUT: import Core//prelude/operators/as
  36. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  37. // CHECK:STDOUT: import Core//prelude/operators/comparison
  38. // CHECK:STDOUT: import Core//prelude/types/bool
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .I = %I.decl
  47. // CHECK:STDOUT: .NotGenericF = %NotGenericF.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  51. // CHECK:STDOUT: %NotGenericF.decl: %NotGenericF.type = fn_decl @NotGenericF [template = constants.%NotGenericF] {
  52. // CHECK:STDOUT: %U.patt: %I.type = binding_pattern U
  53. // CHECK:STDOUT: %U.param_patt: %I.type = param_pattern %U.patt, runtime_param0
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  56. // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self]
  57. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self]
  58. // CHECK:STDOUT: %T.ref: %.1 = name_ref T, @I.%.loc11 [template = constants.%.2]
  59. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  60. // CHECK:STDOUT: %.loc14: type = where_expr %.Self [template = constants.%I.type] {
  61. // CHECK:STDOUT: requirement_equivalent %T.ref, %int.make_type_32
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %param: %I.type = param runtime_param0
  64. // CHECK:STDOUT: %U: %I.type = bind_name U, %param
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: interface @I {
  69. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  70. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  71. // CHECK:STDOUT: %.loc11: %.1 = assoc_entity element0, %T [template = constants.%.2]
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: .Self = %Self
  75. // CHECK:STDOUT: .T = %.loc11
  76. // CHECK:STDOUT: witness = (%T)
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: fn @NotGenericF(%U.param_patt: %I.type) {
  82. // CHECK:STDOUT: !entry:
  83. // CHECK:STDOUT: return
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: