duplicate_name_same_line.carbon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. // EXTRA-ARGS: --dump-sem-ir-ranges=only
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/no_prelude/duplicate_name_same_line.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/no_prelude/duplicate_name_same_line.carbon
  12. fn A() {
  13. if (true) {
  14. // This declares `n` in two different scopes, it's just showing the IR
  15. // behavior of having both on the same line.
  16. //@dump-sem-ir-begin
  17. var n: (); } else { var n: ();
  18. //@dump-sem-ir-end
  19. }
  20. }
  21. // CHECK:STDOUT: --- duplicate_name_same_line.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  25. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: fn @A() {
  29. // CHECK:STDOUT: !entry:
  30. // CHECK:STDOUT: <elided>
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: !if.then:
  33. // CHECK:STDOUT: name_binding_decl {
  34. // CHECK:STDOUT: %n.patt.loc18_9: %pattern_type = binding_pattern n [concrete]
  35. // CHECK:STDOUT: %n.var_patt.loc18_5: %pattern_type = var_pattern %n.patt.loc18_9 [concrete]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %n.var.loc18_5: ref %empty_tuple.type = var %n.var_patt.loc18_5
  38. // CHECK:STDOUT: %.loc18_13.1: type = splice_block %.loc18_13.3 [concrete = constants.%empty_tuple.type] {
  39. // CHECK:STDOUT: %.loc18_13.2: %empty_tuple.type = tuple_literal ()
  40. // CHECK:STDOUT: %.loc18_13.3: type = converted %.loc18_13.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %n.loc18_9: ref %empty_tuple.type = bind_name n, %n.var.loc18_5
  43. // CHECK:STDOUT: <elided>
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: !if.else:
  46. // CHECK:STDOUT: name_binding_decl {
  47. // CHECK:STDOUT: %n.patt.loc18_29: %pattern_type = binding_pattern n [concrete]
  48. // CHECK:STDOUT: %n.var_patt.loc18_25: %pattern_type = var_pattern %n.patt.loc18_29 [concrete]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %n.var.loc18_25: ref %empty_tuple.type = var %n.var_patt.loc18_25
  51. // CHECK:STDOUT: %.loc18_33.1: type = splice_block %.loc18_33.3 [concrete = constants.%empty_tuple.type] {
  52. // CHECK:STDOUT: %.loc18_33.2: %empty_tuple.type = tuple_literal ()
  53. // CHECK:STDOUT: %.loc18_33.3: type = converted %.loc18_33.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %n.loc18_29: ref %empty_tuple.type = bind_name n, %n.var.loc18_25
  56. // CHECK:STDOUT: <elided>
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !if.done:
  59. // CHECK:STDOUT: <elided>
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: