fail_param_redecl.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/function/declaration/fail_param_redecl.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_redecl.carbon
  10. // CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+6]]:14: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  11. // CHECK:STDERR: fn F(n: i32, n: i32);
  12. // CHECK:STDERR: ^
  13. // CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+3]]:6: note: name is previously declared here [NameDeclPrevious]
  14. // CHECK:STDERR: fn F(n: i32, n: i32);
  15. // CHECK:STDERR: ^
  16. fn F(n: i32, n: i32);
  17. // CHECK:STDOUT: --- fail_param_redecl.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  21. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  22. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  23. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  24. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  25. // CHECK:STDOUT: %F: %F.type = struct_value () [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: .F = %F.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  43. // CHECK:STDOUT: %n.patt.loc17_6: %i32 = binding_pattern n
  44. // CHECK:STDOUT: %n.param_patt.loc17_7: %i32 = value_param_pattern %n.patt.loc17_6, runtime_param0
  45. // CHECK:STDOUT: %n.patt.loc17_14: %i32 = binding_pattern n
  46. // CHECK:STDOUT: %n.param_patt.loc17_15: %i32 = value_param_pattern %n.patt.loc17_14, runtime_param1
  47. // CHECK:STDOUT: } {
  48. // CHECK:STDOUT: %int_32.loc17_9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  49. // CHECK:STDOUT: %int.make_type_signed.loc17_9: init type = call constants.%Int(%int_32.loc17_9) [template = constants.%i32]
  50. // CHECK:STDOUT: %.loc17_9.1: type = value_of_initializer %int.make_type_signed.loc17_9 [template = constants.%i32]
  51. // CHECK:STDOUT: %.loc17_9.2: type = converted %int.make_type_signed.loc17_9, %.loc17_9.1 [template = constants.%i32]
  52. // CHECK:STDOUT: %int_32.loc17_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  53. // CHECK:STDOUT: %int.make_type_signed.loc17_17: init type = call constants.%Int(%int_32.loc17_17) [template = constants.%i32]
  54. // CHECK:STDOUT: %.loc17_17.1: type = value_of_initializer %int.make_type_signed.loc17_17 [template = constants.%i32]
  55. // CHECK:STDOUT: %.loc17_17.2: type = converted %int.make_type_signed.loc17_17, %.loc17_17.1 [template = constants.%i32]
  56. // CHECK:STDOUT: %n.param.loc17_7: %i32 = value_param runtime_param0
  57. // CHECK:STDOUT: %n.loc17_6: %i32 = bind_name n, %n.param.loc17_7
  58. // CHECK:STDOUT: %n.param.loc17_15: %i32 = value_param runtime_param1
  59. // CHECK:STDOUT: %n.loc17_14: %i32 = bind_name n, %n.param.loc17_15
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @F(%n.param_patt.loc17_7: %i32, %n.param_patt.loc17_15: %i32);
  64. // CHECK:STDOUT: