fail_not_callable.carbon 2.7 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/function/call/fail_not_callable.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_not_callable.carbon
  10. fn Run() {
  11. // CHECK:STDERR: fail_not_callable.carbon:[[@LINE+4]]:16: error: value of type `String` is not callable [CallToNonCallable]
  12. // CHECK:STDERR: var x: i32 = "hello"();
  13. // CHECK:STDERR: ^~~~~~~~~
  14. // CHECK:STDERR:
  15. var x: i32 = "hello"();
  16. }
  17. // CHECK:STDOUT: --- fail_not_callable.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  21. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  22. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  23. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  24. // CHECK:STDOUT: %str: String = string_literal "hello" [concrete]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  29. // CHECK:STDOUT: .Int = %Core.Int
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: import Core//prelude/...
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .Run = %Run.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.import = import Core
  41. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @Run() {
  45. // CHECK:STDOUT: !entry:
  46. // CHECK:STDOUT: name_binding_decl {
  47. // CHECK:STDOUT: %x.patt: %i32 = binding_pattern x
  48. // CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %x.patt
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %x.var: ref %i32 = var x
  51. // CHECK:STDOUT: %str: String = string_literal "hello" [concrete = constants.%str]
  52. // CHECK:STDOUT: assign %x.var, <error>
  53. // CHECK:STDOUT: %.loc16_10: type = splice_block %i32 [concrete = constants.%i32] {
  54. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  55. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var
  58. // CHECK:STDOUT: return
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: