fail_lookup_outside_scope.carbon 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/var/no_prelude/fail_lookup_outside_scope.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon
  10. fn Main() {
  11. var x: ();
  12. }
  13. // CHECK:STDERR: fail_lookup_outside_scope.carbon:[[@LINE+3]]:13: error: name `x` not found [NameNotFound]
  14. // CHECK:STDERR: var y: () = x;
  15. // CHECK:STDERR: ^
  16. var y: () = x;
  17. // CHECK:STDOUT: --- fail_lookup_outside_scope.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  21. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .Main = %Main.decl
  28. // CHECK:STDOUT: .y = %y
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  31. // CHECK:STDOUT: %y.var: ref %empty_tuple.type = var y
  32. // CHECK:STDOUT: %y: ref %empty_tuple.type = bind_name y, %y.var
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @Main() {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  38. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  39. // CHECK:STDOUT: return
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @__global_init() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [template = <error>]
  45. // CHECK:STDOUT: assign file.%y.var, <error>
  46. // CHECK:STDOUT: return
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: