fail_unimplemented_op.carbon 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/operators/builtin/fail_unimplemented_op.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon
  10. fn Main() -> i32 {
  11. // CHECK:STDERR: fail_unimplemented_op.carbon:[[@LINE+4]]:10: error: cannot access member of interface `Core.Add` in type `{}` that does not implement that interface [MissingImplInMemberAccess]
  12. // CHECK:STDERR: return {} + 34;
  13. // CHECK:STDERR: ^~~~~~~
  14. // CHECK:STDERR:
  15. return {} + 34;
  16. }
  17. // CHECK:STDOUT: --- fail_unimplemented_op.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  21. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  22. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  24. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  25. // CHECK:STDOUT: %int_34: Core.IntLiteral = int_value 34 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .Int = %Core.Int
  31. // CHECK:STDOUT: .Add = %Core.Add
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/...
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .Core = imports.%Core
  40. // CHECK:STDOUT: .Main = %Main.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.import = import Core
  43. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {
  44. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  45. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  46. // CHECK:STDOUT: } {
  47. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  48. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  49. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  50. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @Main() -> %i32 {
  55. // CHECK:STDOUT: !entry:
  56. // CHECK:STDOUT: %.loc16: %empty_struct_type = struct_literal ()
  57. // CHECK:STDOUT: %int_34: Core.IntLiteral = int_value 34 [template = constants.%int_34]
  58. // CHECK:STDOUT: return <error>
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: