fail_param_redecl.carbon 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: %Int32.type: type = fn_type @Int32 [template]
  21. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  22. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [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/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .F = %F.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  41. // CHECK:STDOUT: %n.patt.loc17_6: i32 = binding_pattern n
  42. // CHECK:STDOUT: %n.param_patt.loc17_7: i32 = value_param_pattern %n.patt.loc17_6, runtime_param0
  43. // CHECK:STDOUT: %n.patt.loc17_14: i32 = binding_pattern n
  44. // CHECK:STDOUT: %n.param_patt.loc17_15: i32 = value_param_pattern %n.patt.loc17_14, runtime_param1
  45. // CHECK:STDOUT: } {
  46. // CHECK:STDOUT: %int.make_type_32.loc17_9: init type = call constants.%Int32() [template = i32]
  47. // CHECK:STDOUT: %.loc17_9.1: type = value_of_initializer %int.make_type_32.loc17_9 [template = i32]
  48. // CHECK:STDOUT: %.loc17_9.2: type = converted %int.make_type_32.loc17_9, %.loc17_9.1 [template = i32]
  49. // CHECK:STDOUT: %int.make_type_32.loc17_17: init type = call constants.%Int32() [template = i32]
  50. // CHECK:STDOUT: %.loc17_17.1: type = value_of_initializer %int.make_type_32.loc17_17 [template = i32]
  51. // CHECK:STDOUT: %.loc17_17.2: type = converted %int.make_type_32.loc17_17, %.loc17_17.1 [template = i32]
  52. // CHECK:STDOUT: %n.param.loc17_7: i32 = value_param runtime_param0
  53. // CHECK:STDOUT: %n.loc17_6: i32 = bind_name n, %n.param.loc17_7
  54. // CHECK:STDOUT: %n.param.loc17_15: i32 = value_param runtime_param1
  55. // CHECK:STDOUT: %n.loc17_14: i32 = bind_name n, %n.param.loc17_15
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @F(%n.param_patt.loc17_7: i32, %n.param_patt.loc17_15: i32);
  60. // CHECK:STDOUT: