fail_missing_value.carbon 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/let/fail_missing_value.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/fail_missing_value.carbon
  10. // CHECK:STDERR: fail_missing_value.carbon:[[@LINE+4]]:11: error: expected `=`; `let` declaration must have an initializer
  11. // CHECK:STDERR: let n: i32;
  12. // CHECK:STDERR: ^
  13. // CHECK:STDERR:
  14. let n: i32;
  15. fn F() {
  16. // CHECK:STDERR: fail_missing_value.carbon:[[@LINE+3]]:13: error: expected `=`; `let` declaration must have an initializer
  17. // CHECK:STDERR: let n: i32;
  18. // CHECK:STDERR: ^
  19. let n: i32;
  20. }
  21. // CHECK:STDOUT: --- fail_missing_value.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  25. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  26. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  27. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  28. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: .Int32 = %import_ref
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/operators
  36. // CHECK:STDOUT: import Core//prelude/types
  37. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  38. // CHECK:STDOUT: import Core//prelude/operators/as
  39. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  40. // CHECK:STDOUT: import Core//prelude/operators/comparison
  41. // CHECK:STDOUT: import Core//prelude/types/bool
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: file {
  47. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  48. // CHECK:STDOUT: .Core = imports.%Core
  49. // CHECK:STDOUT: .n = %n
  50. // CHECK:STDOUT: .F = %F.decl
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Core.import = import Core
  53. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  54. // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32 [template = i32]
  55. // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32, %.loc15_8.1 [template = i32]
  56. // CHECK:STDOUT: %n: i32 = bind_name n, <error>
  57. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @F() {
  63. // CHECK:STDOUT: !entry:
  64. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  65. // CHECK:STDOUT: %.loc21_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  66. // CHECK:STDOUT: %.loc21_10.2: type = converted %int.make_type_32, %.loc21_10.1 [template = i32]
  67. // CHECK:STDOUT: %n: i32 = bind_name n, <error>
  68. // CHECK:STDOUT: return
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: