fail_unimplemented_op.carbon 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/full.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/operators/builtin/fail_unimplemented_op.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon
  14. fn Main() -> i32 {
  15. // CHECK:STDERR: fail_unimplemented_op.carbon:[[@LINE+4]]:10: error: cannot access member of interface `Core.AddWith(Core.IntLiteral)` in type `{}` that does not implement that interface [MissingImplInMemberAccess]
  16. // CHECK:STDERR: return {} + 34;
  17. // CHECK:STDERR: ^~~~~~~
  18. // CHECK:STDERR:
  19. return {} + 34;
  20. }
  21. // CHECK:STDOUT: --- fail_unimplemented_op.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  25. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  26. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  28. // CHECK:STDOUT: %.941: form = init_form %i32, call_param0 [concrete]
  29. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  30. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  31. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  32. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  33. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  34. // CHECK:STDOUT: %int_34: Core.IntLiteral = int_value 34 [concrete]
  35. // CHECK:STDOUT: %AddWith.type.e05: type = generic_interface_type @AddWith [concrete]
  36. // CHECK:STDOUT: %AddWith.generic: %AddWith.type.e05 = struct_value () [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: .AddWith = %Core.AddWith
  43. // CHECK:STDOUT: import Core//prelude
  44. // CHECK:STDOUT: import Core//prelude/...
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  47. // CHECK:STDOUT: %Core.AddWith: %AddWith.type.e05 = import_ref Core//prelude/operators/arithmetic, AddWith, loaded [concrete = constants.%AddWith.generic]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  52. // CHECK:STDOUT: .Core = imports.%Core
  53. // CHECK:STDOUT: .Main = %Main.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Core.import = import Core
  56. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {
  57. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  58. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  59. // CHECK:STDOUT: } {
  60. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  61. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  62. // CHECK:STDOUT: %.loc15: form = init_form %i32, call_param0 [concrete = constants.%.941]
  63. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  64. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Main() -> %i32 {
  69. // CHECK:STDOUT: !entry:
  70. // CHECK:STDOUT: %.loc20: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  71. // CHECK:STDOUT: %int_34: Core.IntLiteral = int_value 34 [concrete = constants.%int_34]
  72. // CHECK:STDOUT: return <error> to %return.param
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: