fail_name_not_found.carbon 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/index/fail_name_not_found.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_name_not_found.carbon
  10. fn Main() {
  11. // CHECK:STDERR: fail_name_not_found.carbon:[[@LINE+3]]:16: error: name `a` not found [NameNotFound]
  12. // CHECK:STDERR: var b: i32 = a[0];
  13. // CHECK:STDERR: ^
  14. var b: i32 = a[0];
  15. }
  16. // CHECK:STDOUT: --- fail_name_not_found.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  21. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  22. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  23. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  24. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  25. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 0 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .Int = %import_ref
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/...
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = imports.%Core
  39. // CHECK:STDOUT: .Main = %Main.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @Main() {
  46. // CHECK:STDOUT: !entry:
  47. // CHECK:STDOUT: %.loc15_10.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  48. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc15_10.1) [template = constants.%i32]
  49. // CHECK:STDOUT: %.loc15_10.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  50. // CHECK:STDOUT: %.loc15_10.3: type = converted %int.make_type_signed, %.loc15_10.2 [template = constants.%i32]
  51. // CHECK:STDOUT: %b.var: ref %i32 = var b
  52. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  53. // CHECK:STDOUT: %a.ref: <error> = name_ref a, <error> [template = <error>]
  54. // CHECK:STDOUT: %.loc15_18: Core.IntLiteral = int_value 0 [template = constants.%.2]
  55. // CHECK:STDOUT: assign %b.var, <error>
  56. // CHECK:STDOUT: return
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: