fail_not_callable.carbon 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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+3]]:16: error: value of type `String` is not callable [CallToNonCallable]
  12. // CHECK:STDERR: var x: i32 = "hello"();
  13. // CHECK:STDERR: ^~~~~~~~~
  14. var x: i32 = "hello"();
  15. }
  16. // CHECK:STDOUT: --- fail_not_callable.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Run.type: type = fn_type @Run [template]
  20. // CHECK:STDOUT: %Run: %Run.type = struct_value () [template]
  21. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  22. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  23. // CHECK:STDOUT: %str: String = string_literal "hello" [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  28. // CHECK:STDOUT: .Int = %import_ref.187
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .Run = %Run.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @Run() {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: %x.var: ref %i32 = var x
  46. // CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var
  47. // CHECK:STDOUT: %str: String = string_literal "hello" [template = constants.%str]
  48. // CHECK:STDOUT: assign %x.var, <error>
  49. // CHECK:STDOUT: return
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: