fail_runtime_implicit_param.carbon 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/none.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/call/fail_runtime_implicit_param.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_runtime_implicit_param.carbon
  14. // CHECK:STDERR: fail_runtime_implicit_param.carbon:[[@LINE+4]]:6: error: implicit parameters of functions must be constant or `self` [ImplictParamMustBeConstant]
  15. // CHECK:STDERR: fn F[s: ()]();
  16. // CHECK:STDERR: ^~~~~
  17. // CHECK:STDERR:
  18. fn F[s: ()]();
  19. fn Run() {
  20. F();
  21. }
  22. // CHECK:STDOUT: --- fail_runtime_implicit_param.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  26. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  27. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  29. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  34. // CHECK:STDOUT: .F = %F.decl
  35. // CHECK:STDOUT: .Run = %Run.decl
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  38. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: fn @F();
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @Run() {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  46. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: