shadowed_decl.carbon 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/shadowed_decl.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/shadowed_decl.carbon
  10. fn F(a: i32) -> i32 {
  11. let a: i32 = 1;
  12. // TODO: Reject this due to ambiguity.
  13. return a;
  14. }
  15. // CHECK:STDOUT: --- shadowed_decl.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  19. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  20. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  23. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  28. // CHECK:STDOUT: .Int32 = %import_ref
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/operators
  31. // CHECK:STDOUT: import Core//prelude/types
  32. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  33. // CHECK:STDOUT: import Core//prelude/operators/as
  34. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  35. // CHECK:STDOUT: import Core//prelude/operators/comparison
  36. // CHECK:STDOUT: import Core//prelude/types/bool
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .F = %F.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  48. // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32]
  49. // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32]
  50. // CHECK:STDOUT: %.loc11_9.2: type = converted %int.make_type_32.loc11_9, %.loc11_9.1 [template = i32]
  51. // CHECK:STDOUT: %a.loc11_6.1: i32 = param a, runtime_param0
  52. // CHECK:STDOUT: @F.%a.loc11: i32 = bind_name a, %a.loc11_6.1
  53. // CHECK:STDOUT: %int.make_type_32.loc11_17: init type = call constants.%Int32() [template = i32]
  54. // CHECK:STDOUT: %.loc11_17.1: type = value_of_initializer %int.make_type_32.loc11_17 [template = i32]
  55. // CHECK:STDOUT: %.loc11_17.2: type = converted %int.make_type_32.loc11_17, %.loc11_17.1 [template = i32]
  56. // CHECK:STDOUT: @F.%return: ref i32 = var <return slot>
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @F(%a.loc11: i32) -> i32 {
  63. // CHECK:STDOUT: !entry:
  64. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  65. // CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_32 [template = i32]
  66. // CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_32, %.loc12_10.1 [template = i32]
  67. // CHECK:STDOUT: %.loc12_16: i32 = int_literal 1 [template = constants.%.2]
  68. // CHECK:STDOUT: %a.loc12: i32 = bind_name a, %.loc12_16
  69. // CHECK:STDOUT: %a.ref: i32 = name_ref a, %a.loc12
  70. // CHECK:STDOUT: return %a.ref
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: