fail_missing_value.carbon 3.2 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/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 [ExpectedInitializerAfterLet]
  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 [ExpectedInitializerAfterLet]
  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: %.1: Core.IntLiteral = int_value 32 [template]
  25. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  26. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  27. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  28. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  29. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: .Int = %import_ref
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .n = %n
  44. // CHECK:STDOUT: .F = %F.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %.loc15_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  48. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_8.1) [template = constants.%i32]
  49. // CHECK:STDOUT: %.loc15_8.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  50. // CHECK:STDOUT: %.loc15_8.3: type = converted %int.make_type_signed, %.loc15_8.2 [template = constants.%i32]
  51. // CHECK:STDOUT: %n: %i32 = bind_name n, <error>
  52. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: fn @F() {
  56. // CHECK:STDOUT: !entry:
  57. // CHECK:STDOUT: %.loc21_10.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  58. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc21_10.1) [template = constants.%i32]
  59. // CHECK:STDOUT: %.loc21_10.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  60. // CHECK:STDOUT: %.loc21_10.3: type = converted %int.make_type_signed, %.loc21_10.2 [template = constants.%i32]
  61. // CHECK:STDOUT: %n: %i32 = bind_name n, <error>
  62. // CHECK:STDOUT: return
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: