fail_not_callable.carbon 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .Int32 = %import_ref
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/operators
  33. // CHECK:STDOUT: import Core//prelude/types
  34. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  35. // CHECK:STDOUT: import Core//prelude/operators/as
  36. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  37. // CHECK:STDOUT: import Core//prelude/operators/comparison
  38. // CHECK:STDOUT: import Core//prelude/types/bool
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .Run = %Run.decl
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %Core.import = import Core
  49. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} {}
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @Run() {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  55. // CHECK:STDOUT: %.loc15_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  56. // CHECK:STDOUT: %.loc15_10.2: type = converted %int.make_type_32, %.loc15_10.1 [template = i32]
  57. // CHECK:STDOUT: %x.var: ref i32 = var x
  58. // CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
  59. // CHECK:STDOUT: %.loc15_16: String = string_literal "hello" [template = constants.%.3]
  60. // CHECK:STDOUT: assign %x.var, <error>
  61. // CHECK:STDOUT: return
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  65. // CHECK:STDOUT: