positional.carbon 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/builtin/positional.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/positional.carbon
  14. // --- fail_positional.carbon
  15. // CHECK:STDERR: fail_positional.carbon:[[@LINE+8]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
  16. // CHECK:STDERR: fn Add -> i32 = "int.sadd";
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  18. // CHECK:STDERR:
  19. // CHECK:STDERR: fail_positional.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.sadd" [InvalidBuiltinSignature]
  20. // CHECK:STDERR: fn Add -> i32 = "int.sadd";
  21. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. fn Add -> i32 = "int.sadd";
  24. // CHECK:STDERR: fail_positional.carbon:[[@LINE+8]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
  25. // CHECK:STDERR: fn Mul = "int.smul";
  26. // CHECK:STDERR: ^~~~~~~~
  27. // CHECK:STDERR:
  28. // CHECK:STDERR: fail_positional.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.smul" [InvalidBuiltinSignature]
  29. // CHECK:STDERR: fn Mul = "int.smul";
  30. // CHECK:STDERR: ^~~~~~~~
  31. // CHECK:STDERR:
  32. fn Mul = "int.smul";
  33. // CHECK:STDOUT: --- fail_positional.carbon
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: constants {
  36. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  37. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  38. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  39. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  40. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  41. // CHECK:STDOUT: %Add.type: type = fn_type @Add [concrete]
  42. // CHECK:STDOUT: %Add: %Add.type = struct_value () [concrete]
  43. // CHECK:STDOUT: %Mul.type: type = fn_type @Mul [concrete]
  44. // CHECK:STDOUT: %Mul: %Mul.type = struct_value () [concrete]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: imports {
  48. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  49. // CHECK:STDOUT: .Int = %Core.Int
  50. // CHECK:STDOUT: import Core//prelude
  51. // CHECK:STDOUT: import Core//prelude/...
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  58. // CHECK:STDOUT: .Core = imports.%Core
  59. // CHECK:STDOUT: .Add = %Add.decl
  60. // CHECK:STDOUT: .Mul = %Mul.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %Core.import = import Core
  63. // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [concrete = constants.%Add] {
  64. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  65. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  66. // CHECK:STDOUT: } {
  67. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  68. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  69. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  70. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %Mul.decl: %Mul.type = fn_decl @Mul [concrete = constants.%Mul] {} {}
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: fn @Add() -> %i32;
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: fn @Mul;
  78. // CHECK:STDOUT: