fail_name_not_found.carbon 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/index/fail_name_not_found.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_name_not_found.carbon
  14. fn Main() {
  15. // CHECK:STDERR: fail_name_not_found.carbon:[[@LINE+4]]:16: error: name `a` not found [NameNotFound]
  16. // CHECK:STDERR: var b: i32 = a[0];
  17. // CHECK:STDERR: ^
  18. // CHECK:STDERR:
  19. var b: i32 = a[0];
  20. }
  21. // CHECK:STDOUT: --- fail_name_not_found.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  25. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  26. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  28. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  29. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  30. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  31. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  32. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  33. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  34. // CHECK:STDOUT: %DestroyOp.type: type = fn_type @DestroyOp [concrete]
  35. // CHECK:STDOUT: %DestroyOp: %DestroyOp.type = struct_value () [concrete]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: imports {
  39. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  40. // CHECK:STDOUT: .Int = %Core.Int
  41. // CHECK:STDOUT: .Destroy = %Core.Destroy
  42. // CHECK:STDOUT: import Core//prelude
  43. // CHECK:STDOUT: import Core//prelude/...
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  46. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  51. // CHECK:STDOUT: .Core = imports.%Core
  52. // CHECK:STDOUT: .Main = %Main.decl
  53. // CHECK:STDOUT: .a = <poisoned>
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Core.import = import Core
  56. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @Main() {
  60. // CHECK:STDOUT: !entry:
  61. // CHECK:STDOUT: name_binding_decl {
  62. // CHECK:STDOUT: %b.patt: %pattern_type.7ce = ref_binding_pattern b [concrete]
  63. // CHECK:STDOUT: %b.var_patt: %pattern_type.7ce = var_pattern %b.patt [concrete]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %b.var: ref %i32 = var %b.var_patt
  66. // CHECK:STDOUT: %a.ref: <error> = name_ref a, <error> [concrete = <error>]
  67. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  68. // CHECK:STDOUT: assign %b.var, <error>
  69. // CHECK:STDOUT: %.loc20: type = splice_block %i32 [concrete = constants.%i32] {
  70. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  71. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %b: ref %i32 = ref_binding b, %b.var
  74. // CHECK:STDOUT: %DestroyOp.bound: <bound method> = bound_method %b.var, constants.%DestroyOp
  75. // CHECK:STDOUT: %DestroyOp.call: init %empty_tuple.type = call %DestroyOp.bound(%b.var)
  76. // CHECK:STDOUT: return
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @DestroyOp(%self.param: %i32) = "no_op";
  80. // CHECK:STDOUT: