Implement some basic ImportRef handling for builtins. (#3663)

I'm basically just nudging down the path I think is right here. Adding a
small bit more support, but also more tests to capture cases that I
think will need to be verified as working.

With diagnostics like "Value of type `<function>` is not callable.",
that's because it expects a FunctionDecl but is instead finding a
ImportRefUsed. I'll need to work out the necessary support for a
callable function.
This commit is contained in:
Jon Ross-Perkins
2024-01-30 17:38:38 +00:00
committed by GitHub
parent 3fa70de101
commit e583493e9f
19 changed files with 398 additions and 105 deletions
@@ -3,7 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// CHECK:STDERR: b.carbon: ERROR: Semantics TODO: `TODO: ResolveIfImportRefUnused for FunctionDecl`.
// --- a.carbon
@@ -18,6 +17,9 @@ library "b" api;
import library "a";
fn Run() {
// CHECK:STDERR: b.carbon:[[@LINE+3]]:3: ERROR: Value of type `<function>` is not callable.
// CHECK:STDERR: F();
// CHECK:STDERR: ^~
F();
}
@@ -34,13 +36,13 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace {.F = %import_ref, .Run = %Run} [template]
// CHECK:STDOUT: %import_ref: <error> = import_ref ir1, inst+1, used
// CHECK:STDOUT: %import_ref: <function> = import_ref ir1, inst+1, used
// CHECK:STDOUT: %Run: <function> = fn_decl @Run [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: <error> = name_ref F, file.%import_ref
// CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%import_ref
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: