undefined.carbon 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/undefined.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/undefined.carbon
  12. // --- call_defined.carbon
  13. library "[[@TEST_NAME]]";
  14. fn Defined[T:! type](x: T) {}
  15. fn CallDefined() {
  16. Defined(0 as i32);
  17. }
  18. // --- call_defined_late.carbon
  19. library "[[@TEST_NAME]]";
  20. fn Defined[T:! type](x: T);
  21. fn CallDefined() {
  22. Defined(0 as i32);
  23. }
  24. fn Defined[T:! type](x: T) {}
  25. // --- fail_call_undefined.carbon
  26. library "[[@TEST_NAME]]";
  27. fn Undefined[T:! type](x: T);
  28. fn CallUndefined() {
  29. // CHECK:STDERR: fail_call_undefined.carbon:[[@LINE+7]]:3: error: use of undefined generic function [MissingGenericFunctionDefinition]
  30. // CHECK:STDERR: Undefined(0 as i32);
  31. // CHECK:STDERR: ^~~~~~~~~
  32. // CHECK:STDERR: fail_call_undefined.carbon:[[@LINE-6]]:1: note: generic function declared here [MissingGenericFunctionDefinitionHere]
  33. // CHECK:STDERR: fn Undefined[T:! type](x: T);
  34. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. // CHECK:STDERR:
  36. Undefined(0 as i32);
  37. }