fail_params.carbon 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/namespace/fail_params.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/fail_params.carbon
  10. // CHECK:STDERR: fail_params.carbon:[[@LINE+4]]:12: ERROR: `namespace` declaration cannot have parameters.
  11. // CHECK:STDERR: namespace A();
  12. // CHECK:STDERR: ^~
  13. // CHECK:STDERR:
  14. namespace A();
  15. // Parameters are ignored for error recovery.
  16. fn A.F() {}
  17. // CHECK:STDERR: fail_params.carbon:[[@LINE+4]]:12: ERROR: `namespace` declaration cannot have parameters.
  18. // CHECK:STDERR: namespace B(n: i32);
  19. // CHECK:STDERR: ^~~~~~~~
  20. // CHECK:STDERR:
  21. namespace B(n: i32);
  22. // CHECK:STDERR: fail_params.carbon:[[@LINE+4]]:12: ERROR: `namespace` declaration cannot have parameters.
  23. // CHECK:STDERR: namespace C[T:! type](x: T);
  24. // CHECK:STDERR: ^~~~~~~~~~
  25. // CHECK:STDERR:
  26. namespace C[T:! type](x: T);
  27. namespace D;
  28. // CHECK:STDERR: fail_params.carbon:[[@LINE+6]]:4: ERROR: Redeclaration differs because of parameter list.
  29. // CHECK:STDERR: fn D(T:! type).F() {}
  30. // CHECK:STDERR: ^
  31. // CHECK:STDERR: fail_params.carbon:[[@LINE-4]]:1: Previously declared without parameter list.
  32. // CHECK:STDERR: namespace D;
  33. // CHECK:STDERR: ^~~~~~~~~~~~
  34. fn D(T:! type).F() {}
  35. // CHECK:STDOUT: --- fail_params.carbon
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: constants {
  38. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  39. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  40. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  41. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  42. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  43. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  44. // CHECK:STDOUT: %.type: type = fn_type @.1 [template]
  45. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  50. // CHECK:STDOUT: .Core = %Core
  51. // CHECK:STDOUT: .A = %A
  52. // CHECK:STDOUT: .B = %B
  53. // CHECK:STDOUT: .C = %C
  54. // CHECK:STDOUT: .D = %D
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  57. // CHECK:STDOUT: %A: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .F = %F.decl
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  61. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  62. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  63. // CHECK:STDOUT: %.loc24_16.1: type = value_of_initializer %int.make_type_32 [template = i32]
  64. // CHECK:STDOUT: %.loc24_16.2: type = converted %int.make_type_32, %.loc24_16.1 [template = i32]
  65. // CHECK:STDOUT: %n.loc24_13.1: i32 = param n
  66. // CHECK:STDOUT: %n.loc24_13.2: i32 = bind_name n, %n.loc24_13.1
  67. // CHECK:STDOUT: %B: <namespace> = namespace [template] {}
  68. // CHECK:STDOUT: %T.loc30_13.1: type = param T
  69. // CHECK:STDOUT: %T.loc30_13.2: type = bind_symbolic_name T 0, %T.loc30_13.1 [symbolic = constants.%T]
  70. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc30_13.2 [symbolic = constants.%T]
  71. // CHECK:STDOUT: %x.loc30_23.1: %T = param x
  72. // CHECK:STDOUT: %x.loc30_23.2: %T = bind_name x, %x.loc30_23.1
  73. // CHECK:STDOUT: %C: <namespace> = namespace [template] {}
  74. // CHECK:STDOUT: %D: <namespace> = namespace [template] {}
  75. // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {
  76. // CHECK:STDOUT: %T.loc39_6.1: type = param T
  77. // CHECK:STDOUT: %T.loc39_6.2: type = bind_symbolic_name T 0, %T.loc39_6.1 [symbolic = constants.%T]
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: fn @F() {
  82. // CHECK:STDOUT: !entry:
  83. // CHECK:STDOUT: return
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: fn @.1() {
  89. // CHECK:STDOUT: !entry:
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: