fail_param_redecl.carbon 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/declaration/fail_param_redecl.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_redecl.carbon
  14. // CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+7]]:14: error: duplicate name `n` being declared in the same scope [NameDeclDuplicate]
  15. // CHECK:STDERR: fn F(n: i32, n: i32);
  16. // CHECK:STDERR: ^
  17. // CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+4]]:6: note: name is previously declared here [NameDeclPrevious]
  18. // CHECK:STDERR: fn F(n: i32, n: i32);
  19. // CHECK:STDERR: ^
  20. // CHECK:STDERR:
  21. fn F(n: i32, n: i32);
  22. // CHECK:STDOUT: --- fail_param_redecl.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  26. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  27. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  29. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  30. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  31. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  36. // CHECK:STDOUT: .Int = %Core.Int
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .F = %F.decl
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %Core.import = import Core
  49. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  50. // CHECK:STDOUT: %n.patt.loc22_6: %pattern_type.7ce = binding_pattern n [concrete]
  51. // CHECK:STDOUT: %n.param_patt.loc22_7: %pattern_type.7ce = value_param_pattern %n.patt.loc22_6, call_param0 [concrete]
  52. // CHECK:STDOUT: %n.patt.loc22_14: %pattern_type.7ce = binding_pattern n [concrete]
  53. // CHECK:STDOUT: %n.param_patt.loc22_15: %pattern_type.7ce = value_param_pattern %n.patt.loc22_14, call_param1 [concrete]
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %n.param.loc22_7: %i32 = value_param call_param0
  56. // CHECK:STDOUT: %.loc22_9: type = splice_block %i32.loc22_9 [concrete = constants.%i32] {
  57. // CHECK:STDOUT: %int_32.loc22_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  58. // CHECK:STDOUT: %i32.loc22_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %n.loc22_6: %i32 = bind_name n, %n.param.loc22_7
  61. // CHECK:STDOUT: %n.param.loc22_15: %i32 = value_param call_param1
  62. // CHECK:STDOUT: %.loc22_17: type = splice_block %i32.loc22_17 [concrete = constants.%i32] {
  63. // CHECK:STDOUT: %int_32.loc22_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  64. // CHECK:STDOUT: %i32.loc22_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %n.loc22_14: %i32 = bind_name n, %n.param.loc22_15
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @F(%n.param.loc22_7: %i32, %n.param.loc22_15: %i32);
  71. // CHECK:STDOUT: