fail_missing_value.carbon 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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+4]]:13: error: expected `=`; `let` declaration must have an initializer [ExpectedInitializerAfterLet]
  17. // CHECK:STDERR: let n: i32;
  18. // CHECK:STDERR: ^
  19. // CHECK:STDERR:
  20. let n: i32;
  21. }
  22. // CHECK:STDOUT: --- fail_missing_value.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  26. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  27. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  29. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  30. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  31. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  36. // CHECK:STDOUT: .Int = %Core.Int
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .n = <unexpected>.inst45.loc15_5
  47. // CHECK:STDOUT: .F = %F.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: name_binding_decl {
  51. // CHECK:STDOUT: %n.patt: %pattern_type.7ce = binding_pattern n [concrete]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @F() {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: name_binding_decl {
  59. // CHECK:STDOUT: %n.patt: %pattern_type.7ce = binding_pattern n [concrete]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: return
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: