Files
carbon-lang/toolchain/check/testdata/function/call/fail_not_callable.carbon
T
Richard Smith d63fceff8e Switch GetNodeBlock and GetTypeBlock to return an ArrayRef (#3220)
This removes the risk of accidentally performing a vector copy when
calling these functions, and is a preparation step towards the new node
block allocation design.

This required changing how we build call expressions. Instead of
finishing the argument block and then later adding a return slot, we now
delay finishing the argument block and checking for conversions to
parameter types until after we've added the return slot to it.
2023-09-13 20:47:53 +00:00

28 lines
1004 B
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
fn Run() {
// CHECK:STDERR: fail_not_callable.carbon:[[@LINE+6]]:24: Semantics TODO: `Not a callable name`.
// CHECK:STDERR: var x: i32 = "hello"();
// CHECK:STDERR: ^
// CHECK:STDERR: fail_not_callable.carbon:[[@LINE+3]]:25: Cannot implicitly convert from `String` to `i32`.
// CHECK:STDERR: var x: i32 = "hello"();
// CHECK:STDERR: ^
var x: i32 = "hello"();
}
// CHECK:STDOUT: file "fail_not_callable.carbon" {
// CHECK:STDOUT: %.loc7 = fn_decl @Run
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x: ref i32 = var "x"
// CHECK:STDOUT: %.loc14: String = string_literal "hello"
// CHECK:STDOUT: assign %x, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }