mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 15:16:08 +01:00
- Adds an empty prelude.carbon file - Imports that file in any non-Core package file - Adds --disable-prelude-import to avoid that - Adds --exclude-dump-file-prefix to be able to hide files from dumping - Used to hide core files (we can't do this by package name due to lex dumps, for example) - Restructures some tests to not rely on `i32`, particularly `alias` tests (which rely on a name ref) and tests with no prelude. I'm adding the framework for switching i32 to calling Int32 in the prelude, but I'm running into a separate error actually switching over. So that *mostly* works, but isn't quite ready for prime time. However, maybe the current state of this PR is still useful to review since it does a lot of the infrastructure work and adds the %Core everywhere?
90 lines
3.8 KiB
Plaintext
90 lines
3.8 KiB
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
|
|
|
|
interface Simple {
|
|
fn G[self: Self]();
|
|
}
|
|
|
|
impl i32 as Simple {
|
|
// CHECK:STDERR: fail_call_invalid.carbon:[[@LINE+3]]:14: ERROR: Name `Undeclared` not found.
|
|
// CHECK:STDERR: fn G[self: Undeclared]();
|
|
// CHECK:STDERR: ^~~~~~~~~~
|
|
fn G[self: Undeclared]();
|
|
}
|
|
|
|
fn InstanceCall(n: i32) {
|
|
n.(Simple.G)();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- fail_call_invalid.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %.1: type = interface_type @Simple [template]
|
|
// CHECK:STDOUT: %.2: type = assoc_entity_type @Simple, <function> [template]
|
|
// CHECK:STDOUT: %.3: <associated <function> in Simple> = assoc_entity element0, @Simple.%G [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .Simple = %Simple.decl
|
|
// CHECK:STDOUT: .InstanceCall = %InstanceCall
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {}
|
|
// CHECK:STDOUT: impl_decl @impl {
|
|
// CHECK:STDOUT: %Simple.ref: type = name_ref Simple, %Simple.decl [template = constants.%.1]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %InstanceCall: <function> = fn_decl @InstanceCall [template] {
|
|
// CHECK:STDOUT: %n.loc18_17.1: i32 = param n
|
|
// CHECK:STDOUT: @InstanceCall.%n: i32 = bind_name n, %n.loc18_17.1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @Simple {
|
|
// CHECK:STDOUT: %Self: Simple = bind_symbolic_name Self [symbolic]
|
|
// CHECK:STDOUT: %G: <function> = fn_decl @G.1 [template] {
|
|
// CHECK:STDOUT: %Self.ref: Simple = name_ref Self, %Self [symbolic = %Self]
|
|
// CHECK:STDOUT: %.loc8_14.1: type = facet_type_access %Self.ref [symbolic = %Self]
|
|
// CHECK:STDOUT: %.loc8_14.2: type = converted %Self.ref, %.loc8_14.1 [symbolic = %Self]
|
|
// CHECK:STDOUT: %self.loc8_8.1: Self = param self
|
|
// CHECK:STDOUT: %self.loc8_8.2: Self = bind_name self, %self.loc8_8.1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %.loc8_21: <associated <function> in Simple> = assoc_entity element0, %G [template = constants.%.3]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = %Self
|
|
// CHECK:STDOUT: .G = %.loc8_21
|
|
// CHECK:STDOUT: witness = (%G)
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @impl: i32 as Simple {
|
|
// CHECK:STDOUT: %G: <function> = fn_decl @G.2 [template] {
|
|
// CHECK:STDOUT: %Undeclared.ref: <error> = name_ref Undeclared, <error> [template = <error>]
|
|
// CHECK:STDOUT: %self.loc15_8.1: <error> = param self
|
|
// CHECK:STDOUT: %self.loc15_8.2: <error> = bind_name self, %self.loc15_8.1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %.1: <witness> = interface_witness (<error>) [template = <error>]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .G = %G
|
|
// CHECK:STDOUT: witness = %.1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G.1[@Simple.%self.loc8_8.2: Self]();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G.2[@impl.%self.loc15_8.2: <error>]();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @InstanceCall(%n: i32) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
|
|
// CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [template = constants.%.1]
|
|
// CHECK:STDOUT: %G.ref: <associated <function> in Simple> = name_ref G, @Simple.%.loc8_21 [template = constants.%.3]
|
|
// CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = <error>]
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|