fail_symbolic.carbon 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/eval/fail_symbolic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/eval/fail_symbolic.carbon
  10. // TODO: This should work.
  11. fn G(N:! i32) {
  12. // CHECK:STDERR: fail_symbolic.carbon:[[@LINE+3]]:16: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  13. // CHECK:STDERR: var k: [i32; N];
  14. // CHECK:STDERR: ^
  15. var k: [i32; N];
  16. }
  17. // CHECK:STDOUT: --- fail_symbolic.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  21. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  22. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  23. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  24. // CHECK:STDOUT: %N.1: %i32 = bind_symbolic_name N, 0 [symbolic]
  25. // CHECK:STDOUT: %N.patt.1: %i32 = symbolic_binding_pattern N, 0 [symbolic]
  26. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  27. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  28. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
  29. // CHECK:STDOUT: %Convert.type.13: type = fn_type @Convert.4, @impl.3(%.1) [template]
  30. // CHECK:STDOUT: %Convert.13: %Convert.type.13 = struct_value () [template]
  31. // CHECK:STDOUT: %.19: <witness> = interface_witness (%Convert.13) [template]
  32. // CHECK:STDOUT: %.20: <bound method> = bound_method %N.1, %Convert.13 [symbolic]
  33. // CHECK:STDOUT: %.21: <specific function> = specific_function %.20, @Convert.4(%.1) [symbolic]
  34. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %.21(%N.1) [symbolic]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: imports {
  38. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  39. // CHECK:STDOUT: .Int = %import_ref.1
  40. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  41. // CHECK:STDOUT: import Core//prelude
  42. // CHECK:STDOUT: import Core//prelude/...
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: file {
  47. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  48. // CHECK:STDOUT: .Core = imports.%Core
  49. // CHECK:STDOUT: .G = %G.decl
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %Core.import = import Core
  52. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  53. // CHECK:STDOUT: %N.patt.loc12_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc12_6.2 (constants.%N.patt.1)]
  54. // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc12_6.1, runtime_param<invalid> [symbolic = %N.patt.loc12_6.2 (constants.%N.patt.1)]
  55. // CHECK:STDOUT: } {
  56. // CHECK:STDOUT: %.loc12_10.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  57. // CHECK:STDOUT: %int.make_type_signed.loc12: init type = call constants.%Int(%.loc12_10.1) [template = constants.%i32]
  58. // CHECK:STDOUT: %.loc12_10.2: type = value_of_initializer %int.make_type_signed.loc12 [template = constants.%i32]
  59. // CHECK:STDOUT: %.loc12_10.3: type = converted %int.make_type_signed.loc12, %.loc12_10.2 [template = constants.%i32]
  60. // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
  61. // CHECK:STDOUT: %N.loc12_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc12_6.2 (constants.%N.1)]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: generic fn @G(%N.loc12_6.1: %i32) {
  66. // CHECK:STDOUT: %N.loc12_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc12_6.2 (constants.%N.1)]
  67. // CHECK:STDOUT: %N.patt.loc12_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc12_6.2 (constants.%N.patt.1)]
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !definition:
  70. // CHECK:STDOUT: %.loc16_16.6: <bound method> = bound_method %N.loc12_6.2, constants.%Convert.13 [symbolic = %.loc16_16.6 (constants.%.20)]
  71. // CHECK:STDOUT: %.loc16_16.7: <specific function> = specific_function %.loc16_16.6, @Convert.4(constants.%.1) [symbolic = %.loc16_16.7 (constants.%.21)]
  72. // CHECK:STDOUT: %int.convert_checked.loc16_16.2: init Core.IntLiteral = call %.loc16_16.7(%N.loc12_6.2) [symbolic = %int.convert_checked.loc16_16.2 (constants.%int.convert_checked)]
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn(%N.param_patt: %i32) {
  75. // CHECK:STDOUT: !entry:
  76. // CHECK:STDOUT: %.loc16_11.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  77. // CHECK:STDOUT: %int.make_type_signed.loc16: init type = call constants.%Int(%.loc16_11.1) [template = constants.%i32]
  78. // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc12_6.1 [symbolic = %N.loc12_6.2 (constants.%N.1)]
  79. // CHECK:STDOUT: %.loc16_11.2: type = value_of_initializer %int.make_type_signed.loc16 [template = constants.%i32]
  80. // CHECK:STDOUT: %.loc16_11.3: type = converted %int.make_type_signed.loc16, %.loc16_11.2 [template = constants.%i32]
  81. // CHECK:STDOUT: %.loc16_16.1: %Convert.type.2 = interface_witness_access constants.%.19, element0 [template = constants.%Convert.13]
  82. // CHECK:STDOUT: %.loc16_16.2: <bound method> = bound_method %N.ref, %.loc16_16.1 [symbolic = %.loc16_16.6 (constants.%.20)]
  83. // CHECK:STDOUT: %.loc16_16.3: <specific function> = specific_function %.loc16_16.2, @Convert.4(constants.%.1) [symbolic = %.loc16_16.7 (constants.%.21)]
  84. // CHECK:STDOUT: %int.convert_checked.loc16_16.1: init Core.IntLiteral = call %.loc16_16.3(%N.ref) [symbolic = %int.convert_checked.loc16_16.2 (constants.%int.convert_checked)]
  85. // CHECK:STDOUT: %.loc16_16.4: Core.IntLiteral = value_of_initializer %int.convert_checked.loc16_16.1 [symbolic = %int.convert_checked.loc16_16.2 (constants.%int.convert_checked)]
  86. // CHECK:STDOUT: %.loc16_16.5: Core.IntLiteral = converted %N.ref, %.loc16_16.4 [symbolic = %int.convert_checked.loc16_16.2 (constants.%int.convert_checked)]
  87. // CHECK:STDOUT: %.loc16_17: type = array_type %.loc16_16.5, %i32 [template = <error>]
  88. // CHECK:STDOUT: %k.var: ref <error> = var k
  89. // CHECK:STDOUT: %k: ref <error> = bind_name k, %k.var
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: specific @G(constants.%N.1) {
  95. // CHECK:STDOUT: %N.loc12_6.2 => constants.%N.1
  96. // CHECK:STDOUT: %N.patt.loc12_6.2 => constants.%N.1
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: