fail_unimplemented_op.carbon 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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+3]]:10: error: cannot access member of interface `Add` in type `Core.IntLiteral` that does not implement that interface [MissingImplInMemberAccess]
  12. // CHECK:STDERR: return 12 + 34;
  13. // CHECK:STDERR: ^~~~~~~
  14. return 12 + 34;
  15. }
  16. // CHECK:STDOUT: --- fail_unimplemented_op.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  20. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  21. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  22. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  23. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  24. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  25. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 12 [template]
  26. // CHECK:STDOUT: %.3: Core.IntLiteral = int_value 34 [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: .Int = %import_ref.1
  32. // CHECK:STDOUT: .Add = %import_ref.2
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/...
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .Core = imports.%Core
  41. // CHECK:STDOUT: .Main = %Main.decl
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {
  45. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  46. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  47. // CHECK:STDOUT: } {
  48. // CHECK:STDOUT: %.loc11_14.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  49. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc11_14.1) [template = constants.%i32]
  50. // CHECK:STDOUT: %.loc11_14.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  51. // CHECK:STDOUT: %.loc11_14.3: type = converted %int.make_type_signed, %.loc11_14.2 [template = constants.%i32]
  52. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  53. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: fn @Main() -> %i32 {
  58. // CHECK:STDOUT: !entry:
  59. // CHECK:STDOUT: %.loc15_10: Core.IntLiteral = int_value 12 [template = constants.%.2]
  60. // CHECK:STDOUT: %.loc15_15: Core.IntLiteral = int_value 34 [template = constants.%.3]
  61. // CHECK:STDOUT: return <error>
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: