fail_not_callable.carbon 2.5 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.
  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: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Run: %Run.type = struct_value () [template]
  22. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  23. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  24. // CHECK:STDOUT: %.2: type = ptr_type String [template]
  25. // CHECK:STDOUT: %.3: String = string_literal "hello" [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = %Core
  31. // CHECK:STDOUT: .Run = %Run.decl
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  34. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {}
  35. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: fn @Run() {
  39. // CHECK:STDOUT: !entry:
  40. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  41. // CHECK:STDOUT: %.loc15_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  42. // CHECK:STDOUT: %.loc15_10.2: type = converted %int.make_type_32, %.loc15_10.1 [template = i32]
  43. // CHECK:STDOUT: %x.var: ref i32 = var x
  44. // CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
  45. // CHECK:STDOUT: %.loc15_16: String = string_literal "hello" [template = constants.%.3]
  46. // CHECK:STDOUT: assign %x.var, <error>
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  51. // CHECK:STDOUT: