diff --git a/.bazelrc b/.bazelrc index f6c1ea3911002..7fd5f7aa8ac73 100644 --- a/.bazelrc +++ b/.bazelrc @@ -108,6 +108,11 @@ build --action_env=LANG=en_US.UTF-8 build --enable_platform_specific_config build:linux --define=pfm=1 +# Enable TCMalloc on Linux as well. +# TODO: tcmalloc needs to support compiler-explorer; see: +# https://github.com/carbon-language/carbon-lang/issues/4176 +# build:linux --custom_malloc=@tcmalloc//tcmalloc + # Allow users to override any of the flags desired by importing a user-specific # RC file here if present. try-import %workspace%/user.bazelrc diff --git a/.clangd b/.clangd new file mode 100644 index 0000000000000..f6fab1b26e603 --- /dev/null +++ b/.clangd @@ -0,0 +1,7 @@ +# 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 + +CompileFlags: + # Workaround for https://github.com/clangd/clangd/issues/1582 + Remove: [-march=*] diff --git a/MODULE.bazel b/MODULE.bazel index 34dd9465bacb8..a2283a36ed4ff 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -4,14 +4,33 @@ """Bazel modules. -If `MODULE.bazel.lock` changes locally, it means the host platform hasn't yet -been added to the lock file. Running `bazel mod deps` provides a canonical -update to `MODULE.bazel.lock`; create a PR with those changes in order to -include the host platform. - -Platforms tested with GitHub actions are kept up-to-date. Other platforms may -fall out of sync on dependency changes, and should be updated with a PR the same -way a platform is added. +`MODULE.bazel.lock` may change locally when `bazel` is exexcuted. This means one +of: + +1. `MODULE.bazel` is changing. + - Running `bazel mod deps` provides a canonical update to + `MODULE.bazel.lock`; include the changes. + - GitHub test actions may also identify platform-specific lockfile + updates. +2. The `bazel` version doesn't match the version used to generate the + `MODULE.bazel.lock`. + - Bazel releases can change the lock file contents. + - We use Bazelisk in order to keep everyone using the same version: + https://bazel.build/install/bazelisk + - Developers are encouraged to alias `bazel` to `bazelisk` for + ease-of-use; some setups, like Homebrew, will include that with a + `bazelisk` install. + - Contribution tools documentation includes `bazelisk` setup: + https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md + - Make sure `bazelisk --version` (or `bazel --version`) matches the + version in `.bazeliskrc`. +3. The host platform hasn't yet been added to the lock file. + - Platforms tested with GitHub actions are kept up-to-date. Other + platforms may fall out of sync due to `bazel` or dependency changes, + and should be updated with a PR the same way a platform is added. + - Running `bazel mod deps` provides a canonical update to + `MODULE.bazel.lock`; create a PR with those changes in order to include + the host platform. """ module(name = "carbon") @@ -43,6 +62,17 @@ archive_override( urls = ["https://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-{0}.tar.gz".format(libpfm_version)], ) +# The registry has a snapshot, but upstream is active and not regularly marking +# releases. We start with the BCR snapshot to avoid a miss and then override it +# with a more recent commit. +bazel_dep(name = "tcmalloc", version = "0.0.0-20240411-5ed309d", dev_dependency = True) +git_override( + module_name = "tcmalloc", + # HEAD as of 2024-07-14. + commit = "923df94c922e0cd2d0512c1662d374f63c2c0c96", + remote = "https://github.com/google/tcmalloc.git", +) + bazel_dep(name = "rules_bison", version = "0.2.2") bazel_dep(name = "rules_flex", version = "0.2.1") bazel_dep(name = "rules_m4", version = "0.2.3") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 3b7c74bbf5053..3d5dc0438c40b 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -7,8 +7,11 @@ "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", "https://bcr.bazel.build/modules/abseil-cpp/20230802.0/MODULE.bazel": "d253ae36a8bd9ee3c5955384096ccb6baf16a1b1e93e858370da0a3b94f77c16", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.0/MODULE.bazel": "98dc378d64c12a4e4741ad3362f87fb737ee6a0886b2d90c3cdbb4d93ea3e0bf", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/source.json": "750d5e29326fb59cbe61116a7b803c8a1d0a7090a9c8ed89888d188e3c473fc7", + "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", "https://bcr.bazel.build/modules/apple_support/1.15.1/source.json": "517f2b77430084c541bc9be2db63fdcbb7102938c5f64c17ee60ffda2e5cf07b", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", @@ -30,9 +33,11 @@ "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", + "https://bcr.bazel.build/modules/google_benchmark/1.8.3/MODULE.bazel": "2349ac3adb7917fdc4378e85fae533015dae3cb583ad1bd5d2c2185106c7c403", "https://bcr.bazel.build/modules/google_benchmark/1.8.4/MODULE.bazel": "c6d54a11dcf64ee63545f42561eda3fd94c1b5f5ebe1357011de63ae33739d5e", "https://bcr.bazel.build/modules/google_benchmark/1.8.4/source.json": "84590f7bc5a1fd99e1ef274ee16bb41c214f705e62847b42e705010dfa81fe53", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.13.0/MODULE.bazel": "369533f4a302dc7d9ad1cd9a09a9e820a1d9a4011fad2dfa636b5bb225b9a6c7", "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/source.json": "41e9e129f80d8c8bf103a7acc337b76e54fad1214ac0a7084bf24f4cd924b8b4", "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", @@ -47,14 +52,17 @@ "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/26.0/MODULE.bazel": "8402da964092af40097f4a205eec2a33fd4a7748dc43632b7d1629bfd9a2b856", "https://bcr.bazel.build/modules/protobuf/27.1/MODULE.bazel": "703a7b614728bb06647f965264967a8ef1c39e09e8f167b3ca0bb1fd80449c0d", "https://bcr.bazel.build/modules/protobuf/27.1/source.json": "11a2567425ffebb89ff59e94fc8a55bc78a418d52a4cc415069ce7c793571352", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1.bzl.1/MODULE.bazel": "1ef2994c097ee88f8f7ae8fbf991aaefb0603b2540fe575eca14943bc9f220a6", "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34", "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/source.json": "6900fdc8a9e95866b8c0d4ad4aba4d4236317b5c1cd04c502df3f0d33afed680", "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", + "https://bcr.bazel.build/modules/re2/2024-02-01/MODULE.bazel": "5ed922cb8b6c110e30969695e73bd0d3159576bf17ce8ee2443a7d07bf500551", "https://bcr.bazel.build/modules/re2/2024-06-01/MODULE.bazel": "0c4d80792f7db21f40e84057b623f549aba6c561fda2b0b1a640034a772c8e15", "https://bcr.bazel.build/modules/re2/2024-06-01/source.json": "97960cd6219f913eda7af9c798f866695d0883e1d79e9234ff385091d407ba86", "https://bcr.bazel.build/modules/rules_bison/0.2.2/MODULE.bazel": "4326371dd66dda3c04765cd7f1c64c5dbc064c673555078ec1e4f758ba77d4ba", @@ -70,8 +78,11 @@ "https://bcr.bazel.build/modules/rules_foreign_cc/0.10.1/MODULE.bazel": "b9527010e5fef060af92b6724edb3691970a5b1f76f74b21d39f7d433641be60", "https://bcr.bazel.build/modules/rules_foreign_cc/0.10.1/source.json": "9300e71df0cdde0952f10afff1401fa664e9fc5d9ae6204660ba1b158d90d6a6", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.1/MODULE.bazel": "e6555740cac87ff14367e998bb4a417cf17d7953f81b161afcb679ddc5034b94", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.1/source.json": "dca9ea70f034bac9650d9b679b8bb2d192958898027636361a95822fff8bc5a0", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", + "https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31", "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", "https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", @@ -96,6 +107,8 @@ "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", "https://bcr.bazel.build/modules/rules_python/0.24.0/MODULE.bazel": "4bff7f583653d0762cda21303da0643cc4c545ddfd9593337f18dad8d1787801", "https://bcr.bazel.build/modules/rules_python/0.25.0/MODULE.bazel": "72f1506841c920a1afec76975b35312410eea3aa7b63267436bfb1dd91d2d382", + "https://bcr.bazel.build/modules/rules_python/0.28.0/MODULE.bazel": "cba2573d870babc976664a912539b320cbaa7114cd3e8f053c720171cde331ed", + "https://bcr.bazel.build/modules/rules_python/0.29.0/MODULE.bazel": "2ac8cd70524b4b9ec49a0b8284c79e4cd86199296f82f6e0d5da3f783d660c82", "https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58", "https://bcr.bazel.build/modules/rules_python/0.32.2/MODULE.bazel": "01052470fc30b49de91fb8483d26bea6f664500cfad0b078d4605b03e3a83ed4", "https://bcr.bazel.build/modules/rules_python/0.33.1/MODULE.bazel": "b6767735ae876488ca4210ae315709a10ed97a2ff791d7b185cb241fae4ba3f1", @@ -694,6 +707,97 @@ ] } }, + "@@rules_fuzzing~//fuzzing/private:extensions.bzl%non_module_dependencies": { + "general": { + "bzlTransitiveDigest": "4sxbTq2j1XQCFfsefsoKABQqsrPY1Zgr6d5hyosptkE=", + "usagesDigest": "GQ8oB+GCWPZFOwBiLQ+5DUkEPeGNmfXMfasUU9AB030=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "bazel_skylib": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + "urls": [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz" + ] + } + }, + "rules_fuzzing_jazzer": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_jar", + "attributes": { + "sha256": "ee6feb569d88962d59cb59e8a31eb9d007c82683f3ebc64955fd5b96f277eec2", + "url": "https://repo1.maven.org/maven2/com/code-intelligence/jazzer/0.20.1/jazzer-0.20.1.jar" + } + }, + "rules_python": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b", + "strip_prefix": "rules_python-0.26.0", + "url": "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz" + } + }, + "rules_fuzzing_oss_fuzz": { + "bzlFile": "@@rules_fuzzing~//fuzzing/private/oss_fuzz:repository.bzl", + "ruleClassName": "oss_fuzz_repository", + "attributes": {} + }, + "com_google_absl": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "urls": [ + "https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.1.zip" + ], + "strip_prefix": "abseil-cpp-20240116.1", + "integrity": "sha256-7capMWOvWyoYbUaHF/b+I2U6XLMaHmky8KugWvfXYuk=" + } + }, + "honggfuzz": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file": "@@rules_fuzzing~//:honggfuzz.BUILD", + "sha256": "6b18ba13bc1f36b7b950c72d80f19ea67fbadc0ac0bb297ec89ad91f2eaa423e", + "url": "https://github.com/google/honggfuzz/archive/2.5.zip", + "strip_prefix": "honggfuzz-2.5" + } + }, + "platforms": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "urls": [ + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz" + ], + "sha256": "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74" + } + }, + "rules_fuzzing_jazzer_api": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_jar", + "attributes": { + "sha256": "f5a60242bc408f7fa20fccf10d6c5c5ea1fcb3c6f44642fec5af88373ae7aa1b", + "url": "https://repo1.maven.org/maven2/com/code-intelligence/jazzer-api/0.20.1/jazzer-api-0.20.1.jar" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_fuzzing~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@rules_jvm_external~//:extensions.bzl%maven": { "general": { "bzlTransitiveDigest": "4ijz6uc3T4E+d+U8LQv4EAt+8OqZNVY/lzvhLx3y1yg=", @@ -1773,7 +1877,7 @@ }, "@@rules_python~//python/private/bzlmod:pip.bzl%pip_internal": { "general": { - "bzlTransitiveDigest": "LUnJTqzSxPGxx85Cp/9qyB98ogfoIOKVv8prz2EwHLY=", + "bzlTransitiveDigest": "GfWaS9XSkh1MIaUcq536HEpcveDfasrTHv9+KSap9k0=", "usagesDigest": "Bif91jiki2w5VZpJhilKbPk3oDiMMFw6QycMmn1FirE=", "recordedFileInputs": { "@@rules_python~//tools/publish/requirements.txt": "8ced1e640eab3ee44298590e5ad88cd612f5bf96245af1981709f7a8884a982b", @@ -4126,10 +4230,30 @@ "pythons_hub", "rules_python~~python~pythons_hub" ], + [ + "rules_python~~python~pythons_hub", + "python_3_10_host", + "rules_python~~python~python_3_10_host" + ], [ "rules_python~~python~pythons_hub", "python_3_11_host", "rules_python~~python~python_3_11_host" + ], + [ + "rules_python~~python~pythons_hub", + "python_3_12_host", + "rules_python~~python~python_3_12_host" + ], + [ + "rules_python~~python~pythons_hub", + "python_3_8_host", + "rules_python~~python~python_3_8_host" + ], + [ + "rules_python~~python~pythons_hub", + "python_3_9_host", + "rules_python~~python~python_3_9_host" ] ] } diff --git a/README.md b/README.md index 43172bad97e5a..e764ca9ce2eb1 100644 --- a/README.md +++ b/README.md @@ -124,9 +124,10 @@ and provides a deeper view into our goals for the Carbon project and language. ## Project status -Carbon Language is currently an experimental project. There is no working -compiler or toolchain. You can see the demo interpreter for Carbon on -[compiler-explorer.com](http://carbon.compiler-explorer.com/). +Carbon Language is currently an experimental project. You can see the demo +interpreter for Carbon on +[compiler-explorer.com](http://carbon.compiler-explorer.com/). We are also hard +at work on a toolchain implementation with compiler and linker. We want to better understand whether we can build a language that meets our successor language criteria, and whether the resulting language can gather a @@ -267,20 +268,57 @@ semantics onto C++ such as Rust-inspired ## Getting started -To try out Carbon, you can use the Carbon explorer to interpret Carbon code and -print its output. You can try it out immediately at -[compiler-explorer.com](http://carbon.compiler-explorer.com/). +To try out Carbon immediately in your browser, you can use the demo interpreter +for Carbon on: +[carbon.compiler-explorer.com](http://carbon.compiler-explorer.com/). -Because Carbon is an early, experimental project we don't yet have releases you -can download and try out locally, you'll instead need to build any tools -yourself from source. We expect to have packaged releases you can try out when -we reach our +We are developing a traditional toolchain for Carbon that can compile and link +programs. However, Carbon is still an early, experimental project, and so we +only have very experimental nightly releases of the Carbon toolchain available +to download, and only on limited platforms. If you are using a recent Ubuntu +Linux or similar (Debian, WSL, etc.), you can try these out by going to our +[releases](https://github.com/carbon-language/carbon-lang/releases) page and +download the latest nightly toolchain tar file: +`carbon_toolchain-0.0.0-0.nightly.YYYY.MM.DD.tar.gz`. Then you can try it out: + +```shell +# A variable with the specific nightly version: +VERSION="0.0.0-0.nightly.YYYY.MM.DD" + +# Unpack the toolchain: +tar -xvf carbon_toolchain-${VERSION}.tar.gz + +# Create a simple Carbon source file: +echo "fn Run() { Core.Print(42); }" > forty_two.carbon + +# Compile to an object file: +./carbon_toolchain-${VERSION}/bin/carbon compile \ + --output=forty_two.o forty_two.carbon + +# Install minimal system libraries used for linking. Note that installing `gcc` +# or `g++` for compiling C/C++ code with GCC will also be sufficient, these are +# just the specific system libraries Carbon linking still uses. +sudo apt install libgcc-11-dev + +# Link to an executable: +./carbon_toolchain-${VERSION}/bin/carbon link \ + --output=forty_two forty_two.o + +# Run it: +./forty_two +``` + +As a reminder, the toolchain is still very early and many things don't yet work. +Please hold off on filing lots of bugs: we know many parts of this don't work +yet or may not work on all systems. We expect to have releases that are much +more robust and reliable that you can try out when we reach our [0.1 milestone](/docs/project/milestones.md#milestone-01-a-minimum-viable-product-mvp-for-evaluation). -If you do want to try out Carbon locally, you'll need to install our -[build dependencies](/docs/project/contribution_tools.md#setup-commands) (Bazel, -Clang, LLD, libc++) and check out the Carbon repository, for example on Debian -or Ubuntu: +If you want to build Carbon's toolchain yourself or are thinking about +contributing fixes or improvements to Carbon, you'll need to install our +[build dependencies](/docs/project/contribution_tools.md#setup-commands) (Clang, +LLD, libc++) and check out the Carbon repository. For example, on Debian or +Ubuntu: ```shell # Update apt. @@ -298,14 +336,7 @@ $ git clone https://github.com/carbon-language/carbon-lang $ cd carbon-lang ``` -Then you can build and run the explorer: - -```shell -# Build and run the explorer. -$ ./scripts/run_bazelisk.py run //explorer -- ./explorer/testdata/print/format_only.carbon -``` - -And you can try out our toolchain which has a very early-stage compiler for +Then you can try out our toolchain which has a very early-stage compiler for Carbon: ```shell diff --git a/bazel/cc_toolchains/clang_cc_toolchain_config.bzl b/bazel/cc_toolchains/clang_cc_toolchain_config.bzl index dea6aec1e420f..b2e8426d63a9d 100644 --- a/bazel/cc_toolchains/clang_cc_toolchain_config.bzl +++ b/bazel/cc_toolchains/clang_cc_toolchain_config.bzl @@ -144,6 +144,7 @@ def _impl(ctx): "-Wextra-semi", "-Wmissing-prototypes", "-Wzero-as-null-pointer-constant", + "-Wdelete-non-virtual-dtor", # Don't warn on external code as we can't # necessarily patch it easily. Note that these have # to be initial directories in the `#include` line. @@ -1076,10 +1077,13 @@ def _impl(ctx): target_system_name = identifier, target_cpu = ctx.attr.target_cpu, + # This is used to expose a "flag" that `config_setting` rules can use to + # determine if the compiler is Clang. + compiler = "clang", + # These attributes aren't meaningful at all so just use placeholder # values. target_libc = "local", - compiler = "local", abi_version = "local", abi_libc_version = "local", diff --git a/docs/project/contribution_tools.md b/docs/project/contribution_tools.md index bbd42d9f8db43..36915b5df077e 100644 --- a/docs/project/contribution_tools.md +++ b/docs/project/contribution_tools.md @@ -225,6 +225,15 @@ considering if they fit your workflow. you should be prompted to use Carbon's [devcontainer](/.devcontainer/devcontainer.json) with "Reopen in container". +- [clangd](https://clangd.llvm.org/installation): An LSP server implementation + for C/C++. + - To ensure that `clangd` reports accurate diagnostics. It needs a + generated file called `compile_commands.json`. This can be generated by + invoking the command below: + ``` + ./scripts/create_compdb.py + ``` + - **NOTE**: This assumes you have `python` 3 installed on your system. ### Manually building Clang and LLVM (not recommended) diff --git a/language_server/language_server.cpp b/language_server/language_server.cpp index 5b72fb13c4b2e..92337259c6198 100644 --- a/language_server/language_server.cpp +++ b/language_server/language_server.cpp @@ -10,6 +10,7 @@ #include "toolchain/lex/lex.h" #include "toolchain/parse/node_kind.h" #include "toolchain/parse/parse.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/source/source_buffer.h" namespace Carbon::LS { @@ -79,11 +80,12 @@ auto LanguageServer::onReply(llvm::json::Value /*id*/, // Returns the text of first child of kind Parse::NodeKind::IdentifierName. static auto GetIdentifierName(const SharedValueStores& value_stores, const Lex::TokenizedBuffer& tokens, - const Parse::Tree& p, Parse::NodeId node) + const Parse::TreeAndSubtrees& p, + Parse::NodeId node) -> std::optional { for (auto ch : p.children(node)) { - if (p.node_kind(ch) == Parse::NodeKind::IdentifierName) { - auto token = p.node_token(ch); + if (p.tree().node_kind(ch) == Parse::NodeKind::IdentifierName) { + auto token = p.tree().node_token(ch); if (tokens.GetKind(token) == Lex::TokenKind::Identifier) { return value_stores.identifiers().Get(tokens.GetIdentifier(token)); } @@ -104,6 +106,7 @@ void LanguageServer::OnDocumentSymbol( auto buf = SourceBuffer::MakeFromFile(vfs, file, NullDiagnosticConsumer()); auto lexed = Lex::Lex(value_stores, *buf, NullDiagnosticConsumer()); auto parsed = Parse::Parse(lexed, NullDiagnosticConsumer(), nullptr); + Parse::TreeAndSubtrees tree_and_subtrees(lexed, parsed); std::vector result; for (const auto& node : parsed.postorder()) { clang::clangd::SymbolKind symbol_kind; @@ -126,7 +129,8 @@ void LanguageServer::OnDocumentSymbol( continue; } - if (auto name = GetIdentifierName(value_stores, lexed, parsed, node)) { + if (auto name = + GetIdentifierName(value_stores, lexed, tree_and_subtrees, node)) { auto tok = parsed.node_token(node); clang::clangd::Position pos{lexed.GetLineNumber(tok) - 1, lexed.GetColumnNumber(tok) - 1}; diff --git a/migrate_cpp/rewriter.cpp b/migrate_cpp/rewriter.cpp index cac60c81813eb..55636b74a57e8 100644 --- a/migrate_cpp/rewriter.cpp +++ b/migrate_cpp/rewriter.cpp @@ -222,7 +222,7 @@ auto RewriteBuilder::VisitIntegerLiteral(clang::IntegerLiteral* expr) -> bool { c = '_'; } } - SetReplacement(expr, {OutputSegment(std::move(text))}); + SetReplacement(expr, OutputSegment(std::move(text))); return true; } diff --git a/testing/file_test/file_test_base.cpp b/testing/file_test/file_test_base.cpp index 8acd146ad2b8d..48d4954f77eeb 100644 --- a/testing/file_test/file_test_base.cpp +++ b/testing/file_test/file_test_base.cpp @@ -20,6 +20,7 @@ #include "common/init_llvm.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" @@ -846,6 +847,61 @@ static auto GetTests() -> llvm::SmallVector { return all_tests; } +// Runs autoupdate for the given tests. This is multi-threaded to try to get a +// little extra speed. +static auto RunAutoupdate(llvm::StringRef exe_path, + llvm::ArrayRef tests, + FileTestFactory& test_factory) -> int { + llvm::CrashRecoveryContext::Enable(); + llvm::DefaultThreadPool pool( + {.ThreadsRequested = absl::GetFlag(FLAGS_threads)}); + + // Guard access to both `llvm::errs` and `crashed`. + std::mutex mutex; + bool crashed = false; + + for (const auto& test_name : tests) { + pool.async([&test_factory, &mutex, &exe_path, &crashed, test_name] { + // If any thread crashed, don't try running more. + { + std::unique_lock lock(mutex); + if (crashed) { + return; + } + } + + // Use a crash recovery context to try to get a stack trace when + // multiple threads may crash in parallel, which otherwise leads to the + // program aborting without printing a stack trace. + llvm::CrashRecoveryContext crc; + crc.DumpStackAndCleanupOnFailure = true; + bool thread_crashed = !crc.RunSafely([&] { + std::unique_ptr test( + test_factory.factory_fn(exe_path, test_name)); + auto result = test->Autoupdate(); + + std::unique_lock lock(mutex); + if (result.ok()) { + llvm::errs() << (*result ? "!" : "."); + } else { + llvm::errs() << "\n" << result.error().message() << "\n"; + } + }); + if (thread_crashed) { + std::unique_lock lock(mutex); + crashed = true; + } + }); + } + + pool.wait(); + if (crashed) { + return EXIT_FAILURE; + } + llvm::errs() << "\nDone!\n"; + return EXIT_SUCCESS; +} + // Implements main() within the Carbon::Testing namespace for convenience. static auto Main(int argc, char** argv) -> int { Carbon::InitLLVM init_llvm(argc, argv); @@ -887,28 +943,7 @@ static auto Main(int argc, char** argv) -> int { llvm::SmallVector tests = GetTests(); auto test_factory = GetFileTestFactory(); if (absl::GetFlag(FLAGS_autoupdate)) { - llvm::DefaultThreadPool pool( - {.ThreadsRequested = absl::GetFlag(FLAGS_threads)}); - std::mutex errs_mutex; - - for (const auto& test_name : tests) { - pool.async([&test_factory, &errs_mutex, &exe_path, test_name] { - std::unique_ptr test( - test_factory.factory_fn(exe_path, test_name)); - auto result = test->Autoupdate(); - - // Guard access to llvm::errs, which is not thread-safe. - std::unique_lock lock(errs_mutex); - if (result.ok()) { - llvm::errs() << (*result ? "!" : "."); - } else { - llvm::errs() << "\n" << result.error().message() << "\n"; - } - }); - } - pool.wait(); - llvm::errs() << "\nDone!\n"; - return EXIT_SUCCESS; + return RunAutoupdate(exe_path, tests, test_factory); } else if (absl::GetFlag(FLAGS_dump_output)) { for (const auto& test_name : tests) { std::unique_ptr test( diff --git a/toolchain/base/BUILD b/toolchain/base/BUILD index c5f27547ee452..9a2e802fa334f 100644 --- a/toolchain/base/BUILD +++ b/toolchain/base/BUILD @@ -31,11 +31,23 @@ cc_library( ], ) +cc_library( + name = "mem_usage", + hdrs = ["mem_usage.h"], + deps = [ + ":yaml", + "//common:map", + "//common:set", + "@llvm-project//llvm:Support", + ], +) + cc_library( name = "value_store", hdrs = ["value_store.h"], deps = [ ":index_base", + ":mem_usage", ":yaml", "//common:check", "//common:hashing", diff --git a/toolchain/base/mem_usage.h b/toolchain/base/mem_usage.h new file mode 100644 index 0000000000000..2997f6f539f1a --- /dev/null +++ b/toolchain/base/mem_usage.h @@ -0,0 +1,145 @@ +// 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 + +#ifndef CARBON_TOOLCHAIN_BASE_MEM_USAGE_H_ +#define CARBON_TOOLCHAIN_BASE_MEM_USAGE_H_ + +#include + +#include "common/map.h" +#include "common/set.h" +#include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/FormatVariadic.h" +#include "toolchain/base/yaml.h" + +namespace Carbon { + +// Helps track memory usage for a compile. +// +// Users will mix `Add` and `Collect` calls, using `ConcatLabel` to label +// allocation sources. Typically we'll collect stats for growable, potentially +// large data types (such as `SmallVector`), ignoring small fixed-size members +// (such as pointers or `int32_t`). +// +// For example: +// +// auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const +// -> void { +// // Explicit tracking. +// mem_usage.Add(MemUsage::ConcatLabel(label, "data_"), data_.used_bytes(), +// data_.reserved_bytes()); +// // Common library types like `Map` and `llvm::SmallVector` have +// // type-specific support. +// mem_usage.Add(MemUsage::Concat(label, "array_"), array_); +// // Implementing `CollectMemUsage` allows use with the same interface. +// mem_usage.Collect(MemUsage::Concat(label, "obj_"), obj_); +// } +class MemUsage { + public: + // Adds tracking for used and reserved bytes, paired with the given label. + auto Add(std::string label, int64_t used_bytes, int64_t reserved_bytes) + -> void { + mem_usage_.push_back({.label = std::move(label), + .used_bytes = used_bytes, + .reserved_bytes = reserved_bytes}); + } + + // Adds usage tracking for an allocator. + auto Add(std::string label, const llvm::BumpPtrAllocator& allocator) -> void { + Add(std::move(label), allocator.getBytesAllocated(), + allocator.getTotalMemory()); + } + + // Adds usage tracking for a map. + template + auto Add(std::string label, Map map, + KeyContextT key_context = KeyContextT()) -> void { + // These don't track used bytes, so we set the same value for used and + // reserved bytes. + auto bytes = map.ComputeMetrics(key_context).storage_bytes; + Add(std::move(label), bytes, bytes); + } + + // Adds usage tracking for a set. + template + auto Add(std::string label, Set set, + KeyContextT key_context = KeyContextT()) -> void { + // These don't track used bytes, so we set the same value for used and + // reserved bytes. + auto bytes = set.ComputeMetrics(key_context).storage_bytes; + Add(std::move(label), bytes, bytes); + } + + // Adds memory usage of an array's data. This ignores the possible overhead of + // a SmallVector's in-place storage; if it's used, it's going to be tiny + // relative to scaling memory costs. + // + // This uses SmallVector in order to get proper inference for T, which + // ArrayRef misses. + template + auto Add(std::string label, const llvm::SmallVector& array) -> void { + Add(std::move(label), array.size_in_bytes(), array.capacity_in_bytes()); + } + + // Adds memory usage for an object that provides `CollectMemUsage`. + // + // The expected signature of `CollectMemUsage` is above, in MemUsage class + // comments. + template + auto Collect(llvm::StringRef label, const T& arg) -> void { + arg.CollectMemUsage(*this, label); + } + + // Constructs a label for memory usage, handling the `.` concatenation. + // We don't expect much depth in labels per-call. + static auto ConcatLabel(llvm::StringRef label, llvm::StringRef child_label) + -> std::string { + return llvm::formatv("{0}.{1}", label, child_label); + } + static auto ConcatLabel(llvm::StringRef label, llvm::StringRef child_label1, + llvm::StringRef child_label2) -> std::string { + return llvm::formatv("{0}.{1}.{2}", label, child_label1, child_label2); + } + + auto OutputYaml(llvm::StringRef filename) const -> Yaml::OutputMapping { + // Explicitly copy the filename. + return Yaml::OutputMapping([&, filename](Yaml::OutputMapping::Map map) { + map.Add("filename", filename); + int64_t total_used = 0; + int64_t total_reserved = 0; + for (const auto& entry : mem_usage_) { + total_used += entry.used_bytes; + total_reserved += entry.reserved_bytes; + map.Add(entry.label, + Yaml::OutputMapping([&](Yaml::OutputMapping::Map byte_map) { + byte_map.Add("used_bytes", entry.used_bytes); + byte_map.Add("reserved_bytes", entry.reserved_bytes); + })); + } + map.Add("Total", + Yaml::OutputMapping([&](Yaml::OutputMapping::Map byte_map) { + byte_map.Add("used_bytes", total_used); + byte_map.Add("reserved_bytes", total_reserved); + })); + }); + } + + private: + // Memory usage for a specific label. + struct Entry { + std::string label; + int64_t used_bytes; + int64_t reserved_bytes; + }; + + // The accumulated data on memory usage. + llvm::SmallVector mem_usage_; +}; + +} // namespace Carbon + +#endif // CARBON_TOOLCHAIN_BASE_MEM_USAGE_H_ diff --git a/toolchain/base/value_store.h b/toolchain/base/value_store.h index 941ca144ce277..5dacf8116f133 100644 --- a/toolchain/base/value_store.h +++ b/toolchain/base/value_store.h @@ -17,6 +17,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/YAMLParser.h" #include "toolchain/base/index_base.h" +#include "toolchain/base/mem_usage.h" #include "toolchain/base/yaml.h" namespace Carbon { @@ -187,6 +188,12 @@ class ValueStore }); } + // Collects memory usage of the values. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(label.str(), values_); + } + auto array_ref() const -> llvm::ArrayRef { return values_; } auto size() const -> size_t { return values_.size(); } @@ -218,14 +225,7 @@ class CanonicalValueStore { auto Lookup(ValueType value) const -> IdT; // Reserves space. - auto Reserve(size_t size) -> void { - // Compute the resulting new insert count using the size of values -- the - // set doesn't have a fast to compute current size. - if (size > values_.size()) { - set_.GrowForInsertCount(size - values_.size(), KeyContext(values_)); - } - values_.Reserve(size); - } + auto Reserve(size_t size) -> void; // These are to support printable structures, and are not guaranteed. auto OutputYaml() const -> Yaml::OutputMapping { @@ -237,6 +237,15 @@ class CanonicalValueStore { } auto size() const -> size_t { return values_.size(); } + // Collects memory usage of the values and deduplication set. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Collect(MemUsage::ConcatLabel(label, "values_"), values_); + auto bytes = + set_.ComputeMetrics(KeyContext(values_.array_ref())).storage_bytes; + mem_usage.Add(MemUsage::ConcatLabel(label, "set_"), bytes, bytes); + } + private: class KeyContext; @@ -274,6 +283,17 @@ auto CanonicalValueStore::Lookup(ValueType value) const -> IdT { return IdT::Invalid; } +template +auto CanonicalValueStore::Reserve(size_t size) -> void { + // Compute the resulting new insert count using the size of values -- the + // set doesn't have a fast to compute current size. + if (size > values_.size()) { + set_.GrowForInsertCount(size - values_.size(), + KeyContext(values_.array_ref())); + } + values_.Reserve(size); +} + using FloatValueStore = CanonicalValueStore; // Stores that will be used across compiler phases for a given compilation unit. @@ -322,6 +342,18 @@ class SharedValueStores : public Yaml::Printable { }); } + // Collects memory usage for the various shared stores. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Collect(MemUsage::ConcatLabel(label, "ints_"), ints_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "reals_"), reals_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "floats_"), floats_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "identifiers_"), + identifiers_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "string_literals_"), + string_literals_); + } + private: CanonicalValueStore ints_; ValueStore reals_; diff --git a/toolchain/base/value_store_test.cpp b/toolchain/base/value_store_test.cpp index 9608e755f1506..af45eec63370c 100644 --- a/toolchain/base/value_store_test.cpp +++ b/toolchain/base/value_store_test.cpp @@ -82,6 +82,9 @@ TEST(ValueStore, Identifiers) { std::string b = "b"; SharedValueStores value_stores; + // Make sure reserve works, we use it with identifiers. + value_stores.identifiers().Reserve(100); + auto a_id = value_stores.identifiers().Add(a); auto b_id = value_stores.identifiers().Add(b); diff --git a/toolchain/check/BUILD b/toolchain/check/BUILD index abf01dad08bf3..82830ef4ea99b 100644 --- a/toolchain/check/BUILD +++ b/toolchain/check/BUILD @@ -18,10 +18,12 @@ cc_library( "context.cpp", "convert.cpp", "decl_name_stack.cpp", + "deduce.cpp", "eval.cpp", "function.cpp", "generic.cpp", "global_init.cpp", + "import.cpp", "import_ref.cpp", "inst_block_stack.cpp", "merge.cpp", @@ -35,11 +37,13 @@ cc_library( "convert.h", "decl_introducer_state.h", "decl_name_stack.h", + "deduce.h", "diagnostic_helpers.h", "eval.h", "function.h", "generic.h", "global_init.h", + "import.h", "import_ref.h", "inst_block_stack.h", "keyword_modifier_set.h", @@ -92,7 +96,6 @@ cc_library( ":call", ":context", ":impl", - ":import", ":interface", ":member_access", ":operator", @@ -183,23 +186,6 @@ cc_library( ], ) -cc_library( - name = "import", - srcs = ["import.cpp"], - hdrs = ["import.h"], - deps = [ - ":context", - "//common:check", - "//common:map", - "//toolchain/base:kind_switch", - "//toolchain/parse:node_kind", - "//toolchain/sem_ir:file", - "//toolchain/sem_ir:ids", - "//toolchain/sem_ir:inst", - "//toolchain/sem_ir:inst_kind", - ], -) - cc_library( name = "interface", srcs = ["interface.cpp"], @@ -241,6 +227,7 @@ cc_library( "//common:vlog", "//toolchain/parse:node_kind", "//toolchain/parse:tree", + "//toolchain/sem_ir:formatter", "//toolchain/sem_ir:ids", "@llvm-project//llvm:Support", ], diff --git a/toolchain/check/call.cpp b/toolchain/check/call.cpp index f185f9432bff3..05e6c89c81a66 100644 --- a/toolchain/check/call.cpp +++ b/toolchain/check/call.cpp @@ -7,7 +7,10 @@ #include "toolchain/base/kind_switch.h" #include "toolchain/check/context.h" #include "toolchain/check/convert.h" +#include "toolchain/check/deduce.h" #include "toolchain/check/function.h" +#include "toolchain/check/generic.h" +#include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst.h" #include "toolchain/sem_ir/typed_insts.h" @@ -22,11 +25,15 @@ static auto PerformCallToGenericClass(Context& context, Parse::NodeId node_id, -> SemIR::InstId { auto& class_info = context.classes().Get(class_id); + // TODO: Pass in information about the specific in which the generic class + // name was found. + // TODO: Perform argument deduction. + auto specific_id = SemIR::SpecificId::Invalid; + // Convert the arguments to match the parameters. auto converted_args_id = ConvertCallArgs( context, node_id, /*self_id=*/SemIR::InstId::Invalid, arg_ids, - /*return_storage_id=*/SemIR::InstId::Invalid, class_info.decl_id, - class_info.implicit_param_refs_id, class_info.param_refs_id); + /*return_storage_id=*/SemIR::InstId::Invalid, class_info, specific_id); return context.AddInst(node_id, {.type_id = SemIR::TypeId::TypeType, .callee_id = callee_id, @@ -44,11 +51,16 @@ static auto PerformCallToGenericInterface(Context& context, -> SemIR::InstId { auto& interface_info = context.interfaces().Get(interface_id); + // TODO: Pass in information about the specific in which the generic interface + // name was found. + // TODO: Perform argument deduction. + auto specific_id = SemIR::SpecificId::Invalid; + // Convert the arguments to match the parameters. auto converted_args_id = ConvertCallArgs( context, node_id, /*self_id=*/SemIR::InstId::Invalid, arg_ids, - /*return_storage_id=*/SemIR::InstId::Invalid, interface_info.decl_id, - interface_info.implicit_param_refs_id, interface_info.param_refs_id); + /*return_storage_id=*/SemIR::InstId::Invalid, interface_info, + specific_id); return context.AddInst(node_id, {.type_id = SemIR::TypeId::TypeType, .callee_id = callee_id, @@ -87,48 +99,59 @@ auto PerformCall(Context& context, Parse::NodeId node_id, } auto& callable = context.functions().Get(callee_function.function_id); - // For functions with an implicit return type, the return type is the empty - // tuple type. - SemIR::TypeId type_id = callable.declared_return_type(context.sem_ir()); - if (!type_id.is_valid()) { - type_id = context.GetTupleType({}); + // If the callee is a generic function, determine the generic argument values + // for the call. + auto specific_id = SemIR::SpecificId::Invalid; + if (callable.generic_id.is_valid()) { + specific_id = DeduceGenericCallArguments( + context, node_id, callable.generic_id, callee_function.specific_id, + callable.implicit_param_refs_id, callable.param_refs_id, + callee_function.self_id, arg_ids); + if (!specific_id.is_valid()) { + return SemIR::InstId::BuiltinError; + } } // If there is a return slot, build storage for the result. SemIR::InstId return_storage_id = SemIR::InstId::Invalid; - { + SemIR::ReturnTypeInfo return_info = [&] { DiagnosticAnnotationScope annotate_diagnostics( &context.emitter(), [&](auto& builder) { CARBON_DIAGNOSTIC(IncompleteReturnTypeHere, Note, "Return type declared here."); builder.Note(callable.return_storage_id, IncompleteReturnTypeHere); }); - CheckFunctionReturnType(context, callee_id, callable); - } - switch (callable.return_slot) { - case SemIR::Function::ReturnSlot::Present: + return CheckFunctionReturnType(context, callee_id, callable, specific_id); + }(); + switch (return_info.init_repr.kind) { + case SemIR::InitRepr::InPlace: // Tentatively put storage for a temporary in the function's return slot. // This will be replaced if necessary when we perform initialization. return_storage_id = context.AddInst( - node_id, {.type_id = type_id}); + node_id, {.type_id = return_info.type_id}); + break; + case SemIR::InitRepr::None: + // For functions with an implicit return type, the return type is the + // empty tuple type. + if (!return_info.type_id.is_valid()) { + return_info.type_id = context.GetTupleType({}); + } break; - case SemIR::Function::ReturnSlot::Absent: + case SemIR::InitRepr::ByCopy: break; - case SemIR::Function::ReturnSlot::Error: + case SemIR::InitRepr::Incomplete: // Don't form an initializing expression with an incomplete type. - type_id = SemIR::TypeId::Error; + // CheckFunctionReturnType will have diagnosed this for us if needed. + return_info.type_id = SemIR::TypeId::Error; break; - case SemIR::Function::ReturnSlot::NotComputed: - CARBON_FATAL() << "Missing return slot category in call to " << callable; } // Convert the arguments to match the parameters. auto converted_args_id = ConvertCallArgs(context, node_id, callee_function.self_id, arg_ids, - return_storage_id, callable.decl_id, - callable.implicit_param_refs_id, callable.param_refs_id); + return_storage_id, callable, specific_id); auto call_inst_id = - context.AddInst(node_id, {.type_id = type_id, + context.AddInst(node_id, {.type_id = return_info.type_id, .callee_id = callee_id, .args_id = converted_args_id}); diff --git a/toolchain/check/check.cpp b/toolchain/check/check.cpp index 3047e00cf8831..5288031413cec 100644 --- a/toolchain/check/check.cpp +++ b/toolchain/check/check.cpp @@ -65,7 +65,7 @@ struct UnitInfo { : check_ir_id(check_ir_id), unit(&unit), converter(unit.tokens, unit.tokens->source().filename(), - unit.parse_tree), + unit.get_parse_tree_and_subtrees), err_tracker(*unit.consumer), emitter(converter, err_tracker) {} @@ -206,8 +206,7 @@ static auto ImportCurrentPackage(Context& context, UnitInfo& unit_info, /*api_imports=*/nullptr, total_ir_count)); context.scope_stack().Push( - package_inst_id, SemIR::NameScopeId::Package, - SemIR::GenericInstanceId::Invalid, + package_inst_id, SemIR::NameScopeId::Package, SemIR::SpecificId::Invalid, context.name_scopes().Get(SemIR::NameScopeId::Package).has_error); } @@ -303,14 +302,6 @@ static auto ImportOtherPackages(Context& context, UnitInfo& unit_info, } // Add imports to the root block. -// TODO: Should this be importing all namespaces before anything else, including -// for imports from other packages? Otherwise, name conflict resolution -// involving something such as `fn F() -> Other.NS.A`, wherein `Other.NS` -// hasn't been imported yet (before `Other.NS` had a constant assigned), could -// result in an inconsistent scoping for `Other.NS.A` versus if it were imported -// as part of scanning `Other.NS` (after `Other.NS` had a constant assigned). -// This will probably require IRs separating out which namespaces they -// declare (or declare entities inside). static auto InitPackageScopeAndImports(Context& context, UnitInfo& unit_info, int total_ir_count) -> void { // First create the constant values map for all imported IRs. We'll populate @@ -656,9 +647,10 @@ class NodeIdTraversal { : context_(context), next_deferred_definition_(&context.parse_tree()), worklist_(vlog_stream) { + auto range = context.parse_tree().postorder(); chunks_.push_back( - {.it = context.parse_tree().postorder().begin(), - .end = context.parse_tree().postorder().end(), + {.it = range.begin(), + .end = range.end(), .next_definition = Parse::DeferredDefinitionIndex::Invalid}); } @@ -726,12 +718,11 @@ class NodeIdTraversal { context_.parse_tree().deferred_definitions().Get(definition_index); HandleFunctionDefinitionResume(context_, definition_info.start_id, std::move(suspended_fn)); - chunks_.push_back( - {.it = context_.parse_tree().postorder(definition_info.start_id).end(), - .end = context_.parse_tree() - .postorder(definition_info.definition_id) - .end(), - .next_definition = next_deferred_definition_.index()}); + auto range = Parse::Tree::PostorderIterator::MakeRange( + definition_info.start_id, definition_info.definition_id); + chunks_.push_back({.it = range.begin() + 1, + .end = range.end(), + .next_definition = next_deferred_definition_.index()}); ++definition_index.index; next_deferred_definition_.SkipTo(definition_index); } @@ -785,7 +776,7 @@ auto NodeIdTraversal::Next() -> std::optional { // Continue type-checking the parse tree after the end of the definition. chunks_.back().it = - context_.parse_tree().postorder(definition_info.definition_id).end(); + Parse::Tree::PostorderIterator(definition_info.definition_id) + 1; next_deferred_definition_.SkipTo(definition_info.next_definition_index); continue; } @@ -885,15 +876,23 @@ static auto CheckParseTree( llvm::MutableArrayRef node_converters, UnitInfo& unit_info, int total_ir_count, llvm::raw_ostream* vlog_stream) -> void { + auto package_id = IdentifierId::Invalid; + auto library_id = StringLiteralValueId::Invalid; + if (const auto& packaging = unit_info.unit->parse_tree->packaging_decl()) { + package_id = packaging->names.package_id; + library_id = packaging->names.library_id; + } unit_info.unit->sem_ir->emplace( - unit_info.check_ir_id, *unit_info.unit->value_stores, + unit_info.check_ir_id, package_id, library_id, + *unit_info.unit->value_stores, unit_info.unit->tokens->source().filename().str()); SemIR::File& sem_ir = **unit_info.unit->sem_ir; SemIRDiagnosticConverter converter(node_converters, &sem_ir); Context::DiagnosticEmitter emitter(converter, unit_info.err_tracker); Context context(*unit_info.unit->tokens, emitter, *unit_info.unit->parse_tree, - sem_ir, vlog_stream); + unit_info.unit->get_parse_tree_and_subtrees, sem_ir, + vlog_stream); PrettyStackTraceFunction context_dumper( [&](llvm::raw_ostream& output) { context.PrintForStackDump(output); }); @@ -1224,7 +1223,6 @@ auto CheckParseTrees(llvm::MutableArrayRef units, bool prelude_import, // Add the prelude import. It's added to explicit_import_map so that it can // conflict with an explicit import of the prelude. - // TODO: Add --no-prelude-import for `/no_prelude/` subdirs. IdentifierId core_ident_id = unit_info.unit->value_stores->identifiers().Add("Core"); if (prelude_import && diff --git a/toolchain/check/check.h b/toolchain/check/check.h index 521df3b289509..62304df421ded 100644 --- a/toolchain/check/check.h +++ b/toolchain/check/check.h @@ -10,6 +10,7 @@ #include "toolchain/diagnostics/diagnostic_emitter.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/tree.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/sem_ir/file.h" namespace Carbon::Check { @@ -20,6 +21,8 @@ struct Unit { const Lex::TokenizedBuffer* tokens; const Parse::Tree* parse_tree; DiagnosticConsumer* consumer; + // Returns a lazily constructed TreeAndSubtrees. + std::function get_parse_tree_and_subtrees; // The generated IR. Unset on input, set on output. std::optional* sem_ir; }; diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 7c80610035ed0..7b0b9a6ab767f 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -13,7 +13,9 @@ #include "toolchain/base/kind_switch.h" #include "toolchain/check/decl_name_stack.h" #include "toolchain/check/eval.h" +#include "toolchain/check/generic.h" #include "toolchain/check/generic_region_stack.h" +#include "toolchain/check/import.h" #include "toolchain/check/import_ref.h" #include "toolchain/check/inst_block_stack.h" #include "toolchain/check/merge.h" @@ -34,11 +36,14 @@ namespace Carbon::Check { Context::Context(const Lex::TokenizedBuffer& tokens, DiagnosticEmitter& emitter, - const Parse::Tree& parse_tree, SemIR::File& sem_ir, - llvm::raw_ostream* vlog_stream) + const Parse::Tree& parse_tree, + llvm::function_ref + get_parse_tree_and_subtrees, + SemIR::File& sem_ir, llvm::raw_ostream* vlog_stream) : tokens_(&tokens), emitter_(&emitter), parse_tree_(&parse_tree), + get_parse_tree_and_subtrees_(get_parse_tree_and_subtrees), sem_ir_(&sem_ir), vlog_stream_(vlog_stream), node_stack_(parse_tree, vlog_stream), @@ -273,11 +278,11 @@ auto Context::LookupUnqualifiedName(Parse::NodeId node_id, scope_stack().LookupInLexicalScopes(name_id); // Walk the non-lexical scopes and perform lookups into each of them. - for (auto [index, lookup_scope_id, instance_id] : + for (auto [index, lookup_scope_id, specific_id] : llvm::reverse(non_lexical_scopes)) { if (auto non_lexical_result = LookupQualifiedName( node_id, name_id, - {.name_scope_id = lookup_scope_id, .instance_id = instance_id}, + {.name_scope_id = lookup_scope_id, .specific_id = specific_id}, /*required=*/false); non_lexical_result.inst_id.is_valid()) { return non_lexical_result; @@ -285,104 +290,19 @@ auto Context::LookupUnqualifiedName(Parse::NodeId node_id, } if (lexical_result.is_valid()) { - // A lexical scope never needs an associated generic instance. If there's a + // A lexical scope never needs an associated specific. If there's a // lexically enclosing generic, then it also encloses the point of use of // the name. - return {.instance_id = SemIR::GenericInstanceId::Invalid, + return {.specific_id = SemIR::SpecificId::Invalid, .inst_id = lexical_result}; } // We didn't find anything at all. DiagnoseNameNotFound(node_id, name_id); - return {.instance_id = SemIR::GenericInstanceId::Invalid, + return {.specific_id = SemIR::SpecificId::Invalid, .inst_id = SemIR::InstId::BuiltinError}; } -// Handles lookup through the import_ir_scopes for LookupNameInExactScope. -static auto LookupInImportIRScopes(Context& context, SemIRLoc loc, - SemIR::NameId name_id, - SemIR::NameScopeId scope_id, - const SemIR::NameScope& scope) - -> SemIR::InstId { - auto identifier_id = name_id.AsIdentifierId(); - llvm::StringRef identifier; - if (identifier_id.is_valid()) { - identifier = context.identifiers().Get(identifier_id); - } - - DiagnosticAnnotationScope annotate_diagnostics( - &context.emitter(), [&](auto& builder) { - CARBON_DIAGNOSTIC(InNameLookup, Note, "In name lookup for `{0}`.", - SemIR::NameId); - builder.Note(loc, InNameLookup, name_id); - }); - - auto result_id = SemIR::InstId::Invalid; - std::optional canonical_result_inst; - - for (auto [import_ir_id, import_scope_id] : scope.import_ir_scopes) { - auto& import_ir = context.import_irs().Get(import_ir_id); - - // Determine the NameId in the import IR. - SemIR::NameId import_name_id = name_id; - if (identifier_id.is_valid()) { - auto import_identifier_id = - import_ir.sem_ir->identifiers().Lookup(identifier); - if (!import_identifier_id.is_valid()) { - // Name doesn't exist in the import IR. - continue; - } - import_name_id = SemIR::NameId::ForIdentifier(import_identifier_id); - } - - // Look up the name in the import scope. - const auto& import_scope = - import_ir.sem_ir->name_scopes().Get(import_scope_id); - auto lookup = import_scope.name_map.Lookup(import_name_id); - if (!lookup) { - // Name doesn't exist in the import scope. - continue; - } - const auto& import_scope_entry = import_scope.names[lookup.value()]; - auto import_inst = - import_ir.sem_ir->insts().Get(import_scope_entry.inst_id); - if (import_inst.Is()) { - // This entity was added to name lookup by using an import, and is not - // exported. - continue; - } - - if (import_scope_entry.access_kind != SemIR::AccessKind::Public) { - // Ignore cross-package non-public names. - continue; - } - - if (result_id.is_valid()) { - // On a conflict, we verify the canonical instruction is the same. - if (!canonical_result_inst) { - canonical_result_inst = - GetCanonicalImportIRInst(context, &context.sem_ir(), result_id); - } - VerifySameCanonicalImportIRInst( - context, result_id, *canonical_result_inst, import_ir_id, - import_ir.sem_ir, import_scope_entry.inst_id); - } else { - // Add the first result found. - auto bind_name_id = context.bind_names().Add( - {.name_id = name_id, - .parent_scope_id = scope_id, - .bind_index = SemIR::CompileTimeBindIndex::Invalid}); - result_id = AddImportRef( - context, - {.ir_id = import_ir_id, .inst_id = import_scope_entry.inst_id}, - bind_name_id); - LoadImportRef(context, result_id); - } - } - - return result_id; -} - auto Context::LookupNameInExactScope(SemIRLoc loc, SemIR::NameId name_id, SemIR::NameScopeId scope_id, const SemIR::NameScope& scope) @@ -393,7 +313,8 @@ auto Context::LookupNameInExactScope(SemIRLoc loc, SemIR::NameId name_id, return inst_id; } if (!scope.import_ir_scopes.empty()) { - return LookupInImportIRScopes(*this, loc, name_id, scope_id, scope); + return ImportNameFromOtherPackage(*this, loc, scope_id, + scope.import_ir_scopes, name_id); } return SemIR::InstId::Invalid; } @@ -402,27 +323,27 @@ auto Context::LookupQualifiedName(Parse::NodeId node_id, SemIR::NameId name_id, LookupScope scope, bool required) -> LookupResult { llvm::SmallVector scopes = {scope}; - LookupResult result = {.instance_id = SemIR::GenericInstanceId::Invalid, + LookupResult result = {.specific_id = SemIR::SpecificId::Invalid, .inst_id = SemIR::InstId::Invalid}; bool has_error = false; // Walk this scope and, if nothing is found here, the scopes it extends. while (!scopes.empty()) { - auto [scope_id, instance_id] = scopes.pop_back_val(); - const auto& scope = name_scopes().Get(scope_id); - has_error |= scope.has_error; + auto [scope_id, specific_id] = scopes.pop_back_val(); + const auto& name_scope = name_scopes().Get(scope_id); + has_error |= name_scope.has_error; auto scope_result_id = - LookupNameInExactScope(node_id, name_id, scope_id, scope); + LookupNameInExactScope(node_id, name_id, scope_id, name_scope); if (!scope_result_id.is_valid()) { // Nothing found in this scope: also look in its extended scopes. - auto extended = scope.extended_scopes; + auto extended = name_scope.extended_scopes; scopes.reserve(scopes.size() + extended.size()); for (auto extended_id : llvm::reverse(extended)) { // TODO: Track a constant describing the extended scope, and substitute - // into it to determine its corresponding generic instance. + // into it to determine its corresponding specific. scopes.push_back({.name_scope_id = extended_id, - .instance_id = SemIR::GenericInstanceId::Invalid}); + .specific_id = SemIR::SpecificId::Invalid}); } continue; } @@ -438,19 +359,19 @@ auto Context::LookupQualifiedName(Parse::NodeId node_id, SemIR::NameId name_id, SemIR::NameId); emitter_->Emit(node_id, NameAmbiguousDueToExtend, name_id); // TODO: Add notes pointing to the scopes. - return {.instance_id = SemIR::GenericInstanceId::Invalid, + return {.specific_id = SemIR::SpecificId::Invalid, .inst_id = SemIR::InstId::BuiltinError}; } result.inst_id = scope_result_id; - result.instance_id = instance_id; + result.specific_id = specific_id; } if (required && !result.inst_id.is_valid()) { if (!has_error) { DiagnoseNameNotFound(node_id, name_id); } - return {.instance_id = SemIR::GenericInstanceId::Invalid, + return {.specific_id = SemIR::SpecificId::Invalid, .inst_id = SemIR::InstId::BuiltinError}; } @@ -733,7 +654,7 @@ class TypeCompleter { case Phase::BuildValueRepr: { auto value_rep = BuildValueRepr(type_id, inst); - context_.sem_ir().CompleteType(type_id, value_rep); + context_.types().SetValueRepr(type_id, value_rep); CARBON_CHECK(old_work_list_size == work_list_.size()) << "BuildValueRepr should not change work items"; work_list_.pop_back(); @@ -797,7 +718,9 @@ class TypeCompleter { } return false; } - // TODO: Trigger generic resolution here for a generic class. + if (inst.specific_id.is_valid()) { + ResolveSpecificDefinition(context_, inst.specific_id); + } Push(class_info.object_repr_id); break; } @@ -1092,7 +1015,9 @@ auto Context::TryToDefineType( return false; } - // TODO: Trigger generic resolution here for a generic instance. + if (interface->specific_id.is_valid()) { + ResolveSpecificDefinition(*this, interface->specific_id); + } } return true; @@ -1102,10 +1027,16 @@ auto Context::GetTypeIdForTypeConstant(SemIR::ConstantId constant_id) -> SemIR::TypeId { CARBON_CHECK(constant_id.is_constant()) << "Canonicalizing non-constant type: " << constant_id; - - auto result = type_ids_for_type_constants_.Insert( - constant_id, [&]() { return types().Add({.constant_id = constant_id}); }); - return result.value(); + auto type_id = + insts().Get(constant_values().GetInstId(constant_id)).type_id(); + // TODO: For now, we allow values of facet type to be used as types. + CARBON_CHECK(type_id == SemIR::TypeId::TypeType || + types().Is(type_id) || + constant_id == SemIR::ConstantId::Error) + << "Forming type ID for non-type constant of type " + << types().GetAsInst(type_id); + + return SemIR::TypeId::ForTypeConstant(constant_id); } // Gets or forms a type_id for a type, given the instruction kind and arguments. @@ -1156,8 +1087,9 @@ auto Context::GetBuiltinType(SemIR::BuiltinInstKind kind) -> SemIR::TypeId { return type_id; } -auto Context::GetFunctionType(SemIR::FunctionId fn_id) -> SemIR::TypeId { - return GetCompleteTypeImpl(*this, fn_id); +auto Context::GetFunctionType(SemIR::FunctionId fn_id, + SemIR::SpecificId specific_id) -> SemIR::TypeId { + return GetCompleteTypeImpl(*this, fn_id, specific_id); } auto Context::GetGenericClassType(SemIR::ClassId class_id) -> SemIR::TypeId { @@ -1188,14 +1120,22 @@ auto Context::GetUnqualifiedType(SemIR::TypeId type_id) -> SemIR::TypeId { } auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void { - node_stack_.PrintForStackDump(output); - inst_block_stack_.PrintForStackDump(output); - param_and_arg_refs_stack_.PrintForStackDump(output); - args_type_info_stack_.PrintForStackDump(output); + output << "Check::Context\n"; + + // In a stack dump, this is probably indented by a tab. We treat that as 8 + // spaces then add a couple to indent past the Context label. + constexpr int Indent = 10; + + SemIR::Formatter formatter(*tokens_, *parse_tree_, *sem_ir_); + node_stack_.PrintForStackDump(formatter, Indent, output); + inst_block_stack_.PrintForStackDump(formatter, Indent, output); + param_and_arg_refs_stack_.PrintForStackDump(formatter, Indent, output); + args_type_info_stack_.PrintForStackDump(formatter, Indent, output); } auto Context::DumpFormattedFile() const -> void { - FormatFile(*tokens_, *parse_tree_, *sem_ir_, llvm::errs()); + SemIR::Formatter formatter(*tokens_, *parse_tree_, *sem_ir_); + formatter.Print(llvm::errs()); } } // namespace Carbon::Check diff --git a/toolchain/check/context.h b/toolchain/check/context.h index 8e9805198e01f..8a1afb55fe119 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -19,6 +19,7 @@ #include "toolchain/check/scope_stack.h" #include "toolchain/parse/node_ids.h" #include "toolchain/parse/tree.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/sem_ir/file.h" #include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/import_ir.h" @@ -30,16 +31,16 @@ namespace Carbon::Check { struct LookupScope { // The name scope in which names are searched. SemIR::NameScopeId name_scope_id; - // The generic instance for the name scope, or `Invalid` if the name scope is - // not an instance of a generic. - SemIR::GenericInstanceId instance_id; + // The specific for the name scope, or `Invalid` if the name scope is not + // defined by a generic or we should perform lookup into the generic itself. + SemIR::SpecificId specific_id; }; // A result produced by name lookup. struct LookupResult { - // The generic instance in which the lookup result was found. `Invalid` if the - // result was not found in a generic instance. - SemIR::GenericInstanceId instance_id; + // The specific in which the lookup result was found. `Invalid` if the result + // was not found in a specific. + SemIR::SpecificId specific_id; // The declaration that was found by name lookup. SemIR::InstId inst_id; }; @@ -53,6 +54,8 @@ class Context { // Stores references for work. explicit Context(const Lex::TokenizedBuffer& tokens, DiagnosticEmitter& emitter, const Parse::Tree& parse_tree, + llvm::function_ref + get_parse_tree_and_subtrees, SemIR::File& sem_ir, llvm::raw_ostream* vlog_stream); // Marks an implementation TODO. Always returns false. @@ -288,7 +291,8 @@ class Context { auto GetBuiltinType(SemIR::BuiltinInstKind kind) -> SemIR::TypeId; // Gets a function type. The returned type will be complete. - auto GetFunctionType(SemIR::FunctionId fn_id) -> SemIR::TypeId; + auto GetFunctionType(SemIR::FunctionId fn_id, SemIR::SpecificId specific_id) + -> SemIR::TypeId; // Gets a generic class type, which is the type of a name of a generic class, // such as the type of `Vector` given `class Vector(T:! type)`. The returned @@ -359,6 +363,10 @@ class Context { auto parse_tree() -> const Parse::Tree& { return *parse_tree_; } + auto parse_tree_and_subtrees() -> const Parse::TreeAndSubtrees& { + return get_parse_tree_and_subtrees_(); + } + auto sem_ir() -> SemIR::File& { return *sem_ir_; } auto node_stack() -> NodeStack& { return node_stack_; } @@ -410,7 +418,9 @@ class Context { auto string_literal_values() -> CanonicalValueStore& { return sem_ir().string_literal_values(); } - auto bind_names() -> SemIR::BindNameStore& { return sem_ir().bind_names(); } + auto entity_names() -> SemIR::EntityNameStore& { + return sem_ir().entity_names(); + } auto functions() -> ValueStore& { return sem_ir().functions(); } @@ -420,9 +430,7 @@ class Context { } auto impls() -> SemIR::ImplStore& { return sem_ir().impls(); } auto generics() -> SemIR::GenericStore& { return sem_ir().generics(); } - auto generic_instances() -> SemIR::GenericInstanceStore& { - return sem_ir().generic_instances(); - } + auto specifics() -> SemIR::SpecificStore& { return sem_ir().specifics(); } auto import_irs() -> ValueStore& { return sem_ir().import_irs(); } @@ -485,6 +493,10 @@ class Context { // The file's parse tree. const Parse::Tree* parse_tree_; + // Returns a lazily constructed TreeAndSubtrees. + llvm::function_ref + get_parse_tree_and_subtrees_; + // The SemIR::File being added to. SemIR::File* sem_ir_; diff --git a/toolchain/check/convert.cpp b/toolchain/check/convert.cpp index f680379e3697b..307f81dc06c05 100644 --- a/toolchain/check/convert.cpp +++ b/toolchain/check/convert.cpp @@ -14,6 +14,8 @@ #include "toolchain/check/context.h" #include "toolchain/sem_ir/copy_on_write_block.h" #include "toolchain/sem_ir/file.h" +#include "toolchain/sem_ir/generic.h" +#include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst.h" #include "toolchain/sem_ir/typed_insts.h" @@ -52,7 +54,8 @@ static auto FindReturnSlotForInitializer(SemIR::File& sem_ir, return init.dest_id; } case CARBON_KIND(SemIR::Call call): { - if (!SemIR::GetInitRepr(sem_ir, call.type_id).has_return_slot()) { + if (!SemIR::ReturnTypeInfo::ForType(sem_ir, call.type_id) + .has_return_slot()) { return SemIR::InstId::Invalid; } if (!call.args_id.is_valid()) { @@ -330,7 +333,7 @@ static auto ConvertTupleToTuple(Context& context, SemIR::TupleType src_type, bool is_init = target.is_initializer(); ConversionTarget::Kind inner_kind = !is_init ? ConversionTarget::Value - : SemIR::GetInitRepr(sem_ir, target.type_id).kind == + : SemIR::InitRepr::ForType(sem_ir, target.type_id).kind == SemIR::InitRepr::InPlace ? ConversionTarget::FullInitializer : ConversionTarget::Initializer; @@ -431,7 +434,7 @@ static auto ConvertStructToStructOrClass(Context& context, bool is_init = target.is_initializer(); ConversionTarget::Kind inner_kind = !is_init ? ConversionTarget::Value - : SemIR::GetInitRepr(sem_ir, target.type_id).kind == + : SemIR::InitRepr::ForType(sem_ir, target.type_id).kind == SemIR::InitRepr::InPlace ? ConversionTarget::FullInitializer : ConversionTarget::Initializer; @@ -732,9 +735,9 @@ static auto PerformBuiltinConversion(Context& context, SemIR::LocId loc_id, if (value_cat == SemIR::ExprCategory::Initializing && IsValidExprCategoryForConversionTarget(SemIR::ExprCategory::Value, target.kind) && - SemIR::GetInitRepr(sem_ir, value_type_id).kind == + SemIR::InitRepr::ForType(sem_ir, value_type_id).kind == SemIR::InitRepr::ByCopy) { - auto value_rep = SemIR::GetValueRepr(sem_ir, value_type_id); + auto value_rep = SemIR::ValueRepr::ForType(sem_ir, value_type_id); if (value_rep.kind == SemIR::ValueRepr::Copy && value_rep.type_id == value_type_id) { // The initializer produces an object representation by copy, and the @@ -888,7 +891,7 @@ static auto PerformCopy(Context& context, SemIR::InstId expr_id) // TODO: Directly track on the value representation whether it's a copy of // the object representation. - auto value_rep = SemIR::GetValueRepr(context.sem_ir(), type_id); + auto value_rep = SemIR::ValueRepr::ForType(context.sem_ir(), type_id); if (value_rep.kind == SemIR::ValueRepr::Copy && value_rep.aggregate_kind == SemIR::ValueRepr::NotAggregate && value_rep.type_id == type_id) { @@ -1047,7 +1050,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id, // Perform a final destination store, if necessary. if (target.kind == ConversionTarget::FullInitializer) { - if (auto init_rep = SemIR::GetInitRepr(sem_ir, target.type_id); + if (auto init_rep = SemIR::InitRepr::ForType(sem_ir, target.type_id); init_rep.kind == SemIR::InitRepr::ByCopy) { target.init_block->InsertHere(); expr_id = context.AddInst( @@ -1117,6 +1120,7 @@ CARBON_DIAGNOSTIC(InCallToFunction, Note, "Calling function declared here."); // Convert the object argument in a method call to match the `self` parameter. static auto ConvertSelf(Context& context, SemIR::LocId call_loc_id, SemIR::InstId callee_id, + SemIR::SpecificId callee_specific_id, std::optional addr_pattern, SemIR::InstId self_param_id, SemIR::Param self_param, SemIR::InstId self_id) -> SemIR::InstId { @@ -1163,19 +1167,22 @@ static auto ConvertSelf(Context& context, SemIR::LocId call_loc_id, .lvalue_id = self_or_addr_id}); } - return ConvertToValueOfType(context, call_loc_id, self_or_addr_id, - self_param.type_id); + return ConvertToValueOfType( + context, call_loc_id, self_or_addr_id, + SemIR::GetTypeInSpecific(context.sem_ir(), callee_specific_id, + self_param.type_id)); } auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, SemIR::InstId self_id, llvm::ArrayRef arg_refs, - SemIR::InstId return_storage_id, SemIR::InstId callee_id, - SemIR::InstBlockId implicit_param_refs_id, - SemIR::InstBlockId param_refs_id) -> SemIR::InstBlockId { + SemIR::InstId return_storage_id, + const SemIR::EntityWithParamsBase& callee, + SemIR::SpecificId callee_specific_id) + -> SemIR::InstBlockId { auto implicit_param_refs = - context.inst_blocks().GetOrEmpty(implicit_param_refs_id); - auto param_refs = context.inst_blocks().GetOrEmpty(param_refs_id); + context.inst_blocks().GetOrEmpty(callee.implicit_param_refs_id); + auto param_refs = context.inst_blocks().GetOrEmpty(callee.param_refs_id); // If sizes mismatch, fail early. if (arg_refs.size() != param_refs.size()) { @@ -1186,7 +1193,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, context.emitter() .Build(call_loc_id, CallArgCountMismatch, arg_refs.size(), param_refs.size()) - .Note(callee_id, InCallToFunction) + .Note(callee.decl_id, InCallToFunction) .Emit(); return SemIR::InstBlockId::Invalid; } @@ -1204,8 +1211,8 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, context.sem_ir(), implicit_param_id); if (param.name_id == SemIR::NameId::SelfValue) { auto converted_self_id = - ConvertSelf(context, call_loc_id, callee_id, addr_pattern, param_id, - param, self_id); + ConvertSelf(context, call_loc_id, callee.decl_id, callee_specific_id, + addr_pattern, param_id, param, self_id); if (converted_self_id == SemIR::InstId::BuiltinError) { return SemIR::InstBlockId::Invalid; } @@ -1223,14 +1230,17 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, CARBON_DIAGNOSTIC( InCallToFunctionParam, Note, "Initializing parameter {0} of function declared here.", int); - builder.Note(callee_id, InCallToFunctionParam, diag_param_index + 1); + builder.Note(callee.decl_id, InCallToFunctionParam, + diag_param_index + 1); }); // Check type conversions per-element. for (auto [i, arg_id, param_id] : llvm::enumerate(arg_refs, param_refs)) { diag_param_index = i; - auto param_type_id = context.insts().Get(param_id).type_id(); + auto param_type_id = + SemIR::GetTypeInSpecific(context.sem_ir(), callee_specific_id, + context.insts().Get(param_id).type_id()); // TODO: Convert to the proper expression category. For now, we assume // parameters are all `let` bindings. auto converted_arg_id = diff --git a/toolchain/check/convert.h b/toolchain/check/convert.h index ac7cbf295dd47..65f8219b72497 100644 --- a/toolchain/check/convert.h +++ b/toolchain/check/convert.h @@ -7,6 +7,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/pending_block.h" +#include "toolchain/sem_ir/ids.h" namespace Carbon::Check { @@ -94,9 +95,10 @@ auto ConvertForExplicitAs(Context& context, Parse::NodeId as_node, auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, SemIR::InstId self_id, llvm::ArrayRef arg_refs, - SemIR::InstId return_storage_id, SemIR::InstId callee_id, - SemIR::InstBlockId implicit_param_refs_id, - SemIR::InstBlockId param_refs_id) -> SemIR::InstBlockId; + SemIR::InstId return_storage_id, + const SemIR::EntityWithParamsBase& callee, + SemIR::SpecificId callee_specific_id) + -> SemIR::InstBlockId; // Converts an expression for use as a type. auto ExprAsType(Context& context, SemIR::LocId loc_id, SemIR::InstId value_id) diff --git a/toolchain/check/decl_name_stack.cpp b/toolchain/check/decl_name_stack.cpp index 6b121338dda0c..1b54e2054f01f 100644 --- a/toolchain/check/decl_name_stack.cpp +++ b/toolchain/check/decl_name_stack.cpp @@ -200,13 +200,27 @@ auto DeclNameStack::LookupOrAddName(NameContext name_context, static auto PushNameQualifierScope(Context& context, SemIR::InstId scope_inst_id, SemIR::NameScopeId scope_id, - SemIR::GenericInstanceId instance_id, + SemIR::SpecificId specific_id, bool has_error = false) -> void { // If the qualifier has no parameters, we don't need to keep around a // parameter scope. context.scope_stack().PopIfEmpty(); - context.scope_stack().Push(scope_inst_id, scope_id, instance_id, has_error); + // When declaring a member of a generic, resolve the self specific. + if (specific_id.is_valid()) { + ResolveSpecificDefinition(context, specific_id); + } + + context.scope_stack().Push(scope_inst_id, scope_id, specific_id, has_error); + + // An interface also introduces its 'Self' parameter into scope, despite it + // not being redeclared as part of the qualifier. + if (auto interface_decl = + context.insts().TryGetAs(scope_inst_id)) { + auto& interface = context.interfaces().Get(interface_decl->interface_id); + context.scope_stack().AddCompileTimeBinding(); + context.scope_stack().PushCompileTimeBinding(interface.self_param_id); + } // Enter a parameter scope in case the qualified name itself has parameters. context.scope_stack().Push(); @@ -218,10 +232,10 @@ auto DeclNameStack::ApplyNameQualifier(const NameComponent& name) -> void { name_context.has_qualifiers = true; // Resolve the qualifier as a scope and enter the new scope. - auto [scope_id, instance_id] = ResolveAsScope(name_context, name); + auto [scope_id, specific_id] = ResolveAsScope(name_context, name); if (scope_id.is_valid()) { PushNameQualifierScope(*context_, name_context.resolved_inst_id, scope_id, - instance_id, + specific_id, context_->name_scopes().Get(scope_id).has_error); name_context.parent_scope_id = scope_id; } else { @@ -352,19 +366,22 @@ static auto DiagnoseQualifiedDeclInNonScope(Context& context, SemIRLoc use_loc, auto DeclNameStack::ResolveAsScope(const NameContext& name_context, const NameComponent& name) const - -> std::pair { - constexpr std::pair - InvalidResult = {SemIR::NameScopeId::Invalid, - SemIR::GenericInstanceId::Invalid}; + -> std::pair { + constexpr std::pair InvalidResult = { + SemIR::NameScopeId::Invalid, SemIR::SpecificId::Invalid}; if (!CheckQualifierIsResolved(*context_, name_context)) { return InvalidResult; } - auto new_params = - DeclParams(name.name_loc_id, name.implicit_params_id, name.params_id); + auto new_params = DeclParams(name.name_loc_id, name.first_param_node_id, + name.last_param_node_id, name.implicit_params_id, + name.params_id); // Find the scope corresponding to the resolved instruction. + // TODO: When diagnosing qualifiers on names, print a diagnostic that talks + // about qualifiers instead of redeclarations. Maybe also rename + // CheckRedeclParamsMatch. CARBON_KIND_SWITCH(context_->insts().Get(name_context.resolved_inst_id)) { case CARBON_KIND(SemIR::ClassDecl class_decl): { const auto& class_info = context_->classes().Get(class_decl.class_id); @@ -378,7 +395,7 @@ auto DeclNameStack::ResolveAsScope(const NameContext& name_context, return InvalidResult; } return {class_info.scope_id, - context_->generics().GetSelfInstance(class_info.generic_id)}; + context_->generics().GetSelfSpecific(class_info.generic_id)}; } case CARBON_KIND(SemIR::InterfaceDecl interface_decl): { const auto& interface_info = @@ -394,15 +411,17 @@ auto DeclNameStack::ResolveAsScope(const NameContext& name_context, return InvalidResult; } return {interface_info.scope_id, - context_->generics().GetSelfInstance(interface_info.generic_id)}; + context_->generics().GetSelfSpecific(interface_info.generic_id)}; } case CARBON_KIND(SemIR::Namespace resolved_inst): { auto scope_id = resolved_inst.name_scope_id; auto& scope = context_->name_scopes().Get(scope_id); - if (!CheckRedeclParamsMatch(*context_, new_params, - DeclParams(name_context.resolved_inst_id, - SemIR::InstBlockId::Invalid, - SemIR::InstBlockId::Invalid))) { + // This is specifically for qualified name handling. + if (!CheckRedeclParamsMatch( + *context_, new_params, + DeclParams(name_context.resolved_inst_id, Parse::NodeId::Invalid, + Parse::NodeId::Invalid, SemIR::InstBlockId::Invalid, + SemIR::InstBlockId::Invalid))) { return InvalidResult; } if (scope.is_closed_import) { @@ -412,7 +431,7 @@ auto DeclNameStack::ResolveAsScope(const NameContext& name_context, // be used as a name qualifier. scope.is_closed_import = false; } - return {scope_id, SemIR::GenericInstanceId::Invalid}; + return {scope_id, SemIR::SpecificId::Invalid}; } default: { DiagnoseQualifiedDeclInNonScope(*context_, name_context.loc_id, diff --git a/toolchain/check/decl_name_stack.h b/toolchain/check/decl_name_stack.h index e3f0c838fe2f6..f5e1152cb960b 100644 --- a/toolchain/check/decl_name_stack.h +++ b/toolchain/check/decl_name_stack.h @@ -65,6 +65,8 @@ class Context; class DeclNameStack { public: // Context for declaration name construction. + // TODO: Add a helper for class, function, and interface to turn a NameContext + // into an EntityWithParamsBase. struct NameContext { enum class State : int8_t { // A context that has not processed any parts of the qualifier. @@ -86,6 +88,23 @@ class DeclNameStack { Error, }; + // Combines name information to produce a base struct for entity + // construction. + auto MakeEntityWithParamsBase(SemIR::InstId decl_id, + const NameComponent& name) + -> SemIR::EntityWithParamsBase { + return { + .name_id = name_id_for_new_inst(), + .parent_scope_id = parent_scope_id_for_new_inst(), + .generic_id = SemIR::GenericId::Invalid, + .first_param_node_id = name.first_param_node_id, + .last_param_node_id = name.last_param_node_id, + .implicit_param_refs_id = name.implicit_params_id, + .param_refs_id = name.params_id, + .decl_id = decl_id, + }; + } + // Returns any name collision found, or Invalid. auto prev_inst_id() -> SemIR::InstId; @@ -234,7 +253,7 @@ class DeclNameStack { // the name doesn't resolve to a scope. auto ResolveAsScope(const NameContext& name_context, const NameComponent& name) const - -> std::pair; + -> std::pair; // The linked context. Context* context_; diff --git a/toolchain/check/deduce.cpp b/toolchain/check/deduce.cpp new file mode 100644 index 0000000000000..124f2d9409aa8 --- /dev/null +++ b/toolchain/check/deduce.cpp @@ -0,0 +1,220 @@ +// 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 + +#include "toolchain/check/deduce.h" + +#include "toolchain/base/kind_switch.h" +#include "toolchain/check/context.h" +#include "toolchain/check/generic.h" +#include "toolchain/check/subst.h" +#include "toolchain/sem_ir/typed_insts.h" + +namespace Carbon::Check { + +namespace { +// A list of pairs of (instruction from generic, corresponding instruction from +// call to of generic) for which we still need to perform deduction, along with +// methods to add and pop pending deductions from the list. Deductions are +// popped in order from most- to least-recently pushed, with the intent that +// they are visited in depth-first order, although the order is not expected to +// matter except when it influences which error is diagnosed. +class DeductionWorklist { + public: + explicit DeductionWorklist(Context& context) : context_(context) {} + + struct PendingDeduction { + SemIR::InstId param; + SemIR::InstId arg; + bool needs_substitution; + }; + + // Adds a single (param, arg) deduction. + auto Add(SemIR::InstId param, SemIR::InstId arg, bool needs_substitution) + -> void { + deductions_.push_back( + {.param = param, .arg = arg, .needs_substitution = needs_substitution}); + } + + // Adds a list of (param, arg) deductions. These are added in reverse order so + // they are popped in forward order. + auto AddAll(llvm::ArrayRef params, + llvm::ArrayRef args, bool needs_substitution) + -> void { + if (params.size() != args.size()) { + // TODO: Decide whether to error on this or just treat the parameter list + // as non-deduced. For now we treat it as non-deduced. + return; + } + for (auto [param, arg] : llvm::reverse(llvm::zip_equal(params, args))) { + Add(param, arg, needs_substitution); + } + } + + auto AddAll(SemIR::InstBlockId params, llvm::ArrayRef args, + bool needs_substitution) -> void { + AddAll(context_.inst_blocks().Get(params), args, needs_substitution); + } + + auto AddAll(SemIR::InstBlockId params, SemIR::InstBlockId args, + bool needs_substitution) -> void { + AddAll(context_.inst_blocks().Get(params), context_.inst_blocks().Get(args), + needs_substitution); + } + + // Returns whether we have completed all deductions. + auto Done() -> bool { return deductions_.empty(); } + + // Pops the next deduction. Requires `!Done()`. + auto PopNext() -> PendingDeduction { return deductions_.pop_back_val(); } + + private: + Context& context_; + llvm::SmallVector deductions_; +}; +} // namespace + +static auto NoteGenericHere(Context& context, SemIR::GenericId generic_id, + Context::DiagnosticBuilder& diag) -> void { + CARBON_DIAGNOSTIC(DeductionGenericHere, Note, + "While deducing parameters of generic declared here."); + diag.Note(context.generics().Get(generic_id).decl_id, DeductionGenericHere); +} + +auto DeduceGenericCallArguments( + Context& context, Parse::NodeId node_id, SemIR::GenericId generic_id, + SemIR::SpecificId enclosing_specific_id, + [[maybe_unused]] SemIR::InstBlockId implicit_params_id, + SemIR::InstBlockId params_id, [[maybe_unused]] SemIR::InstId self_id, + llvm::ArrayRef arg_ids) -> SemIR::SpecificId { + DeductionWorklist worklist(context); + + llvm::SmallVector result_arg_ids; + llvm::SmallVector substitutions; + + // Copy any outer generic arguments from the specified instance and prepare to + // substitute them into the function declaration. + if (enclosing_specific_id.is_valid()) { + auto args = context.inst_blocks().Get( + context.specifics().Get(enclosing_specific_id).args_id); + result_arg_ids.assign(args.begin(), args.end()); + + // TODO: Subst is linear in the length of the substitutions list. Change it + // so we can pass in an array mapping indexes to substitutions instead. + substitutions.reserve(args.size()); + for (auto [i, subst_inst_id] : llvm::enumerate(args)) { + substitutions.push_back( + {.bind_id = SemIR::CompileTimeBindIndex(i), + .replacement_id = context.constant_values().Get(subst_inst_id)}); + } + } + auto first_deduced_index = SemIR::CompileTimeBindIndex(result_arg_ids.size()); + + // Initialize the deduced arguments to Invalid. + result_arg_ids.resize(context.inst_blocks() + .Get(context.generics().Get(generic_id).bindings_id) + .size(), + SemIR::InstId::Invalid); + + // Prepare to perform deduction of the explicit parameters against their + // arguments. + // TODO: Also perform deduction for type of self. + worklist.AddAll(params_id, arg_ids, /*needs_substitution=*/true); + + while (!worklist.Done()) { + auto [param_id, arg_id, needs_substitution] = worklist.PopNext(); + + // If the parameter has a symbolic type, deduce against that. + auto param_type_id = context.insts().Get(param_id).type_id(); + if (param_type_id.AsConstantId().is_symbolic()) { + worklist.Add( + context.types().GetInstId(param_type_id), + context.types().GetInstId(context.insts().Get(arg_id).type_id()), + needs_substitution); + } + + // If the parameter is a symbolic constant, deduce against it. + auto param_const_id = context.constant_values().Get(param_id); + if (!param_const_id.is_valid() || !param_const_id.is_symbolic()) { + continue; + } + + // If we've not yet substituted into the parameter, do so now. + if (needs_substitution) { + param_const_id = SubstConstant(context, param_const_id, substitutions); + if (!param_const_id.is_valid() || !param_const_id.is_symbolic()) { + continue; + } + needs_substitution = false; + } + + CARBON_KIND_SWITCH(context.insts().Get(context.constant_values().GetInstId( + param_const_id))) { + // Deducing a symbolic binding from an argument with a constant value + // deduces the binding as having that constant value. + case CARBON_KIND(SemIR::BindSymbolicName bind): { + auto& entity_name = context.entity_names().Get(bind.entity_name_id); + auto index = entity_name.bind_index; + if (index.is_valid() && index >= first_deduced_index) { + CARBON_CHECK(static_cast(index.index) < result_arg_ids.size()) + << "Deduced value for unexpected index " << index + << "; expected to deduce " << result_arg_ids.size() + << " arguments."; + auto arg_const_inst_id = + context.constant_values().GetConstantInstId(arg_id); + if (arg_const_inst_id.is_valid()) { + if (result_arg_ids[index.index].is_valid() && + result_arg_ids[index.index] != arg_const_inst_id) { + // TODO: Include the two different deduced values. + CARBON_DIAGNOSTIC(DeductionInconsistent, Error, + "Inconsistent deductions for value of generic " + "parameter `{0}`.", + SemIR::NameId); + auto diag = context.emitter().Build( + node_id, DeductionInconsistent, entity_name.name_id); + NoteGenericHere(context, generic_id, diag); + diag.Emit(); + return SemIR::SpecificId::Invalid; + } + result_arg_ids[index.index] = arg_const_inst_id; + } + } + break; + } + + // TODO: Handle more cases. + + default: + break; + } + } + + // Check we deduced an argument value for every parameter. + for (auto [i, deduced_arg_id] : + llvm::enumerate(llvm::ArrayRef(result_arg_ids) + .drop_front(first_deduced_index.index))) { + if (!deduced_arg_id.is_valid()) { + auto binding_index = first_deduced_index.index + i; + auto binding_id = context.inst_blocks().Get( + context.generics().Get(generic_id).bindings_id)[binding_index]; + auto entity_name_id = + context.insts().GetAs(binding_id).entity_name_id; + CARBON_DIAGNOSTIC(DeductionIncomplete, Error, + "Cannot deduce value for generic parameter `{0}`.", + SemIR::NameId); + auto diag = context.emitter().Build( + node_id, DeductionIncomplete, + context.entity_names().Get(entity_name_id).name_id); + NoteGenericHere(context, generic_id, diag); + diag.Emit(); + return SemIR::SpecificId::Invalid; + } + } + + // TODO: Convert the deduced values to the types of the bindings. + + return MakeSpecific(context, generic_id, + context.inst_blocks().AddCanonical(result_arg_ids)); +} + +} // namespace Carbon::Check diff --git a/toolchain/check/deduce.h b/toolchain/check/deduce.h new file mode 100644 index 0000000000000..6daabe1f2916a --- /dev/null +++ b/toolchain/check/deduce.h @@ -0,0 +1,25 @@ +// 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 + +#ifndef CARBON_TOOLCHAIN_CHECK_DEDUCE_H_ +#define CARBON_TOOLCHAIN_CHECK_DEDUCE_H_ + +#include "toolchain/check/context.h" +#include "toolchain/sem_ir/ids.h" + +namespace Carbon::Check { + +// Deduces the generic arguments to use in a call to a generic. +auto DeduceGenericCallArguments(Context& context, Parse::NodeId node_id, + SemIR::GenericId generic_id, + SemIR::SpecificId enclosing_specific_id, + SemIR::InstBlockId implicit_params_id, + SemIR::InstBlockId params_id, + SemIR::InstId self_id, + llvm::ArrayRef arg_ids) + -> SemIR::SpecificId; + +} // namespace Carbon::Check + +#endif // CARBON_TOOLCHAIN_CHECK_DEDUCE_H_ diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index dd98b5252f9b7..e71c56be0d751 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -17,6 +17,153 @@ namespace Carbon::Check { +namespace { +// Information about an eval block of a specific that we are currently building. +struct SpecificEvalInfo { + // The region within the specific whose eval block we are building. + SemIR::GenericInstIndex::Region region; + // The work-in-progress contents of the eval block. + llvm::ArrayRef values; +}; + +// Information about the context within which we are performing evaluation. +class EvalContext { + public: + explicit EvalContext( + Context& context, + SemIR::SpecificId specific_id = SemIR::SpecificId::Invalid, + std::optional specific_eval_info = std::nullopt) + : context_(context), + specific_id_(specific_id), + specific_eval_info_(specific_eval_info) {} + + // Gets the value of the specified compile-time binding in this context. + // Returns `Invalid` if the value is not fixed in this context. + auto GetCompileTimeBindValue(SemIR::CompileTimeBindIndex bind_index) + -> SemIR::ConstantId { + if (!bind_index.is_valid() || !specific_id_.is_valid()) { + return SemIR::ConstantId::Invalid; + } + + const auto& specific = specifics().Get(specific_id_); + auto args = inst_blocks().Get(specific.args_id); + + // Bindings past the ones with known arguments can appear as local + // bindings of entities declared within this generic. + if (static_cast(bind_index.index) >= args.size()) { + return SemIR::ConstantId::Invalid; + } + return constant_values().Get(args[bind_index.index]); + } + + // Given a constant value from the SemIR we're evaluating, finds the + // corresponding constant value to use in the context of this evaluation. + // This can be different if the original SemIR is for a generic and we are + // evaluating with specific arguments for the generic parameters. + auto GetInContext(SemIR::ConstantId const_id) -> SemIR::ConstantId { + if (!const_id.is_symbolic()) { + return const_id; + } + + // While resolving a specific, map from previous instructions in the eval + // block into their evaluated values. These values won't be present on the + // specific itself yet, so `GetConstantInSpecific` won't be able to find + // them. + if (specific_eval_info_) { + const auto& symbolic_info = + constant_values().GetSymbolicConstant(const_id); + if (symbolic_info.index.is_valid() && + symbolic_info.generic_id == + specifics().Get(specific_id_).generic_id && + symbolic_info.index.region() == specific_eval_info_->region) { + auto inst_id = specific_eval_info_->values[symbolic_info.index.index()]; + CARBON_CHECK(inst_id.is_valid()) + << "Forward reference in eval block: index " + << symbolic_info.index.index() << " referenced before evaluation"; + return constant_values().Get(inst_id); + } + } + + // Map from a specific constant value to the canonical value. + return GetConstantInSpecific(sem_ir(), specific_id_, const_id); + } + + // Gets the constant value of the specified instruction in this context. + auto GetConstantValue(SemIR::InstId inst_id) -> SemIR::ConstantId { + return GetInContext(constant_values().Get(inst_id)); + } + + // Gets the constant value of the specified type in this context. + auto GetConstantValue(SemIR::TypeId type_id) -> SemIR::ConstantId { + return GetInContext(types().GetConstantId(type_id)); + } + + // Gets the constant value of the specified type in this context. + auto GetConstantValueAsType(SemIR::TypeId id) -> SemIR::TypeId { + return context().GetTypeIdForTypeConstant(GetConstantValue(id)); + } + + // Gets the instruction describing the constant value of the specified type in + // this context. + auto GetConstantValueAsInst(SemIR::TypeId id) -> SemIR::Inst { + return insts().Get( + context().constant_values().GetInstId(GetConstantValue(id))); + } + + auto ints() -> CanonicalValueStore& { return sem_ir().ints(); } + auto floats() -> FloatValueStore& { return sem_ir().floats(); } + auto entity_names() -> SemIR::EntityNameStore& { + return sem_ir().entity_names(); + } + auto functions() -> const ValueStore& { + return sem_ir().functions(); + } + auto classes() -> const ValueStore& { + return sem_ir().classes(); + } + auto interfaces() -> const ValueStore& { + return sem_ir().interfaces(); + } + auto specifics() -> const SemIR::SpecificStore& { + return sem_ir().specifics(); + } + auto type_blocks() -> SemIR::BlockValueStore& { + return sem_ir().type_blocks(); + } + auto insts() -> const SemIR::InstStore& { return sem_ir().insts(); } + auto inst_blocks() -> SemIR::InstBlockStore& { + return sem_ir().inst_blocks(); + } + + // Gets the constant value store. Note that this does not provide the constant + // values that should be used from this evaluation context, and so should be + // used with caution. + auto constant_values() -> const SemIR::ConstantValueStore& { + return sem_ir().constant_values(); + } + + // Gets the types store. Note that this does not provide the type values that + // should be used from this evaluation context, and so should be used with + // caution. + auto types() -> const SemIR::TypeStore& { return sem_ir().types(); } + + auto context() -> Context& { return context_; } + + auto sem_ir() -> SemIR::File& { return context().sem_ir(); } + + auto emitter() -> Context::DiagnosticEmitter& { return context().emitter(); } + + private: + // The type-checking context in which we're performing evaluation. + Context& context_; + // The specific that we are evaluating within. + SemIR::SpecificId specific_id_; + // If we are currently evaluating an eval block for `specific_id_`, + // information about that evaluation. + std::optional specific_eval_info_; +}; +} // namespace + namespace { // The evaluation phase for an expression, computed by evaluation. These are // ordered so that the phase of an expression is the numerically highest phase @@ -52,15 +199,6 @@ static auto GetPhase(SemIR::ConstantId constant_id) -> Phase { } } -// Gets the earliest possible phase for a constant whose type is `type_id`. The -// type of a constant is effectively treated as an operand of that constant when -// determining its phase. For example, an empty struct with a symbolic type is a -// symbolic constant, not a template constant. -static auto GetTypePhase(Context& context, SemIR::TypeId type_id) -> Phase { - CARBON_CHECK(type_id.is_valid()); - return GetPhase(context.types().GetConstantId(type_id)); -} - // Returns the later of two phases. static auto LatestPhase(Phase a, Phase b) -> Phase { return static_cast( @@ -121,32 +259,34 @@ static auto MakeFloatResult(Context& context, SemIR::TypeId type_id, // Overloads are provided for different kinds of ID. // If the given instruction is constant, returns its constant value. -static auto GetConstantValue(Context& context, SemIR::InstId inst_id, +static auto GetConstantValue(EvalContext& eval_context, SemIR::InstId inst_id, Phase* phase) -> SemIR::InstId { - auto const_id = context.constant_values().Get(inst_id); + auto const_id = eval_context.GetConstantValue(inst_id); *phase = LatestPhase(*phase, GetPhase(const_id)); - return context.constant_values().GetInstId(const_id); + return eval_context.constant_values().GetInstId(const_id); } -// A type is always constant, but we still need to extract its phase. -static auto GetConstantValue(Context& context, SemIR::TypeId type_id, +// Given a type which may refer to a generic parameter, returns the +// corresponding type in the evaluation context. +static auto GetConstantValue(EvalContext& eval_context, SemIR::TypeId type_id, Phase* phase) -> SemIR::TypeId { - auto const_id = context.types().GetConstantId(type_id); + auto const_id = eval_context.GetConstantValue(type_id); *phase = LatestPhase(*phase, GetPhase(const_id)); - return type_id; + return eval_context.context().GetTypeIdForTypeConstant(const_id); } // If the given instruction block contains only constants, returns a // corresponding block of those values. -static auto GetConstantValue(Context& context, SemIR::InstBlockId inst_block_id, - Phase* phase) -> SemIR::InstBlockId { +static auto GetConstantValue(EvalContext& eval_context, + SemIR::InstBlockId inst_block_id, Phase* phase) + -> SemIR::InstBlockId { if (!inst_block_id.is_valid()) { return SemIR::InstBlockId::Invalid; } - auto insts = context.inst_blocks().Get(inst_block_id); + auto insts = eval_context.inst_blocks().Get(inst_block_id); llvm::SmallVector const_insts; for (auto inst_id : insts) { - auto const_inst_id = GetConstantValue(context, inst_id, phase); + auto const_inst_id = GetConstantValue(eval_context, inst_id, phase); if (!const_inst_id.is_valid()) { return SemIR::InstBlockId::Invalid; } @@ -162,52 +302,68 @@ static auto GetConstantValue(Context& context, SemIR::InstBlockId inst_block_id, } // TODO: If the new block is identical to the original block, and we know the // old ID was canonical, return the original ID. - return context.inst_blocks().AddCanonical(const_insts); + return eval_context.inst_blocks().AddCanonical(const_insts); } -// The constant value of a type block is that type block, but we still need to -// extract its phase. -static auto GetConstantValue(Context& context, SemIR::TypeBlockId type_block_id, - Phase* phase) -> SemIR::TypeBlockId { +// Compute the constant value of a type block. This may be different from the +// input type block if we have known generic arguments. +static auto GetConstantValue(EvalContext& eval_context, + SemIR::TypeBlockId type_block_id, Phase* phase) + -> SemIR::TypeBlockId { if (!type_block_id.is_valid()) { return SemIR::TypeBlockId::Invalid; } - auto types = context.type_blocks().Get(type_block_id); + auto types = eval_context.type_blocks().Get(type_block_id); + llvm::SmallVector new_types; for (auto type_id : types) { - GetConstantValue(context, type_id, phase); + auto new_type_id = GetConstantValue(eval_context, type_id, phase); + if (!new_type_id.is_valid()) { + return SemIR::TypeBlockId::Invalid; + } + + // Once we leave the small buffer, we know the first few elements are all + // constant, so it's likely that the entire block is constant. Resize to the + // target size given that we're going to allocate memory now anyway. + if (new_types.size() == new_types.capacity()) { + new_types.reserve(types.size()); + } + + new_types.push_back(new_type_id); } - return type_block_id; + // TODO: If the new block is identical to the original block, and we know the + // old ID was canonical, return the original ID. + return eval_context.type_blocks().AddCanonical(new_types); } -// The constant value of a generic instance is the generic instance with the -// corresponding constant values for its arguments. -static auto GetConstantValue(Context& context, - SemIR::GenericInstanceId instance_id, Phase* phase) - -> SemIR::GenericInstanceId { - if (!instance_id.is_valid()) { - return SemIR::GenericInstanceId::Invalid; +// The constant value of a specific is the specific with the corresponding +// constant values for its arguments. +static auto GetConstantValue(EvalContext& eval_context, + SemIR::SpecificId specific_id, Phase* phase) + -> SemIR::SpecificId { + if (!specific_id.is_valid()) { + return SemIR::SpecificId::Invalid; } - const auto& instance = context.generic_instances().Get(instance_id); - auto args_id = GetConstantValue(context, instance.args_id, phase); + const auto& specific = eval_context.specifics().Get(specific_id); + auto args_id = GetConstantValue(eval_context, specific.args_id, phase); if (!args_id.is_valid()) { - return SemIR::GenericInstanceId::Invalid; + return SemIR::SpecificId::Invalid; } - if (args_id == instance.args_id) { - return instance_id; + if (args_id == specific.args_id) { + return specific_id; } - return MakeGenericInstance(context, instance.generic_id, args_id); + return MakeSpecific(eval_context.context(), specific.generic_id, args_id); } // Replaces the specified field of the given typed instruction with its constant // value, if it has constant phase. Returns true on success, false if the value // has runtime phase. template -static auto ReplaceFieldWithConstantValue(Context& context, InstT* inst, - FieldIdT InstT::*field, Phase* phase) - -> bool { - auto unwrapped = GetConstantValue(context, inst->*field, phase); +static auto ReplaceFieldWithConstantValue(EvalContext& eval_context, + InstT* inst, FieldIdT InstT::*field, + Phase* phase) -> bool { + auto unwrapped = GetConstantValue(eval_context, inst->*field, phase); if (!unwrapped.is_valid() && (inst->*field).is_valid()) { return false; } @@ -222,74 +378,97 @@ static auto ReplaceFieldWithConstantValue(Context& context, InstT* inst, // // The constant value is then checked by calling `validate_fn(typed_inst)`, // which should return a `bool` indicating whether the new constant is valid. If -// validation passes, a corresponding ConstantId for the new constant is +// validation passes, `transform_fn(typed_inst)` is called to produce the final +// constant instruction, and a corresponding ConstantId for the new constant is // returned. If validation fails, it should produce a suitable error message. // `ConstantId::Error` is returned. -template -static auto RebuildAndValidateIfFieldsAreConstant( - Context& context, SemIR::Inst inst, ValidateFn validate_fn, - EachFieldIdT InstT::*... each_field_id) -> SemIR::ConstantId { +template +static auto RebuildIfFieldsAreConstantImpl( + EvalContext& eval_context, SemIR::Inst inst, ValidateFn validate_fn, + TransformFn transform_fn, EachFieldIdT InstT::*... each_field_id) + -> SemIR::ConstantId { // Build a constant instruction by replacing each non-constant operand with // its constant value. auto typed_inst = inst.As(); - // Some instruction kinds don't have a `type_id` field. For those that do, the - // type contributes to the phase. - Phase phase = inst.type_id().is_valid() - ? GetTypePhase(context, inst.type_id()) - : Phase::Template; - if ((ReplaceFieldWithConstantValue(context, &typed_inst, each_field_id, + Phase phase = Phase::Template; + if ((ReplaceFieldWithConstantValue(eval_context, &typed_inst, each_field_id, &phase) && ...)) { if (phase == Phase::UnknownDueToError || !validate_fn(typed_inst)) { return SemIR::ConstantId::Error; } - return MakeConstantResult(context, typed_inst, phase); + return MakeConstantResult(eval_context.context(), transform_fn(typed_inst), + phase); } return MakeNonConstantResult(phase); } +// Same as above but with an identity transform function. +template +static auto RebuildAndValidateIfFieldsAreConstant( + EvalContext& eval_context, SemIR::Inst inst, ValidateFn validate_fn, + EachFieldIdT InstT::*... each_field_id) -> SemIR::ConstantId { + return RebuildIfFieldsAreConstantImpl(eval_context, inst, validate_fn, + std::identity{}, each_field_id...); +} + // Same as above but with no validation step. +template +static auto TransformIfFieldsAreConstant(EvalContext& eval_context, + SemIR::Inst inst, + TransformFn transform_fn, + EachFieldIdT InstT::*... each_field_id) + -> SemIR::ConstantId { + return RebuildIfFieldsAreConstantImpl( + eval_context, inst, [](...) { return true; }, transform_fn, + each_field_id...); +} + +// Same as above but with no validation or transform step. template -static auto RebuildIfFieldsAreConstant(Context& context, SemIR::Inst inst, +static auto RebuildIfFieldsAreConstant(EvalContext& eval_context, + SemIR::Inst inst, EachFieldIdT InstT::*... each_field_id) -> SemIR::ConstantId { - return RebuildAndValidateIfFieldsAreConstant( - context, inst, [](...) { return true; }, each_field_id...); + return RebuildIfFieldsAreConstantImpl( + eval_context, inst, [](...) { return true; }, std::identity{}, + each_field_id...); } // Rebuilds the given aggregate initialization instruction as a corresponding // constant aggregate value, if its elements are all constants. -static auto RebuildInitAsValue(Context& context, SemIR::Inst inst, +static auto RebuildInitAsValue(EvalContext& eval_context, SemIR::Inst inst, SemIR::InstKind value_kind) -> SemIR::ConstantId { - auto init_inst = inst.As(); - Phase phase = GetTypePhase(context, init_inst.type_id); - auto elements_id = GetConstantValue(context, init_inst.elements_id, &phase); - return MakeConstantResult( - context, - SemIR::AnyAggregateValue{.kind = value_kind, - .type_id = init_inst.type_id, - .elements_id = elements_id}, - phase); + return TransformIfFieldsAreConstant( + eval_context, inst, + [&](SemIR::AnyAggregateInit result) { + return SemIR::AnyAggregateValue{.kind = value_kind, + .type_id = result.type_id, + .elements_id = result.elements_id}; + }, + &SemIR::AnyAggregateInit::type_id, &SemIR::AnyAggregateInit::elements_id); } // Performs an access into an aggregate, retrieving the specified element. -static auto PerformAggregateAccess(Context& context, SemIR::Inst inst) +static auto PerformAggregateAccess(EvalContext& eval_context, SemIR::Inst inst) -> SemIR::ConstantId { auto access_inst = inst.As(); Phase phase = Phase::Template; if (auto aggregate_id = - GetConstantValue(context, access_inst.aggregate_id, &phase); + GetConstantValue(eval_context, access_inst.aggregate_id, &phase); aggregate_id.is_valid()) { if (auto aggregate = - context.insts().TryGetAs(aggregate_id)) { - auto elements = context.inst_blocks().Get(aggregate->elements_id); + eval_context.insts().TryGetAs( + aggregate_id)) { + auto elements = eval_context.inst_blocks().Get(aggregate->elements_id); auto index = static_cast(access_inst.index.index); CARBON_CHECK(index < elements.size()) << "Access out of bounds."; // `Phase` is not used here. If this element is a template constant, then // so is the result of indexing, even if the aggregate also contains a // symbolic context. - return context.constant_values().Get(elements[index]); + return eval_context.GetConstantValue(elements[index]); } else { CARBON_CHECK(phase != Phase::Template) << "Failed to evaluate template constant " << inst; @@ -300,63 +479,66 @@ static auto PerformAggregateAccess(Context& context, SemIR::Inst inst) // Performs an index into a homogeneous aggregate, retrieving the specified // element. -static auto PerformAggregateIndex(Context& context, SemIR::Inst inst) +static auto PerformAggregateIndex(EvalContext& eval_context, SemIR::Inst inst) -> SemIR::ConstantId { auto index_inst = inst.As(); Phase phase = Phase::Template; - auto aggregate_id = - GetConstantValue(context, index_inst.aggregate_id, &phase); - auto index_id = GetConstantValue(context, index_inst.index_id, &phase); + auto index_id = GetConstantValue(eval_context, index_inst.index_id, &phase); if (!index_id.is_valid()) { return MakeNonConstantResult(phase); } - auto index = context.insts().TryGetAs(index_id); + auto index = eval_context.insts().TryGetAs(index_id); if (!index) { CARBON_CHECK(phase != Phase::Template) << "Template constant integer should be a literal"; return MakeNonConstantResult(phase); } - // Array indexing is invalid if the index is constant and out of range. - auto aggregate_type_id = - context.insts().Get(index_inst.aggregate_id).type_id(); - const auto& index_val = context.ints().Get(index->int_id); + // Array indexing is invalid if the index is constant and out of range, + // regardless of whether the array itself is constant. + const auto& index_val = eval_context.ints().Get(index->int_id); + auto aggregate_type_id = eval_context.GetConstantValueAsType( + eval_context.insts().Get(index_inst.aggregate_id).type_id()); if (auto array_type = - context.types().TryGetAs(aggregate_type_id)) { - if (auto bound = - context.insts().TryGetAs(array_type->bound_id)) { + eval_context.types().TryGetAs(aggregate_type_id)) { + if (auto bound = eval_context.insts().TryGetAs( + array_type->bound_id)) { // This awkward call to `getZExtValue` is a workaround for APInt not // supporting comparisons between integers of different bit widths. if (index_val.getActiveBits() > 64 || - context.ints().Get(bound->int_id).ule(index_val.getZExtValue())) { + eval_context.ints() + .Get(bound->int_id) + .ule(index_val.getZExtValue())) { CARBON_DIAGNOSTIC(ArrayIndexOutOfBounds, Error, "Array index `{0}` is past the end of type `{1}`.", TypedInt, SemIR::TypeId); - context.emitter().Emit(index_inst.index_id, ArrayIndexOutOfBounds, - {.type = index->type_id, .value = index_val}, - aggregate_type_id); + eval_context.emitter().Emit( + index_inst.index_id, ArrayIndexOutOfBounds, + {.type = index->type_id, .value = index_val}, aggregate_type_id); return SemIR::ConstantId::Error; } } } + auto aggregate_id = + GetConstantValue(eval_context, index_inst.aggregate_id, &phase); if (!aggregate_id.is_valid()) { return MakeNonConstantResult(phase); } auto aggregate = - context.insts().TryGetAs(aggregate_id); + eval_context.insts().TryGetAs(aggregate_id); if (!aggregate) { CARBON_CHECK(phase != Phase::Template) << "Unexpected representation for template constant aggregate"; return MakeNonConstantResult(phase); } - auto elements = context.inst_blocks().Get(aggregate->elements_id); + auto elements = eval_context.inst_blocks().Get(aggregate->elements_id); // We checked this for the array case above. CARBON_CHECK(index_val.ult(elements.size())) << "Index out of bounds in tuple indexing"; - return context.constant_values().Get(elements[index_val.getZExtValue()]); + return eval_context.GetConstantValue(elements[index_val.getZExtValue()]); } // Enforces that an integer type has a valid bit width. @@ -867,7 +1049,7 @@ static auto MakeConstantForBuiltinCall(Context& context, SemIRLoc loc, } // Makes a constant for a call instruction. -static auto MakeConstantForCall(Context& context, SemIRLoc loc, +static auto MakeConstantForCall(EvalContext& eval_context, SemIRLoc loc, SemIR::Call call) -> SemIR::ConstantId { Phase phase = Phase::Template; @@ -879,18 +1061,20 @@ static auto MakeConstantForCall(Context& context, SemIRLoc loc, return SemIR::ConstantId::Error; } - // If the callee isn't constant, this is not a constant call. - if (!ReplaceFieldWithConstantValue(context, &call, &SemIR::Call::callee_id, + // If the callee or return type isn't constant, this is not a constant call. + if (!ReplaceFieldWithConstantValue(eval_context, &call, + &SemIR::Call::callee_id, &phase) || + !ReplaceFieldWithConstantValue(eval_context, &call, &SemIR::Call::type_id, &phase)) { return SemIR::ConstantId::NotConstant; } auto callee_function = - SemIR::GetCalleeFunction(context.sem_ir(), call.callee_id); + SemIR::GetCalleeFunction(eval_context.sem_ir(), call.callee_id); auto builtin_kind = SemIR::BuiltinFunctionKind::None; if (callee_function.function_id.is_valid()) { // Calls to builtins might be constant. - builtin_kind = context.functions() + builtin_kind = eval_context.functions() .Get(callee_function.function_id) .builtin_function_kind; if (builtin_kind == SemIR::BuiltinFunctionKind::None) { @@ -904,7 +1088,7 @@ static auto MakeConstantForCall(Context& context, SemIRLoc loc, } // If the arguments aren't constant, this is not a constant call. - if (!ReplaceFieldWithConstantValue(context, &call, &SemIR::Call::args_id, + if (!ReplaceFieldWithConstantValue(eval_context, &call, &SemIR::Call::args_id, &phase)) { return SemIR::ConstantId::NotConstant; } @@ -914,37 +1098,39 @@ static auto MakeConstantForCall(Context& context, SemIRLoc loc, // Handle calls to builtins. if (builtin_kind != SemIR::BuiltinFunctionKind::None) { - return MakeConstantForBuiltinCall(context, loc, call, builtin_kind, - context.inst_blocks().Get(call.args_id), - phase); + return MakeConstantForBuiltinCall( + eval_context.context(), loc, call, builtin_kind, + eval_context.inst_blocks().Get(call.args_id), phase); } // Look at the type of the callee for special cases: calls to generic class // and generic interface types. - auto type_inst = - context.types().GetAsInst(context.insts().Get(call.callee_id).type_id()); + auto type_inst = eval_context.GetConstantValueAsInst( + eval_context.insts().Get(call.callee_id).type_id()); CARBON_KIND_SWITCH(type_inst) { case CARBON_KIND(SemIR::GenericClassType generic_class): { - auto instance_id = MakeGenericInstance( - context, context.classes().Get(generic_class.class_id).generic_id, + auto specific_id = MakeSpecific( + eval_context.context(), + eval_context.classes().Get(generic_class.class_id).generic_id, call.args_id); return MakeConstantResult( - context, + eval_context.context(), SemIR::ClassType{.type_id = call.type_id, .class_id = generic_class.class_id, - .instance_id = instance_id}, + .specific_id = specific_id}, phase); } case CARBON_KIND(SemIR::GenericInterfaceType generic_interface): { - auto instance_id = MakeGenericInstance( - context, - context.interfaces().Get(generic_interface.interface_id).generic_id, - call.args_id); + auto specific_id = MakeSpecific(eval_context.context(), + eval_context.interfaces() + .Get(generic_interface.interface_id) + .generic_id, + call.args_id); return MakeConstantResult( - context, + eval_context.context(), SemIR::InterfaceType{.type_id = call.type_id, .interface_id = generic_interface.interface_id, - .instance_id = instance_id}, + .specific_id = specific_id}, phase); } default: { @@ -953,37 +1139,38 @@ static auto MakeConstantForCall(Context& context, SemIRLoc loc, } } -auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) - -> SemIR::ConstantId { +auto TryEvalInstInContext(EvalContext& eval_context, SemIR::InstId inst_id, + SemIR::Inst inst) -> SemIR::ConstantId { // TODO: Ensure we have test coverage for each of these cases that can result // in a constant, once those situations are all reachable. CARBON_KIND_SWITCH(inst) { // These cases are constants if their operands are. case SemIR::AddrOf::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::AddrOf::type_id, &SemIR::AddrOf::lvalue_id); case CARBON_KIND(SemIR::ArrayType array_type): { return RebuildAndValidateIfFieldsAreConstant( - context, inst, + eval_context, inst, [&](SemIR::ArrayType result) { auto bound_id = array_type.bound_id; - auto int_bound = - context.insts().TryGetAs(result.bound_id); + auto int_bound = eval_context.insts().TryGetAs( + result.bound_id); if (!int_bound) { // TODO: Permit symbolic array bounds. This will require fixing // callers of `GetArrayBoundValue`. - context.TODO(bound_id, "symbolic array bound"); + eval_context.context().TODO(bound_id, "symbolic array bound"); return false; } // TODO: We should check that the size of the resulting array type // fits in 64 bits, not just that the bound does. Should we use a // 32-bit limit for 32-bit targets? - const auto& bound_val = context.ints().Get(int_bound->int_id); - if (context.types().IsSignedInt(int_bound->type_id) && + const auto& bound_val = eval_context.ints().Get(int_bound->int_id); + if (eval_context.types().IsSignedInt(int_bound->type_id) && bound_val.isNegative()) { CARBON_DIAGNOSTIC(ArrayBoundNegative, Error, "Array bound of {0} is negative.", TypedInt); - context.emitter().Emit( + eval_context.emitter().Emit( bound_id, ArrayBoundNegative, {.type = int_bound->type_id, .value = bound_val}); return false; @@ -991,7 +1178,7 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) if (bound_val.getActiveBits() > 64) { CARBON_DIAGNOSTIC(ArrayBoundTooLarge, Error, "Array bound of {0} is too large.", TypedInt); - context.emitter().Emit( + eval_context.emitter().Emit( bound_id, ArrayBoundTooLarge, {.type = int_bound->type_id, .value = bound_val}); return false; @@ -1000,133 +1187,151 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) }, &SemIR::ArrayType::bound_id, &SemIR::ArrayType::element_type_id); } + case SemIR::AssociatedEntity::Kind: + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::AssociatedEntity::type_id); + case SemIR::AssociatedEntityType::Kind: return RebuildIfFieldsAreConstant( - context, inst, &SemIR::AssociatedEntityType::entity_type_id); + eval_context, inst, &SemIR::AssociatedEntityType::entity_type_id); case SemIR::BoundMethod::Kind: - return RebuildIfFieldsAreConstant(context, inst, - &SemIR::BoundMethod::object_id, - &SemIR::BoundMethod::function_id); + return RebuildIfFieldsAreConstant( + eval_context, inst, &SemIR::BoundMethod::type_id, + &SemIR::BoundMethod::object_id, &SemIR::BoundMethod::function_id); case SemIR::ClassType::Kind: - return RebuildIfFieldsAreConstant(context, inst, - &SemIR::ClassType::instance_id); + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::ClassType::specific_id); + case SemIR::FunctionType::Kind: + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::FunctionType::specific_id); case SemIR::InterfaceType::Kind: - return RebuildIfFieldsAreConstant(context, inst, - &SemIR::InterfaceType::instance_id); + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::InterfaceType::specific_id); case SemIR::InterfaceWitness::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, &SemIR::InterfaceWitness::elements_id); case CARBON_KIND(SemIR::IntType int_type): { return RebuildAndValidateIfFieldsAreConstant( - context, inst, + eval_context, inst, [&](SemIR::IntType result) { - return ValidateIntType(context, int_type.bit_width_id, result); + return ValidateIntType(eval_context.context(), + int_type.bit_width_id, result); }, &SemIR::IntType::bit_width_id); } case SemIR::PointerType::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, &SemIR::PointerType::pointee_id); case CARBON_KIND(SemIR::FloatType float_type): { return RebuildAndValidateIfFieldsAreConstant( - context, inst, + eval_context, inst, [&](SemIR::FloatType result) { - return ValidateFloatType(context, float_type.bit_width_id, result); + return ValidateFloatType(eval_context.context(), + float_type.bit_width_id, result); }, &SemIR::FloatType::bit_width_id); } case SemIR::StructType::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, &SemIR::StructType::fields_id); case SemIR::StructTypeField::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, &SemIR::StructTypeField::field_type_id); case SemIR::StructValue::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::StructValue::type_id, &SemIR::StructValue::elements_id); case SemIR::TupleType::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, &SemIR::TupleType::elements_id); case SemIR::TupleValue::Kind: - return RebuildIfFieldsAreConstant(context, inst, + return RebuildIfFieldsAreConstant(eval_context, inst, + &SemIR::TupleValue::type_id, &SemIR::TupleValue::elements_id); case SemIR::UnboundElementType::Kind: return RebuildIfFieldsAreConstant( - context, inst, &SemIR::UnboundElementType::class_type_id, + eval_context, inst, &SemIR::UnboundElementType::class_type_id, &SemIR::UnboundElementType::element_type_id); // Initializers evaluate to a value of the object representation. case SemIR::ArrayInit::Kind: // TODO: Add an `ArrayValue` to represent a constant array object // representation instead of using a `TupleValue`. - return RebuildInitAsValue(context, inst, SemIR::TupleValue::Kind); + return RebuildInitAsValue(eval_context, inst, SemIR::TupleValue::Kind); case SemIR::ClassInit::Kind: // TODO: Add a `ClassValue` to represent a constant class object // representation instead of using a `StructValue`. - return RebuildInitAsValue(context, inst, SemIR::StructValue::Kind); + return RebuildInitAsValue(eval_context, inst, SemIR::StructValue::Kind); case SemIR::StructInit::Kind: - return RebuildInitAsValue(context, inst, SemIR::StructValue::Kind); + return RebuildInitAsValue(eval_context, inst, SemIR::StructValue::Kind); case SemIR::TupleInit::Kind: - return RebuildInitAsValue(context, inst, SemIR::TupleValue::Kind); + return RebuildInitAsValue(eval_context, inst, SemIR::TupleValue::Kind); - case SemIR::AssociatedEntity::Kind: case SemIR::BuiltinInst::Kind: - case SemIR::FunctionType::Kind: case SemIR::GenericClassType::Kind: case SemIR::GenericInterfaceType::Kind: // Builtins are always template constants. - return MakeConstantResult(context, inst, Phase::Template); + return MakeConstantResult(eval_context.context(), inst, Phase::Template); case CARBON_KIND(SemIR::FunctionDecl fn_decl): { - return MakeConstantResult( - context, - SemIR::StructValue{.type_id = fn_decl.type_id, - .elements_id = SemIR::InstBlockId::Empty}, - GetTypePhase(context, fn_decl.type_id)); + return TransformIfFieldsAreConstant( + eval_context, fn_decl, + [&](SemIR::FunctionDecl result) { + return SemIR::StructValue{.type_id = result.type_id, + .elements_id = SemIR::InstBlockId::Empty}; + }, + &SemIR::FunctionDecl::type_id); } case CARBON_KIND(SemIR::ClassDecl class_decl): { // If the class has generic parameters, we don't produce a class type, but // a callable whose return value is a class type. - if (context.classes().Get(class_decl.class_id).is_generic()) { - return MakeConstantResult( - context, - SemIR::StructValue{.type_id = class_decl.type_id, - .elements_id = SemIR::InstBlockId::Empty}, - GetTypePhase(context, class_decl.type_id)); + if (eval_context.classes().Get(class_decl.class_id).is_generic()) { + return TransformIfFieldsAreConstant( + eval_context, class_decl, + [&](SemIR::ClassDecl result) { + return SemIR::StructValue{ + .type_id = result.type_id, + .elements_id = SemIR::InstBlockId::Empty}; + }, + &SemIR::ClassDecl::type_id); } // A non-generic class declaration evaluates to the class type. return MakeConstantResult( - context, + eval_context.context(), SemIR::ClassType{.type_id = SemIR::TypeId::TypeType, .class_id = class_decl.class_id, - .instance_id = SemIR::GenericInstanceId::Invalid}, + .specific_id = SemIR::SpecificId::Invalid}, Phase::Template); } case CARBON_KIND(SemIR::InterfaceDecl interface_decl): { // If the interface has generic parameters, we don't produce an interface // type, but a callable whose return value is an interface type. - if (context.interfaces().Get(interface_decl.interface_id).is_generic()) { - return MakeConstantResult( - context, - SemIR::StructValue{.type_id = interface_decl.type_id, - .elements_id = SemIR::InstBlockId::Empty}, - GetTypePhase(context, interface_decl.type_id)); + if (eval_context.interfaces() + .Get(interface_decl.interface_id) + .is_generic()) { + return TransformIfFieldsAreConstant( + eval_context, interface_decl, + [&](SemIR::InterfaceDecl result) { + return SemIR::StructValue{ + .type_id = result.type_id, + .elements_id = SemIR::InstBlockId::Empty}; + }, + &SemIR::InterfaceDecl::type_id); } // A non-generic interface declaration evaluates to the interface type. return MakeConstantResult( - context, - SemIR::InterfaceType{ - .type_id = SemIR::TypeId::TypeType, - .interface_id = interface_decl.interface_id, - .instance_id = SemIR::GenericInstanceId::Invalid}, + eval_context.context(), + SemIR::InterfaceType{.type_id = SemIR::TypeId::TypeType, + .interface_id = interface_decl.interface_id, + .specific_id = SemIR::SpecificId::Invalid}, Phase::Template); } - case CARBON_KIND(SemIR::SpecificConstant instance): { - // Pull the instance-specific constant value out of the generic instance. - return SemIR::GetConstantValueInInstance( - context.sem_ir(), instance.instance_id, instance.inst_id); + case CARBON_KIND(SemIR::SpecificConstant specific): { + // Pull the constant value out of the specific. + return SemIR::GetConstantValueInSpecific( + eval_context.sem_ir(), specific.specific_id, specific.inst_id); } // These cases are treated as being the unique canonical definition of the @@ -1147,20 +1352,22 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) // TODO: Convert literals into a canonical form. Currently we can form two // different `i32` constants with the same value if they are represented // by `APInt`s with different bit widths. - return MakeConstantResult(context, inst, Phase::Template); + // TODO: Can the type of an IntLiteral or FloatLiteral be symbolic? If so, + // we may need to rebuild. + return MakeConstantResult(eval_context.context(), inst, Phase::Template); // The elements of a constant aggregate can be accessed. case SemIR::ClassElementAccess::Kind: case SemIR::InterfaceWitnessAccess::Kind: case SemIR::StructAccess::Kind: case SemIR::TupleAccess::Kind: - return PerformAggregateAccess(context, inst); + return PerformAggregateAccess(eval_context, inst); case SemIR::ArrayIndex::Kind: case SemIR::TupleIndex::Kind: - return PerformAggregateIndex(context, inst); + return PerformAggregateIndex(eval_context, inst); case CARBON_KIND(SemIR::Call call): { - return MakeConstantForCall(context, inst_id, call); + return MakeConstantForCall(eval_context, inst_id, call); } // TODO: These need special handling. @@ -1173,58 +1380,67 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) break; case CARBON_KIND(SemIR::BindSymbolicName bind): { + const auto& bind_name = + eval_context.entity_names().Get(bind.entity_name_id); + + // If we know which specific we're evaluating within and this is an + // argument of that specific, its constant value is the corresponding + // argument value. + if (auto value = + eval_context.GetCompileTimeBindValue(bind_name.bind_index); + value.is_valid()) { + return value; + } + // The constant form of a symbolic binding is an idealized form of the // original, with no equivalent value. - bind.bind_name_id = context.bind_names().MakeCanonical(bind.bind_name_id); + bind.entity_name_id = + eval_context.entity_names().MakeCanonical(bind.entity_name_id); bind.value_id = SemIR::InstId::Invalid; - return MakeConstantResult(context, bind, Phase::Symbolic); + return MakeConstantResult(eval_context.context(), bind, Phase::Symbolic); } // These semantic wrappers don't change the constant value. case CARBON_KIND(SemIR::AsCompatible inst): { - return context.constant_values().Get(inst.source_id); + return eval_context.GetConstantValue(inst.source_id); } case CARBON_KIND(SemIR::BindAlias typed_inst): { - return context.constant_values().Get(typed_inst.value_id); + return eval_context.GetConstantValue(typed_inst.value_id); } case CARBON_KIND(SemIR::ExportDecl typed_inst): { - return context.constant_values().Get(typed_inst.value_id); + return eval_context.GetConstantValue(typed_inst.value_id); } case CARBON_KIND(SemIR::NameRef typed_inst): { - // Map from an instance-specific constant value to the canonical value. - // TODO: Remove this once we properly model instructions with - // instance-dependent constant values. - return GetConstantValueInInstance(context.sem_ir(), - SemIR::GenericInstanceId::Invalid, - typed_inst.value_id); + return eval_context.GetConstantValue(typed_inst.value_id); } case CARBON_KIND(SemIR::Converted typed_inst): { - return context.constant_values().Get(typed_inst.result_id); + return eval_context.GetConstantValue(typed_inst.result_id); } case CARBON_KIND(SemIR::InitializeFrom typed_inst): { - return context.constant_values().Get(typed_inst.src_id); + return eval_context.GetConstantValue(typed_inst.src_id); } case CARBON_KIND(SemIR::SpliceBlock typed_inst): { - return context.constant_values().Get(typed_inst.result_id); + return eval_context.GetConstantValue(typed_inst.result_id); } case CARBON_KIND(SemIR::ValueOfInitializer typed_inst): { - return context.constant_values().Get(typed_inst.init_id); + return eval_context.GetConstantValue(typed_inst.init_id); } case CARBON_KIND(SemIR::FacetTypeAccess typed_inst): { // TODO: Once we start tracking the witness in the facet value, remove it // here. For now, we model a facet value as just a type. - return context.constant_values().Get(typed_inst.facet_id); + return eval_context.GetConstantValue(typed_inst.facet_id); } // `not true` -> `false`, `not false` -> `true`. // All other uses of unary `not` are non-constant. case CARBON_KIND(SemIR::UnaryOperatorNot typed_inst): { - auto const_id = context.constant_values().Get(typed_inst.operand_id); + auto const_id = eval_context.GetConstantValue(typed_inst.operand_id); auto phase = GetPhase(const_id); if (phase == Phase::Template) { - auto value = context.insts().GetAs( - context.constant_values().GetInstId(const_id)); - return MakeBoolResult(context, value.type_id, !value.value.ToBool()); + auto value = eval_context.insts().GetAs( + eval_context.constant_values().GetInstId(const_id)); + return MakeBoolResult(eval_context.context(), value.type_id, + !value.value.ToBool()); } if (phase == Phase::UnknownDueToError) { return SemIR::ConstantId::Error; @@ -1235,15 +1451,15 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) // `const (const T)` evaluates to `const T`. Otherwise, `const T` evaluates // to itself. case CARBON_KIND(SemIR::ConstType typed_inst): { - auto inner_id = context.constant_values().Get( - context.types().GetInstId(typed_inst.inner_id)); + auto inner_id = eval_context.GetConstantValue(typed_inst.inner_id); if (inner_id.is_constant() && - context.insts() - .Get(context.constant_values().GetInstId(inner_id)) + eval_context.insts() + .Get(eval_context.constant_values().GetInstId(inner_id)) .Is()) { return inner_id; } - return MakeConstantResult(context, inst, GetPhase(inner_id)); + return MakeConstantResult(eval_context.context(), inst, + GetPhase(inner_id)); } // These cases are either not expressions or not constant. @@ -1272,4 +1488,39 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) return SemIR::ConstantId::NotConstant; } +auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) + -> SemIR::ConstantId { + EvalContext eval_context(context); + return TryEvalInstInContext(eval_context, inst_id, inst); +} + +auto TryEvalBlockForSpecific(Context& context, SemIR::SpecificId specific_id, + SemIR::GenericInstIndex::Region region) + -> SemIR::InstBlockId { + auto generic_id = context.specifics().Get(specific_id).generic_id; + auto eval_block_id = context.generics().Get(generic_id).GetEvalBlock(region); + auto eval_block = context.inst_blocks().Get(eval_block_id); + + llvm::SmallVector result; + result.resize(eval_block.size(), SemIR::InstId::Invalid); + + EvalContext eval_context(context, specific_id, + SpecificEvalInfo{ + .region = region, + .values = result, + }); + + for (auto [i, inst_id] : llvm::enumerate(eval_block)) { + auto const_id = TryEvalInstInContext(eval_context, inst_id, + context.insts().Get(inst_id)); + result[i] = context.constant_values().GetInstId(const_id); + + // TODO: If this becomes possible through monomorphization failure, produce + // a diagnostic and put `SemIR::InstId::BuiltinError` in the table entry. + CARBON_CHECK(result[i].is_valid()); + } + + return context.inst_blocks().Add(result); +} + } // namespace Carbon::Check diff --git a/toolchain/check/eval.h b/toolchain/check/eval.h index 6152fcffdbe3c..d56a41ba4ff7c 100644 --- a/toolchain/check/eval.h +++ b/toolchain/check/eval.h @@ -14,11 +14,16 @@ namespace Carbon::Check { // Determines the phase of the instruction `inst`, and returns its constant // value if it has constant phase. If it has runtime phase, returns // `SemIR::ConstantId::NotConstant`. -// -// TODO: Support symbolic phase. auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) -> SemIR::ConstantId; +// Evaluates the eval block for a region of a specific. Produces a block +// containing the evaluated constant values of the instructions in the eval +// block. +auto TryEvalBlockForSpecific(Context& context, SemIR::SpecificId specific_id, + SemIR::GenericInstIndex::Region region) + -> SemIR::InstBlockId; + } // namespace Carbon::Check #endif // CARBON_TOOLCHAIN_CHECK_EVAL_H_ diff --git a/toolchain/check/function.cpp b/toolchain/check/function.cpp index 7aafb42b18b94..6dc12f505c34a 100644 --- a/toolchain/check/function.cpp +++ b/toolchain/check/function.cpp @@ -13,15 +13,20 @@ namespace Carbon::Check { auto CheckFunctionTypeMatches(Context& context, const SemIR::Function& new_function, const SemIR::Function& prev_function, - Substitutions substitutions) -> bool { + Substitutions substitutions, bool check_syntax) + -> bool { if (!CheckRedeclParamsMatch(context, DeclParams(new_function), - DeclParams(prev_function), substitutions)) { + DeclParams(prev_function), substitutions, + check_syntax)) { return false; } - auto new_return_type_id = new_function.declared_return_type(context.sem_ir()); - auto prev_return_type_id = - prev_function.declared_return_type(context.sem_ir()); + // TODO: Pass a specific ID for `prev_function` instead of substitutions and + // use it here. + auto new_return_type_id = + new_function.GetDeclaredReturnType(context.sem_ir()); + auto prev_return_type_id = prev_function.GetDeclaredReturnType( + context.sem_ir(), SemIR::SpecificId::Invalid); if (new_return_type_id == SemIR::TypeId::Error || prev_return_type_id == SemIR::TypeId::Error) { return false; @@ -66,42 +71,33 @@ auto CheckFunctionTypeMatches(Context& context, } auto CheckFunctionReturnType(Context& context, SemIRLoc loc, - SemIR::Function& function) -> void { - // If we have already checked the return type, we have nothing to do. - if (function.return_slot != SemIR::Function::ReturnSlot::NotComputed) { - return; - } - - if (!function.return_storage_id.is_valid()) { - // Implicit `-> ()` has no return slot. - function.return_slot = SemIR::Function::ReturnSlot::Absent; - return; - } + SemIR::Function& function, + SemIR::SpecificId specific_id) + -> SemIR::ReturnTypeInfo { + auto return_info = SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), + function, specific_id); - auto return_type_id = function.declared_return_type(context.sem_ir()); - CARBON_CHECK(return_type_id.is_valid()) - << "Have return storage but no return type."; + // If we couldn't determine the return information due to the return type + // being incomplete, try to complete it now. + if (return_info.init_repr.kind == SemIR::InitRepr::Incomplete) { + auto diagnose_incomplete_return_type = [&] { + CARBON_DIAGNOSTIC(IncompleteTypeInFunctionReturnType, Error, + "Function returns incomplete type `{0}`.", + SemIR::TypeId); + return context.emitter().Build(loc, IncompleteTypeInFunctionReturnType, + return_info.type_id); + }; - // Check the return type is complete. Only diagnose incompleteness if we've - // not already done so. - auto diagnose_incomplete_return_type = [&] { - CARBON_DIAGNOSTIC(IncompleteTypeInFunctionReturnType, Error, - "Function returns incomplete type `{0}`.", SemIR::TypeId); - return context.emitter().Build(loc, IncompleteTypeInFunctionReturnType, - return_type_id); - }; - if (!context.TryToCompleteType( - return_type_id, - function.return_slot == SemIR::Function::ReturnSlot::Error - ? std::nullopt - : std::optional(diagnose_incomplete_return_type))) { - function.return_slot = SemIR::Function::ReturnSlot::Error; - } else if (SemIR::GetInitRepr(context.sem_ir(), return_type_id) - .has_return_slot()) { - function.return_slot = SemIR::Function::ReturnSlot::Present; - } else { - function.return_slot = SemIR::Function::ReturnSlot::Absent; + // TODO: Consider suppressing the diagnostic if we've already diagnosed a + // definition or call to this function. + if (context.TryToCompleteType(return_info.type_id, + diagnose_incomplete_return_type)) { + return_info = SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), + function, specific_id); + } } + + return return_info; } } // namespace Carbon::Check diff --git a/toolchain/check/function.h b/toolchain/check/function.h index f7de8352ba32d..a2d7a392001de 100644 --- a/toolchain/check/function.h +++ b/toolchain/check/function.h @@ -29,18 +29,20 @@ struct SuspendedFunction { // Checks that `new_function` has the same parameter types and return type as // `prev_function`, applying the specified set of substitutions to the // previous function. Prints a suitable diagnostic and returns false if not. -// Note that this doesn't include the syntactic check that's performed for -// redeclarations. auto CheckFunctionTypeMatches(Context& context, const SemIR::Function& new_function, const SemIR::Function& prev_function, - Substitutions substitutions) -> bool; + Substitutions substitutions, bool check_syntax) + -> bool; // Checks that the return type of the specified function is complete, issuing an // error if not. This computes the return slot usage for the function if -// necessary. +// necessary, and returns information about how the function returns its return +// value. auto CheckFunctionReturnType(Context& context, SemIRLoc loc, - SemIR::Function& function) -> void; + SemIR::Function& function, + SemIR::SpecificId specific_id) + -> SemIR::ReturnTypeInfo; } // namespace Carbon::Check diff --git a/toolchain/check/generic.cpp b/toolchain/check/generic.cpp index 1404a3c2ef29b..f38045abe0272 100644 --- a/toolchain/check/generic.cpp +++ b/toolchain/check/generic.cpp @@ -5,6 +5,7 @@ #include "toolchain/check/generic.h" #include "common/map.h" +#include "toolchain/check/eval.h" #include "toolchain/check/generic_region_stack.h" #include "toolchain/check/subst.h" #include "toolchain/sem_ir/ids.h" @@ -29,10 +30,9 @@ auto StartGenericDefinition(Context& context) -> void { // Adds an instruction `generic_inst_id` to the eval block for a generic region, // which is the current instruction block. The instruction `generic_inst_id` is // expected to compute the value of the constant described by `const_inst_id` in -// each instance of the generic. Forms and returns a corresponding symbolic -// constant ID that refers to the substituted value of that instruction in each -// instance of the generic. -static auto AddGenericConstantToEvalBlock( +// each specific. Forms and returns a corresponding symbolic constant ID that +// refers to the substituted value of that instruction in each specific. +static auto AddGenericConstantInstToEvalBlock( Context& context, SemIR::GenericId generic_id, SemIR::GenericInstIndex::Region region, SemIR::InstId const_inst_id, SemIR::InstId generic_inst_id) -> SemIR::ConstantId { @@ -44,36 +44,67 @@ static auto AddGenericConstantToEvalBlock( } namespace { -// Substitution callbacks to rebuild a generic type in the eval block for a +// A map from an instruction ID representing a canonical symbolic constant to an +// instruction within an eval block of the generic that computes the specific +// value for that constant. +// +// We arbitrarily use a small size of 256 bytes for the map. +// TODO: Determine a better number based on measurements. +using ConstantsInGenericMap = Map; + +// Substitution callbacks to rebuild a generic constant in the eval block for a // generic region. -class RebuildGenericTypeInEvalBlockCallbacks : public SubstInstCallbacks { +class RebuildGenericConstantInEvalBlockCallbacks final + : public SubstInstCallbacks { public: - RebuildGenericTypeInEvalBlockCallbacks( + RebuildGenericConstantInEvalBlockCallbacks( Context& context, SemIR::GenericId generic_id, SemIR::GenericInstIndex::Region region, - Map& constants_in_generic) + ConstantsInGenericMap& constants_in_generic) : context_(context), generic_id_(generic_id), region_(region), constants_in_generic_(constants_in_generic) {} // Check for instructions for which we already have a mapping into the eval - // block, and substitute them for the instructions in the eval block. Note - // that this will at least include mappings for the `BindSymbolicName` - // instructions that introduce our parameters. + // block, and substitute them for the instructions in the eval block. auto Subst(SemIR::InstId& inst_id) const -> bool override { - if (context_.constant_values().Get(inst_id).is_template()) { - // This instruction is a template constant, so can't contain any - // bindings that need to be substituted. + auto const_id = context_.constant_values().Get(inst_id); + if (!const_id.is_valid()) { + // An unloaded import ref should never contain anything we need to + // substitute into. Don't trigger loading it here. + CARBON_CHECK(context_.insts().Is(inst_id)) + << "Substituting into instruction with invalid constant ID: " + << context_.insts().Get(inst_id); + return true; + } + if (!const_id.is_symbolic()) { + // This instruction doesn't have a symbolic constant value, so can't + // contain any bindings that need to be substituted. return true; } // If this instruction is in the map, return the known result. - if (auto result = constants_in_generic_.Lookup(inst_id)) { - inst_id = result.value(); + if (auto result = constants_in_generic_.Lookup( + context_.constant_values().GetInstId(const_id))) { + // In order to reuse instructions from the generic as often as possible, + // keep this instruction as-is if it already has the desired symbolic + // constant value. + if (const_id != context_.constant_values().Get(result.value())) { + inst_id = result.value(); + } CARBON_CHECK(inst_id.is_valid()); return true; } + + // If the instruction is a symbolic binding, build a version in the eval + // block. + if (auto binding = + context_.insts().TryGetAs(inst_id)) { + inst_id = Rebuild(inst_id, *binding); + return true; + } + return false; } @@ -81,57 +112,105 @@ class RebuildGenericTypeInEvalBlockCallbacks : public SubstInstCallbacks { // constant. auto Rebuild(SemIR::InstId orig_inst_id, SemIR::Inst new_inst) const -> SemIR::InstId override { - // TODO: Add a function on `Context` to add the instruction without - // inserting it into the dependent instructions list or computing a constant - // value for it. - auto inst_id = context_.sem_ir().insts().AddInNoBlock( - SemIR::LocIdAndInst::NoLoc(new_inst)); - auto result = constants_in_generic_.Insert(orig_inst_id, inst_id); - CARBON_CHECK(result.is_inserted()) - << "Substituted into an instruction that was already in the map."; - auto const_id = AddGenericConstantToEvalBlock( - context_, generic_id_, region_, orig_inst_id, inst_id); - context_.constant_values().Set(inst_id, const_id); - return inst_id; + auto const_inst_id = + context_.constant_values().GetConstantInstId(orig_inst_id); + // We might already have an instruction in the eval block if a transitive + // operand of this instruction has the same constant value. + auto result = constants_in_generic_.Insert(const_inst_id, [&] { + // TODO: Add a function on `Context` to add the instruction without + // inserting it into the dependent instructions list or computing a + // constant value for it. + // TODO: Provide a location based on the location of the instruction + // that uses the constant. + auto inst_id = context_.sem_ir().insts().AddInNoBlock( + SemIR::LocIdAndInst::NoLoc(new_inst)); + auto const_id = AddGenericConstantInstToEvalBlock( + context_, generic_id_, region_, const_inst_id, inst_id); + context_.constant_values().Set(inst_id, const_id); + return inst_id; + }); + return result.value(); } private: Context& context_; SemIR::GenericId generic_id_; SemIR::GenericInstIndex::Region region_; - Map& constants_in_generic_; + ConstantsInGenericMap& constants_in_generic_; }; } // namespace // Adds instructions to compute the substituted version of `type_id` in each -// instance of a generic into the eval block for the generic, which is the -// current instruction block. Returns a symbolic type ID that refers to the -// substituted type in each instance of the generic. +// specific into the eval block for the generic, which is the current +// instruction block. Returns a symbolic type ID that refers to the substituted +// type in each specific. static auto AddGenericTypeToEvalBlock( Context& context, SemIR::GenericId generic_id, SemIR::GenericInstIndex::Region region, - Map& constants_in_generic, - SemIR::TypeId type_id) -> SemIR::TypeId { + ConstantsInGenericMap& constants_in_generic, SemIR::TypeId type_id) + -> SemIR::TypeId { // Substitute into the type's constant instruction and rebuild it in the eval // block. auto type_inst_id = SubstInst(context, context.types().GetInstId(type_id), - RebuildGenericTypeInEvalBlockCallbacks( + RebuildGenericConstantInEvalBlockCallbacks( context, generic_id, region, constants_in_generic)); return context.GetTypeIdForTypeInst(type_inst_id); } +// Adds instructions to compute the substituted value of `inst_id` in each +// specific into the eval block for the generic, which is the current +// instruction block. Returns a symbolic constant instruction ID that refers to +// the substituted constant value in each specific. +static auto AddGenericConstantToEvalBlock( + Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, + ConstantsInGenericMap& constants_in_generic, SemIR::InstId inst_id) + -> SemIR::ConstantId { + // Substitute into the constant value and rebuild it in the eval block if + // we've not encountered it before. + auto const_inst_id = context.constant_values().GetConstantInstId(inst_id); + auto new_inst_id = + SubstInst(context, const_inst_id, + RebuildGenericConstantInEvalBlockCallbacks( + context, generic_id, region, constants_in_generic)); + CARBON_CHECK(new_inst_id != const_inst_id) + << "Did not apply any substitutions to symbolic constant " + << context.insts().Get(const_inst_id); + return context.constant_values().Get(new_inst_id); +} + +// Populates a map of constants in a generic from the constants in the +// declaration region, in preparation for building the definition region. +static auto PopulateConstantsFromDeclaration( + Context& context, SemIR::GenericId generic_id, + ConstantsInGenericMap& constants_in_generic) { + // For the definition region, populate constants from the declaration. + auto decl_eval_block = context.inst_blocks().Get( + context.generics().Get(generic_id).decl_block_id); + constants_in_generic.GrowForInsertCount(decl_eval_block.size()); + for (auto inst_id : decl_eval_block) { + auto const_inst_id = context.constant_values().GetConstantInstId(inst_id); + auto result = constants_in_generic.Insert(const_inst_id, inst_id); + CARBON_CHECK(result.is_inserted()) + << "Duplicate constant in generic decl eval block: " + << context.insts().Get(const_inst_id); + } +} + // Builds and returns a block of instructions whose constant values need to be -// evaluated in order to resolve a generic instance. +// evaluated in order to resolve a generic to a specific. static auto MakeGenericEvalBlock(Context& context, SemIR::GenericId generic_id, SemIR::GenericInstIndex::Region region) -> SemIR::InstBlockId { context.inst_block_stack().Push(); - Map constants_in_generic; - // TODO: For the definition region, populate constants from the declaration. - // TODO: Add `BindSymbolicName` instructions for enclosing generics to the - // map. + ConstantsInGenericMap constants_in_generic; + + // For the definition region, populate constants from the declaration. + if (region == SemIR::GenericInstIndex::Region::Definition) { + PopulateConstantsFromDeclaration(context, generic_id, constants_in_generic); + } // The work done in this loop might invalidate iterators into the generic // region stack, but shouldn't add new dependent instructions to the current @@ -146,28 +225,30 @@ static auto MakeGenericEvalBlock(Context& context, SemIR::GenericId generic_id, if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicType) != GenericRegionStack::DependencyKind::None) { auto inst = context.insts().Get(inst_id); - inst.SetType(AddGenericTypeToEvalBlock( - context, generic_id, region, constants_in_generic, inst.type_id())); + auto type_id = AddGenericTypeToEvalBlock( + context, generic_id, region, constants_in_generic, inst.type_id()); + // TODO: Eventually, completeness requirements should be modeled as + // constraints on the generic rather than properties of the type. For now, + // require the transformed type to be complete if the original was. + // TODO: We'll also need to do this when evaluating the eval block. + if (context.types().IsComplete(inst.type_id())) { + context.TryToCompleteType(type_id); + } + inst.SetType(type_id); context.sem_ir().insts().Set(inst_id, inst); } // If the instruction has a symbolic constant value, then make a note that - // we'll need to evaluate this instruction in the generic instance. Update + // we'll need to evaluate this instruction when forming the specific. Update // the constant value of the instruction to refer to the result of that // eventual evaluation. if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicConstant) != GenericRegionStack::DependencyKind::None) { - auto const_inst_id = context.constant_values().GetConstantInstId(inst_id); - - // Create a new symbolic constant representing this instruction in this - // generic, if it doesn't already exist. - auto result = constants_in_generic.Insert(const_inst_id, inst_id); - auto const_id = - result.is_inserted() - ? AddGenericConstantToEvalBlock(context, generic_id, region, - const_inst_id, inst_id) - : context.constant_values().Get(result.value()); - context.constant_values().Set(inst_id, const_id); + // Update the constant value to refer to this generic. + context.constant_values().Set( + inst_id, + AddGenericConstantToEvalBlock(context, generic_id, region, + constants_in_generic, inst_id)); } } @@ -181,6 +262,37 @@ static auto MakeGenericEvalBlock(Context& context, SemIR::GenericId generic_id, return context.inst_block_stack().Pop(); } +// Builds and returns an eval block, given the list of canonical symbolic +// constants that the instructions in the eval block should produce. This is +// used when importing a generic. +auto RebuildGenericEvalBlock(Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, + llvm::ArrayRef const_ids) + -> SemIR::InstBlockId { + context.inst_block_stack().Push(); + + ConstantsInGenericMap constants_in_generic; + + // For the definition region, populate constants from the declaration. + if (region == SemIR::GenericInstIndex::Region::Definition) { + PopulateConstantsFromDeclaration(context, generic_id, constants_in_generic); + } + + constants_in_generic.GrowForInsertCount(const_ids.size()); + for (auto [i, inst_id] : llvm::enumerate(const_ids)) { + // Build a constant in the inst block. + AddGenericConstantToEvalBlock(context, generic_id, region, + constants_in_generic, inst_id); + CARBON_CHECK(context.inst_block_stack().PeekCurrentBlockContents().size() == + i + 1) + << "Produced " + << (context.inst_block_stack().PeekCurrentBlockContents().size() - i) + << " instructions when importing " << context.insts().Get(inst_id); + } + + return context.inst_block_stack().Pop(); +} + auto FinishGenericDecl(Context& context, SemIR::InstId decl_id) -> SemIR::GenericId { auto all_bindings = @@ -194,21 +306,23 @@ auto FinishGenericDecl(Context& context, SemIR::InstId decl_id) return SemIR::GenericId::Invalid; } + // Build the new Generic object. Note that we intentionally do not hold a + // persistent reference to it throughout this function, because the `generics` + // collection can have items added to it by import resolution while we are + // building this generic. auto bindings_id = context.inst_blocks().Add(all_bindings); auto generic_id = context.generics().Add( SemIR::Generic{.decl_id = decl_id, .bindings_id = bindings_id, - .self_instance_id = SemIR::GenericInstanceId::Invalid}); + .self_specific_id = SemIR::SpecificId::Invalid}); auto decl_block_id = MakeGenericEvalBlock( context, generic_id, SemIR::GenericInstIndex::Region::Declaration); context.generic_region_stack().Pop(); + context.generics().Get(generic_id).decl_block_id = decl_block_id; - auto self_instance_id = MakeGenericSelfInstance(context, generic_id); - - auto& generic_info = context.generics().Get(generic_id); - generic_info.decl_block_id = decl_block_id; - generic_info.self_instance_id = self_instance_id; + auto self_specific_id = MakeSelfSpecific(context, generic_id); + context.generics().Get(generic_id).self_specific_id = self_specific_id; return generic_id; } @@ -230,22 +344,34 @@ auto FinishGenericDefinition(Context& context, SemIR::GenericId generic_id) return; } - // TODO: Track the list of dependent instructions in this region. + auto definition_block_id = MakeGenericEvalBlock( + context, generic_id, SemIR::GenericInstIndex::Region::Definition); + context.generics().Get(generic_id).definition_block_id = definition_block_id; + context.generic_region_stack().Pop(); } -auto MakeGenericInstance(Context& context, SemIR::GenericId generic_id, - SemIR::InstBlockId args_id) - -> SemIR::GenericInstanceId { - auto instance_id = context.generic_instances().GetOrAdd(generic_id, args_id); - // TODO: Perform substitution into the generic declaration if needed. - return instance_id; +auto MakeSpecific(Context& context, SemIR::GenericId generic_id, + SemIR::InstBlockId args_id) -> SemIR::SpecificId { + auto specific_id = context.specifics().GetOrAdd(generic_id, args_id); + + // If this is the first time we've formed this specific, evaluate its decl + // block to form information about the specific. + if (!context.specifics().Get(specific_id).decl_block_id.is_valid()) { + auto decl_block_id = TryEvalBlockForSpecific( + context, specific_id, SemIR::GenericInstIndex::Region::Declaration); + // Note that TryEvalBlockForSpecific may reallocate the list of specifics, + // so re-lookup the specific here. + context.specifics().Get(specific_id).decl_block_id = decl_block_id; + } + + return specific_id; } -auto MakeGenericSelfInstance(Context& context, SemIR::GenericId generic_id) - -> SemIR::GenericInstanceId { +auto MakeSelfSpecific(Context& context, SemIR::GenericId generic_id) + -> SemIR::SpecificId { if (!generic_id.is_valid()) { - return SemIR::GenericInstanceId::Invalid; + return SemIR::SpecificId::Invalid; } auto& generic = context.generics().Get(generic_id); @@ -259,23 +385,34 @@ auto MakeGenericSelfInstance(Context& context, SemIR::GenericId generic_id) } auto args_id = context.inst_blocks().AddCanonical(arg_ids); - // Build a corresponding instance. + // Build a corresponding specific. // TODO: This could be made more efficient. We don't need to perform // substitution here; we know we want identity mappings for all constants and // types. We could also consider not storing the mapping at all in this case. - return MakeGenericInstance(context, generic_id, args_id); + return MakeSpecific(context, generic_id, args_id); } -auto GetTypeInInstance(Context& context, SemIR::GenericInstanceId instance_id, - SemIR::TypeId type_id) -> SemIR::TypeId { - auto const_id = context.types().GetConstantId(type_id); - auto inst_const_id = - GetConstantInInstance(context.sem_ir(), instance_id, const_id); - if (inst_const_id == const_id) { - // Common case: not an instance constant. - return type_id; +auto ResolveSpecificDefinition(Context& context, SemIR::SpecificId specific_id) + -> bool { + auto& specific = context.specifics().Get(specific_id); + auto generic_id = specific.generic_id; + CARBON_CHECK(generic_id.is_valid()) << "Specific with no generic ID"; + + if (!specific.definition_block_id.is_valid()) { + // Evaluate the eval block for the definition of the generic. + auto& generic = context.generics().Get(generic_id); + if (!generic.definition_block_id.is_valid()) { + // The generic is not defined yet. + return false; + } + auto definition_block_id = TryEvalBlockForSpecific( + context, specific_id, SemIR::GenericInstIndex::Region::Definition); + // Note that TryEvalBlockForSpecific may reallocate the list of specifics, + // so re-lookup the specific here. + context.specifics().Get(specific_id).definition_block_id = + definition_block_id; } - return context.GetTypeIdForTypeConstant(inst_const_id); + return true; } } // namespace Carbon::Check diff --git a/toolchain/check/generic.h b/toolchain/check/generic.h index 10b8b537d8454..4008bd1f17461 100644 --- a/toolchain/check/generic.h +++ b/toolchain/check/generic.h @@ -31,28 +31,33 @@ auto FinishGenericRedecl(Context& context, SemIR::InstId decl_id, auto FinishGenericDefinition(Context& context, SemIR::GenericId generic_id) -> void; -// Builds a new generic instance, or finds an existing one if this instance of -// this generic has already been referenced. Performs substitution into the +// Builds and returns an eval block, given the list of canonical symbolic +// constants that the instructions in the eval block should produce. This is +// used when importing a generic. +auto RebuildGenericEvalBlock(Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, + llvm::ArrayRef const_ids) + -> SemIR::InstBlockId; + +// Builds a new specific, or finds an existing one if this generic has already +// been referenced with these arguments. Performs substitution into the // declaration, but not the definition, of the generic. // // `args_id` should be a canonical instruction block referring to constants. -auto MakeGenericInstance(Context& context, SemIR::GenericId generic_id, - SemIR::InstBlockId args_id) - -> SemIR::GenericInstanceId; - -// Builds the generic instance corresponding to the generic itself. For example, -// for a generic `G(T:! type)`, this is `G(T)`. For an invalid `generic_id`, -// returns an invalid instance ID. -auto MakeGenericSelfInstance(Context& context, SemIR::GenericId generic_id) - -> SemIR::GenericInstanceId; - -// Gets the substituted value of a type within a specified instance of a -// generic. Note that this does not perform substitution, and will return -// `Invalid` if the substituted type is not yet known. -// -// TODO: Move this to sem_ir so that lowering can use it. -auto GetTypeInInstance(Context& context, SemIR::GenericInstanceId instance_id, - SemIR::TypeId type_id) -> SemIR::TypeId; +auto MakeSpecific(Context& context, SemIR::GenericId generic_id, + SemIR::InstBlockId args_id) -> SemIR::SpecificId; + +// Builds the specific that describes how the generic should refer to itself. +// For example, for a generic `G(T:! type)`, this is the specific `G(T)`. For an +// invalid `generic_id`, returns an invalid specific ID. +auto MakeSelfSpecific(Context& context, SemIR::GenericId generic_id) + -> SemIR::SpecificId; + +// Attempts to resolve the definition of the given specific, by evaluating the +// eval block of the corresponding generic and storing a corresponding value +// block in the specific. Returns false if a definition is not available. +auto ResolveSpecificDefinition(Context& context, SemIR::SpecificId specific_id) + -> bool; } // namespace Carbon::Check diff --git a/toolchain/check/global_init.cpp b/toolchain/check/global_init.cpp index 56995b1d06d52..ce13d390b4ad6 100644 --- a/toolchain/check/global_init.cpp +++ b/toolchain/check/global_init.cpp @@ -35,16 +35,17 @@ auto GlobalInit::Finalize() -> void { auto name_id = context_->sem_ir().identifiers().Add("__global_init"); context_->sem_ir().functions().Add( - {.name_id = SemIR::NameId::ForIdentifier(name_id), - .parent_scope_id = SemIR::NameScopeId::Package, - .decl_id = SemIR::InstId::Invalid, - .generic_id = SemIR::GenericId::Invalid, - .implicit_param_refs_id = SemIR::InstBlockId::Invalid, - .param_refs_id = SemIR::InstBlockId::Empty, - .return_storage_id = SemIR::InstId::Invalid, - .is_extern = false, - .return_slot = SemIR::Function::ReturnSlot::Absent, - .body_block_ids = {SemIR::InstBlockId::GlobalInit}}); + {{.name_id = SemIR::NameId::ForIdentifier(name_id), + .parent_scope_id = SemIR::NameScopeId::Package, + .generic_id = SemIR::GenericId::Invalid, + .first_param_node_id = Parse::NodeId::Invalid, + .last_param_node_id = Parse::NodeId::Invalid, + .implicit_param_refs_id = SemIR::InstBlockId::Invalid, + .param_refs_id = SemIR::InstBlockId::Empty, + .decl_id = SemIR::InstId::Invalid}, + {.return_storage_id = SemIR::InstId::Invalid, + .is_extern = false, + .body_block_ids = {SemIR::InstBlockId::GlobalInit}}}); } } // namespace Carbon::Check diff --git a/toolchain/check/handle_alias.cpp b/toolchain/check/handle_alias.cpp index 63953ebeb243b..ce1ecc858a286 100644 --- a/toolchain/check/handle_alias.cpp +++ b/toolchain/check/handle_alias.cpp @@ -34,7 +34,7 @@ auto HandleParseNode(Context& context, Parse::AliasId /*node_id*/) -> bool { context.decl_introducer_state_stack().Pop(); LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Access); - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_context.name_id_for_new_inst(), .parent_scope_id = name_context.parent_scope_id_for_new_inst(), .bind_index = SemIR::CompileTimeBindIndex::Invalid}); @@ -61,7 +61,7 @@ auto HandleParseNode(Context& context, Parse::AliasId /*node_id*/) -> bool { } auto alias_id = context.AddInst( name_context.loc_id, {.type_id = alias_type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = alias_value_id}); // Add the name of the binding to the current scope. diff --git a/toolchain/check/handle_binding_pattern.cpp b/toolchain/check/handle_binding_pattern.cpp index 2c9e4146bac0b..3843e9cc09dfa 100644 --- a/toolchain/check/handle_binding_pattern.cpp +++ b/toolchain/check/handle_binding_pattern.cpp @@ -37,7 +37,7 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, SemIR::InstId value_id) -> SemIR::LocIdAndInst { // TODO: Eventually the name will need to support associations with other // scopes, but right now we don't support qualified names here. - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = context.scope_stack().PeekNameScopeId(), // TODO: Don't allocate a compile-time binding index for an associated @@ -49,13 +49,13 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, // TODO: Create a `BindTemplateName` instead inside a `template` pattern. return SemIR::LocIdAndInst( name_node, SemIR::BindSymbolicName{.type_id = type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = value_id}); } else { - return SemIR::LocIdAndInst(name_node, - SemIR::BindName{.type_id = type_id, - .bind_name_id = bind_name_id, - .value_id = value_id}); + return SemIR::LocIdAndInst( + name_node, SemIR::BindName{.type_id = type_id, + .entity_name_id = entity_name_id, + .value_id = value_id}); } }; @@ -206,7 +206,7 @@ auto HandleParseNode(Context& context, Parse::AddrId node_id) -> bool { if (auto self_param = context.insts().TryGetAs(self_param_id); self_param && - context.bind_names().Get(self_param->bind_name_id).name_id == + context.entity_names().Get(self_param->entity_name_id).name_id == SemIR::NameId::SelfValue) { // TODO: The type of an `addr_pattern` should probably be the non-pointer // type, because that's the type that the pattern matches. diff --git a/toolchain/check/handle_class.cpp b/toolchain/check/handle_class.cpp index e14ecbf4818c8..49da8614a86c2 100644 --- a/toolchain/check/handle_class.cpp +++ b/toolchain/check/handle_class.cpp @@ -56,8 +56,7 @@ static auto MergeClassRedecl(Context& context, SemIRLoc new_loc, SemIR::ClassId prev_class_id, bool prev_is_extern, SemIR::ImportIRId prev_import_ir_id) -> bool { auto& prev_class = context.classes().Get(prev_class_id); - SemIRLoc prev_loc = - prev_class.is_defined() ? prev_class.definition_id : prev_class.decl_id; + SemIRLoc prev_loc = prev_class.latest_decl_id(); // Check the generic parameters match, if they were specified. if (!CheckRedeclParamsMatch(context, DeclParams(new_class), @@ -93,9 +92,7 @@ static auto MergeClassRedecl(Context& context, SemIRLoc new_loc, } if (new_is_definition) { - prev_class.implicit_param_refs_id = new_class.implicit_param_refs_id; - prev_class.param_refs_id = new_class.param_refs_id; - prev_class.definition_id = new_class.definition_id; + prev_class.MergeDefinition(new_class); prev_class.scope_id = new_class.scope_id; prev_class.body_block_id = new_class.body_block_id; prev_class.adapt_id = new_class.adapt_id; @@ -222,15 +219,10 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId node_id, // TODO: Store state regarding is_extern. SemIR::Class class_info = { - .name_id = name_context.name_id_for_new_inst(), - .parent_scope_id = name_context.parent_scope_id_for_new_inst(), - .generic_id = SemIR::GenericId::Invalid, - .implicit_param_refs_id = name.implicit_params_id, - .param_refs_id = name.params_id, - // `.self_type_id` depends on the ClassType, so is set below. - .self_type_id = SemIR::TypeId::Invalid, - .decl_id = class_decl_id, - .inheritance_kind = inheritance_kind}; + name_context.MakeEntityWithParamsBase(class_decl_id, name), + {// `.self_type_id` depends on the ClassType, so is set below. + .self_type_id = SemIR::TypeId::Invalid, + .inheritance_kind = inheritance_kind}}; MergeOrAddName(context, node_id, name_context, class_decl_id, class_decl, class_info, is_definition, is_extern, @@ -260,13 +252,13 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId node_id, // declaration. auto& class_info = context.classes().Get(class_decl.class_id); if (class_info.is_generic()) { - auto instance_id = - context.generics().GetSelfInstance(class_info.generic_id); + auto specific_id = + context.generics().GetSelfSpecific(class_info.generic_id); class_info.self_type_id = context.GetTypeIdForTypeConstant( TryEvalInst(context, SemIR::InstId::Invalid, SemIR::ClassType{.type_id = SemIR::TypeId::TypeType, .class_id = class_decl.class_id, - .instance_id = instance_id})); + .specific_id = specific_id})); } else { class_info.self_type_id = context.GetTypeIdForTypeInst(class_decl_id); } @@ -301,7 +293,7 @@ auto HandleParseNode(Context& context, Parse::ClassDefinitionStartId node_id) // Enter the class scope. context.scope_stack().Push( class_decl_id, class_info.scope_id, - context.generics().GetSelfInstance(class_info.generic_id)); + context.generics().GetSelfSpecific(class_info.generic_id)); StartGenericDefinition(context); // Introduce `Self`. diff --git a/toolchain/check/handle_export.cpp b/toolchain/check/handle_export.cpp index 9e660b2025bf6..1389e10fb6b5f 100644 --- a/toolchain/check/handle_export.cpp +++ b/toolchain/check/handle_export.cpp @@ -70,15 +70,15 @@ auto HandleParseNode(Context& context, Parse::ExportDeclId node_id) -> bool { auto export_id = context.AddInst( node_id, {.type_id = import_ref->type_id, - .bind_name_id = import_ref->bind_name_id, + .entity_name_id = import_ref->entity_name_id, .value_id = inst_id}); context.AddExport(export_id); // Replace the ImportRef in name lookup, both for the above duplicate // diagnostic and so that cross-package imports can find it easily. - auto bind_name = context.bind_names().Get(import_ref->bind_name_id); - auto& parent_scope = context.name_scopes().Get(bind_name.parent_scope_id); - auto lookup = parent_scope.name_map.Lookup(bind_name.name_id); + auto entity_name = context.entity_names().Get(import_ref->entity_name_id); + auto& parent_scope = context.name_scopes().Get(entity_name.parent_scope_id); + auto lookup = parent_scope.name_map.Lookup(entity_name.name_id); auto& scope_inst_id = parent_scope.names[lookup.value()].inst_id; CARBON_CHECK(scope_inst_id == inst_id); scope_inst_id = export_id; diff --git a/toolchain/check/handle_function.cpp b/toolchain/check/handle_function.cpp index f801043ad0491..6f03bbca8de30 100644 --- a/toolchain/check/handle_function.cpp +++ b/toolchain/check/handle_function.cpp @@ -64,28 +64,6 @@ static auto DiagnoseModifiers(Context& context, DeclIntroducerState& introducer, RequireDefaultFinalOnlyInInterfaces(context, introducer, parent_scope_inst); } -// Returns the return slot usage for a function given the computed usage for two -// different declarations of the function. -static auto MergeReturnSlot(SemIR::Function::ReturnSlot a, - SemIR::Function::ReturnSlot b) - -> SemIR::Function::ReturnSlot { - if (a == SemIR::Function::ReturnSlot::NotComputed) { - return b; - } - if (b == SemIR::Function::ReturnSlot::NotComputed) { - return a; - } - if (a == SemIR::Function::ReturnSlot::Error) { - return b; - } - if (b == SemIR::Function::ReturnSlot::Error) { - return a; - } - CARBON_CHECK(a == b) - << "Different return slot usage computed for the same function."; - return a; -} - // Tries to merge new_function into prev_function_id. Since new_function won't // have a definition even if one is upcoming, set is_definition to indicate the // planned result. @@ -99,7 +77,8 @@ static auto MergeFunctionRedecl(Context& context, SemIRLoc new_loc, SemIR::ImportIRId prev_import_ir_id) -> bool { auto& prev_function = context.functions().Get(prev_function_id); - if (!CheckFunctionTypeMatches(context, new_function, prev_function, {})) { + if (!CheckFunctionTypeMatches(context, new_function, prev_function, {}, + /*check_syntax=*/true)) { return false; } @@ -107,9 +86,7 @@ static auto MergeFunctionRedecl(Context& context, SemIRLoc new_loc, {.loc = new_loc, .is_definition = new_is_definition, .is_extern = new_function.is_extern}, - {.loc = prev_function.definition_id.is_valid() - ? prev_function.definition_id - : prev_function.decl_id, + {.loc = prev_function.latest_decl_id(), .is_definition = prev_function.definition_id.is_valid(), .is_extern = prev_function.is_extern}, prev_import_ir_id); @@ -117,14 +94,10 @@ static auto MergeFunctionRedecl(Context& context, SemIRLoc new_loc, if (new_is_definition) { // Track the signature from the definition, so that IDs in the body // match IDs in the signature. - prev_function.definition_id = new_function.definition_id; - prev_function.implicit_param_refs_id = new_function.implicit_param_refs_id; - prev_function.param_refs_id = new_function.param_refs_id; + prev_function.MergeDefinition(new_function); prev_function.return_storage_id = new_function.return_storage_id; } // The new function might have return slot information if it was imported. - prev_function.return_slot = - MergeReturnSlot(prev_function.return_slot, new_function.return_slot); if ((prev_import_ir_id.is_valid() && !new_is_import) || (prev_function.is_extern && !new_function.is_extern)) { prev_function.is_extern = new_function.is_extern; @@ -201,14 +174,10 @@ static auto BuildFunctionDecl(Context& context, auto decl_block_id = context.inst_block_stack().Pop(); auto return_storage_id = SemIR::InstId::Invalid; - auto return_slot = SemIR::Function::ReturnSlot::NotComputed; if (auto [return_node, maybe_return_storage_id] = context.node_stack().PopWithNodeIdIf(); maybe_return_storage_id) { return_storage_id = *maybe_return_storage_id; - } else { - // If there's no return type, there's no return slot. - return_slot = SemIR::Function::ReturnSlot::Absent; } auto name = PopNameComponent(context); @@ -248,15 +217,8 @@ static auto BuildFunctionDecl(Context& context, // Build the function entity. This will be merged into an existing function if // there is one, or otherwise added to the function store. auto function_info = SemIR::Function{ - .name_id = name_context.name_id_for_new_inst(), - .parent_scope_id = name_context.parent_scope_id_for_new_inst(), - .decl_id = decl_id, - .generic_id = SemIR::GenericId::Invalid, - .implicit_param_refs_id = name.implicit_params_id, - .param_refs_id = name.params_id, - .return_storage_id = return_storage_id, - .is_extern = is_extern, - .return_slot = return_slot}; + {name_context.MakeEntityWithParamsBase(decl_id, name)}, + {.return_storage_id = return_storage_id, .is_extern = is_extern}}; if (is_definition) { function_info.definition_id = decl_id; } @@ -272,17 +234,8 @@ static auto BuildFunctionDecl(Context& context, FinishGenericRedecl(context, decl_id, function_info.generic_id); // TODO: Validate that the redeclaration doesn't set an access modifier. } - function_decl.type_id = context.GetFunctionType(function_decl.function_id); - - // TODO: Temporarily replace the return type with the canonical return type. - // This is a placeholder to avoid breaking tests before generic type - // substitution is ready. - if (return_storage_id.is_valid()) { - auto return_storage = context.insts().Get(return_storage_id); - return_storage.SetType(GetTypeInInstance( - context, SemIR::GenericInstanceId::Invalid, return_storage.type_id())); - context.sem_ir().insts().Set(return_storage_id, return_storage); - } + function_decl.type_id = context.GetFunctionType( + function_decl.function_id, context.scope_stack().PeekSpecificId()); // Write the function ID into the FunctionDecl. context.ReplaceInstBeforeConstantUse(decl_id, function_decl); @@ -306,7 +259,7 @@ static auto BuildFunctionDecl(Context& context, } if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) { - auto return_type_id = function_info.declared_return_type(context.sem_ir()); + auto return_type_id = function_info.GetDeclaredReturnType(context.sem_ir()); // TODO: Update this once valid signatures for the entry point are decided. if (function_info.implicit_param_refs_id.is_valid() || !function_info.param_refs_id.is_valid() || @@ -351,7 +304,8 @@ static auto HandleFunctionDefinitionAfterSignature( context.AddCurrentCodeBlockToFunction(); // Check the return type is complete. - CheckFunctionReturnType(context, function.return_storage_id, function); + CheckFunctionReturnType(context, function.return_storage_id, function, + SemIR::SpecificId::Invalid); // Check the parameter types are complete. for (auto param_id : llvm::concat( @@ -491,7 +445,7 @@ static auto IsValidBuiltinDeclaration(Context& context, } // Get the return type. This is `()` if none was specified. - auto return_type_id = function.declared_return_type(context.sem_ir()); + auto return_type_id = function.GetDeclaredReturnType(context.sem_ir()); if (!return_type_id.is_valid()) { return_type_id = context.GetTupleType({}); } diff --git a/toolchain/check/handle_impl.cpp b/toolchain/check/handle_impl.cpp index 1626c0f1e7e74..36a2596b65691 100644 --- a/toolchain/check/handle_impl.cpp +++ b/toolchain/check/handle_impl.cpp @@ -36,6 +36,8 @@ auto HandleParseNode(Context& context, Parse::ImplIntroducerId node_id) auto HandleParseNode(Context& context, Parse::ImplForallId node_id) -> bool { auto params_id = context.node_stack().Pop(); + context.node_stack() + .PopAndDiscardSoloNodeId(); context.node_stack().Push(node_id, params_id); return true; } @@ -139,7 +141,8 @@ static auto ExtendImpl(Context& context, Parse::NodeId extend_node, // The explicit self type is the same as the default self type, so suggest // removing it and recover as if it were not present. if (auto self_as = - context.parse_tree().ExtractAs(self_type_node)) { + context.parse_tree_and_subtrees().ExtractAs( + self_type_node)) { CARBON_DIAGNOSTIC(ExtendImplSelfAsDefault, Note, "Remove the explicit `Self` type here."); diag.Note(self_as->type_expr, ExtendImplSelfAsDefault); diff --git a/toolchain/check/handle_index.cpp b/toolchain/check/handle_index.cpp index b86a884469f86..c236503f5b545 100644 --- a/toolchain/check/handle_index.cpp +++ b/toolchain/check/handle_index.cpp @@ -16,26 +16,6 @@ auto HandleParseNode(Context& /*context*/, Parse::IndexExprStartId /*node_id*/) return true; } -// Validates that the index (required to be an IntLiteral) is valid within the -// tuple size. Returns the index on success, or nullptr on failure. -static auto ValidateTupleIndex(Context& context, Parse::NodeId node_id, - SemIR::Inst operand_inst, - SemIR::IntLiteral index_inst, int size) - -> const llvm::APInt* { - const auto& index_val = context.ints().Get(index_inst.int_id); - if (index_val.uge(size)) { - CARBON_DIAGNOSTIC( - TupleIndexOutOfBounds, Error, - "Tuple element index `{0}` is past the end of type `{1}`.", TypedInt, - SemIR::TypeId); - context.emitter().Emit(node_id, TupleIndexOutOfBounds, - {.type = index_inst.type_id, .value = index_val}, - operand_inst.type_id()); - return nullptr; - } - return &index_val; -} - auto HandleParseNode(Context& context, Parse::IndexExprId node_id) -> bool { auto index_inst_id = context.node_stack().PopExpr(); auto operand_inst_id = context.node_stack().PopExpr(); @@ -72,39 +52,6 @@ auto HandleParseNode(Context& context, Parse::IndexExprId node_id) -> bool { context.node_stack().Push(node_id, elem_id); return true; } - case CARBON_KIND(SemIR::TupleType tuple_type): { - SemIR::TypeId element_type_id = SemIR::TypeId::Error; - auto index_node_id = context.insts().GetLocId(index_inst_id); - index_inst_id = ConvertToValueOfType( - context, index_node_id, index_inst_id, - context.GetBuiltinType(SemIR::BuiltinInstKind::IntType)); - auto index_const_id = context.constant_values().Get(index_inst_id); - if (index_const_id == SemIR::ConstantId::Error) { - index_inst_id = SemIR::InstId::BuiltinError; - } else if (!index_const_id.is_template()) { - // TODO: Decide what to do if the index is a symbolic constant. - CARBON_DIAGNOSTIC(TupleIndexNotConstant, Error, - "Tuple index must be a constant."); - context.emitter().Emit(node_id, TupleIndexNotConstant); - index_inst_id = SemIR::InstId::BuiltinError; - } else { - auto index_literal = context.insts().GetAs( - context.constant_values().GetInstId(index_const_id)); - auto type_block = context.type_blocks().Get(tuple_type.elements_id); - if (const auto* index_val = - ValidateTupleIndex(context, node_id, operand_inst, - index_literal, type_block.size())) { - element_type_id = type_block[index_val->getZExtValue()]; - } else { - index_inst_id = SemIR::InstId::BuiltinError; - } - } - context.AddInstAndPush(node_id, - {.type_id = element_type_id, - .tuple_id = operand_inst_id, - .index_id = index_inst_id}); - return true; - } default: { if (operand_type_id != SemIR::TypeId::Error) { CARBON_DIAGNOSTIC(TypeNotIndexable, Error, diff --git a/toolchain/check/handle_interface.cpp b/toolchain/check/handle_interface.cpp index 63c021c6ad6cc..fac3f83586fa5 100644 --- a/toolchain/check/handle_interface.cpp +++ b/toolchain/check/handle_interface.cpp @@ -62,7 +62,8 @@ static auto BuildInterfaceDecl(Context& context, // now we just check the generic parameters match. if (CheckRedeclParamsMatch( context, - DeclParams(interface_decl_id, name.implicit_params_id, + DeclParams(interface_decl_id, name.first_param_node_id, + name.last_param_node_id, name.implicit_params_id, name.params_id), DeclParams(context.interfaces().Get( existing_interface_decl->interface_id)))) { @@ -87,12 +88,14 @@ static auto BuildInterfaceDecl(Context& context, // interface name here. We should keep track of it even if the name is // invalid. SemIR::Interface interface_info = { - .name_id = name_context.name_id_for_new_inst(), - .parent_scope_id = name_context.parent_scope_id_for_new_inst(), - .generic_id = generic_id, - .implicit_param_refs_id = name.implicit_params_id, - .param_refs_id = name.params_id, - .decl_id = interface_decl_id}; + {.name_id = name_context.name_id_for_new_inst(), + .parent_scope_id = name_context.parent_scope_id_for_new_inst(), + .generic_id = generic_id, + .first_param_node_id = name.first_param_node_id, + .last_param_node_id = name.last_param_node_id, + .implicit_param_refs_id = name.implicit_params_id, + .param_refs_id = name.params_id, + .decl_id = interface_decl_id}}; interface_decl.interface_id = context.interfaces().Add(interface_info); if (interface_info.is_generic()) { interface_decl.type_id = @@ -141,7 +144,7 @@ auto HandleParseNode(Context& context, // Enter the interface scope. context.scope_stack().Push( interface_decl_id, interface_info.scope_id, - context.generics().GetSelfInstance(interface_info.generic_id)); + context.generics().GetSelfSpecific(interface_info.generic_id)); StartGenericDefinition(context); context.inst_block_stack().Push(); @@ -154,13 +157,13 @@ auto HandleParseNode(Context& context, if (!interface_info.is_defined()) { SemIR::TypeId self_type_id = SemIR::TypeId::Invalid; if (interface_info.is_generic()) { - auto instance_id = - context.generics().GetSelfInstance(interface_info.generic_id); + auto specific_id = + context.generics().GetSelfSpecific(interface_info.generic_id); self_type_id = context.GetTypeIdForTypeConstant( TryEvalInst(context, SemIR::InstId::Invalid, SemIR::InterfaceType{.type_id = SemIR::TypeId::TypeType, .interface_id = interface_id, - .instance_id = instance_id})); + .specific_id = specific_id})); } else { self_type_id = context.GetTypeIdForTypeInst(interface_decl_id); } @@ -168,13 +171,13 @@ auto HandleParseNode(Context& context, // We model `Self` as a symbolic binding whose type is the interface. // Because there is no equivalent non-symbolic value, we use `Invalid` as // the `value_id` on the `BindSymbolicName`. - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = SemIR::NameId::SelfType, .parent_scope_id = interface_info.scope_id, .bind_index = context.scope_stack().AddCompileTimeBinding()}); interface_info.self_param_id = context.AddInst( SemIR::LocId::Invalid, {.type_id = self_type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = SemIR::InstId::Invalid}); context.scope_stack().PushCompileTimeBinding(interface_info.self_param_id); context.name_scopes().AddRequiredName(interface_info.scope_id, diff --git a/toolchain/check/handle_let_and_var.cpp b/toolchain/check/handle_let_and_var.cpp index b7aae94ca2d1c..3d9c8f0249593 100644 --- a/toolchain/check/handle_let_and_var.cpp +++ b/toolchain/check/handle_let_and_var.cpp @@ -81,7 +81,7 @@ static auto BuildAssociatedConstantDecl(Context& context, // Replace the tentative BindName instruction with the associated constant // declaration. auto name_id = - context.bind_names().Get(binding_pattern->bind_name_id).name_id; + context.entity_names().Get(binding_pattern->entity_name_id).name_id; context.ReplaceLocIdAndInstBeforeConstantUse( pattern_id, SemIR::LocIdAndInst(node_id, SemIR::AssociatedConstantDecl{ @@ -107,7 +107,7 @@ static auto HandleNameBinding(Context& context, SemIR::InstId pattern_id, // the variable. auto name_context = context.decl_name_stack().MakeUnqualifiedName( context.insts().GetLocId(pattern_id), - context.bind_names().Get(bind_name->bind_name_id).name_id); + context.entity_names().Get(bind_name->entity_name_id).name_id); context.decl_name_stack().AddNameOrDiagnoseDuplicate( name_context, pattern_id, access_kind); return bind_name->value_id; diff --git a/toolchain/check/handle_modifier.cpp b/toolchain/check/handle_modifier.cpp index 75fa2c60b4122..3cf89bb312f16 100644 --- a/toolchain/check/handle_modifier.cpp +++ b/toolchain/check/handle_modifier.cpp @@ -94,4 +94,14 @@ static auto HandleModifier(Context& context, Parse::NodeId node_id, } #include "toolchain/parse/node_kind.def" +auto HandleParseNode(Context& context, + Parse::ExternModifierWithLibraryId node_id) -> bool { + return context.TODO(node_id, "extern library syntax"); +} + +auto HandleParseNode(Context& context, Parse::ExternModifierId node_id) + -> bool { + return HandleModifier(context, node_id, KeywordModifierSet::Extern); +} + } // namespace Carbon::Check diff --git a/toolchain/check/handle_name.cpp b/toolchain/check/handle_name.cpp index 1b06f6c55910e..3eeec9617a9b7 100644 --- a/toolchain/check/handle_name.cpp +++ b/toolchain/check/handle_name.cpp @@ -3,12 +3,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" -#include "toolchain/check/generic.h" #include "toolchain/check/handle.h" #include "toolchain/check/member_access.h" #include "toolchain/check/name_component.h" #include "toolchain/check/pointer_dereference.h" #include "toolchain/lex/token_kind.h" +#include "toolchain/parse/node_kind.h" #include "toolchain/sem_ir/inst.h" #include "toolchain/sem_ir/typed_insts.h" @@ -16,12 +16,22 @@ namespace Carbon::Check { auto HandleParseNode(Context& context, Parse::MemberAccessExprId node_id) -> bool { - if (context.node_stack().PeekIs()) { + auto node_kind = context.node_stack().PeekNodeKind(); + + if (node_kind == Parse::NodeKind::ParenExpr) { auto member_expr_id = context.node_stack().PopExpr(); auto base_id = context.node_stack().PopExpr(); auto member_id = PerformCompoundMemberAccess(context, node_id, base_id, member_expr_id); context.node_stack().Push(node_id, member_id); + } else if (node_kind == Parse::NodeKind::IntLiteral) { + auto index_inst_id = context.node_stack().PopExpr(); + auto tuple_inst_id = context.node_stack().PopExpr(); + + auto tuple_value_inst_id = + PerformTupleIndex(context, node_id, tuple_inst_id, index_inst_id); + + context.node_stack().Push(node_id, tuple_value_inst_id); } else { SemIR::NameId name_id = context.node_stack().PopName(); auto base_id = context.node_stack().PopExpr(); @@ -44,7 +54,9 @@ auto HandleParseNode(Context& context, Parse::PointerMemberAccessExprId node_id) builder.Emit(); }; - if (context.node_stack().PeekIs()) { + auto node_kind = context.node_stack().PeekNodeKind(); + + if (node_kind == Parse::NodeKind::ParenExpr) { auto member_expr_id = context.node_stack().PopExpr(); auto base_id = context.node_stack().PopExpr(); auto deref_base_id = PerformPointerDereference(context, node_id, base_id, @@ -52,6 +64,15 @@ auto HandleParseNode(Context& context, Parse::PointerMemberAccessExprId node_id) auto member_id = PerformCompoundMemberAccess(context, node_id, deref_base_id, member_expr_id); context.node_stack().Push(node_id, member_id); + } else if (node_kind == Parse::NodeKind::IntLiteral) { + auto index_inst_id = context.node_stack().PopExpr(); + auto tuple_pointer_inst_id = context.node_stack().PopExpr(); + auto tuple_inst_id = PerformPointerDereference( + context, node_id, tuple_pointer_inst_id, diagnose_not_pointer); + auto tuple_value_inst_id = + PerformTupleIndex(context, node_id, tuple_inst_id, index_inst_id); + + context.node_stack().Push(node_id, tuple_value_inst_id); } else { SemIR::NameId name_id = context.node_stack().PopName(); auto base_id = context.node_stack().PopExpr(); @@ -81,18 +102,18 @@ static auto HandleNameAsExpr(Context& context, Parse::NodeId node_id, SemIR::NameId name_id) -> bool { auto result = context.LookupUnqualifiedName(node_id, name_id); auto value = context.insts().Get(result.inst_id); - auto type_id = - GetTypeInInstance(context, result.instance_id, value.type_id()); + auto type_id = SemIR::GetTypeInSpecific(context.sem_ir(), result.specific_id, + value.type_id()); CARBON_CHECK(type_id.is_valid()) << "Missing type for " << value; - // If the named entity has a constant value that depends on its generic - // instance, store the instance too. - if (result.instance_id.is_valid() && + // If the named entity has a constant value that depends on its specific, + // store the specific too. + if (result.specific_id.is_valid() && context.constant_values().Get(result.inst_id).is_symbolic()) { result.inst_id = context.AddInst( node_id, {.type_id = type_id, .inst_id = result.inst_id, - .instance_id = result.instance_id}); + .specific_id = result.specific_id}); } context.AddInstAndPush( diff --git a/toolchain/check/handle_namespace.cpp b/toolchain/check/handle_namespace.cpp index 70df7a15d2ec1..495112ff631ec 100644 --- a/toolchain/check/handle_namespace.cpp +++ b/toolchain/check/handle_namespace.cpp @@ -34,10 +34,6 @@ auto HandleParseNode(Context& context, Parse::NamespaceId node_id) -> bool { SemIR::NameScopeId::Invalid, SemIR::InstId::Invalid}; auto namespace_id = context.AddPlaceholderInst(SemIR::LocIdAndInst(node_id, namespace_inst)); - namespace_inst.name_scope_id = context.name_scopes().Add( - namespace_id, name_context.name_id_for_new_inst(), - name_context.parent_scope_id_for_new_inst()); - context.ReplaceInstBeforeConstantUse(namespace_id, namespace_inst); auto existing_inst_id = context.decl_name_stack().LookupOrAddName( name_context, namespace_id, SemIR::AccessKind::Public); @@ -46,6 +42,9 @@ auto HandleParseNode(Context& context, Parse::NamespaceId node_id) -> bool { // previous declaration. Otherwise, diagnose the issue. if (auto existing = context.insts().TryGetAs(existing_inst_id)) { + // Point at the other namespace. + namespace_inst.name_scope_id = existing->name_scope_id; + if (context.name_scopes().Get(existing->name_scope_id).is_closed_import) { // The existing name is a package name, so this is a name conflict. context.DiagnoseDuplicateName(namespace_id, existing_inst_id); @@ -65,6 +64,17 @@ auto HandleParseNode(Context& context, Parse::NamespaceId node_id) -> bool { } } + // If we weren't able to merge namespaces, add a new name scope. Note this + // occurs even for duplicates where we discard the namespace, because we want + // to produce a valid constant. + if (!namespace_inst.name_scope_id.is_valid()) { + namespace_inst.name_scope_id = context.name_scopes().Add( + namespace_id, name_context.name_id_for_new_inst(), + name_context.parent_scope_id_for_new_inst()); + } + + context.ReplaceInstBeforeConstantUse(namespace_id, namespace_inst); + context.decl_name_stack().PopScope(); return true; } diff --git a/toolchain/check/handle_pattern_list.cpp b/toolchain/check/handle_pattern_list.cpp index 6ee4b79c4162e..44dbb4a36840d 100644 --- a/toolchain/check/handle_pattern_list.cpp +++ b/toolchain/check/handle_pattern_list.cpp @@ -16,10 +16,10 @@ auto HandleParseNode(Context& context, Parse::ImplicitParamListStartId node_id) auto HandleParseNode(Context& context, Parse::ImplicitParamListId node_id) -> bool { + // Note the Start node remains on the stack, where the param list handler can + // make use of it. auto refs_id = context.param_and_arg_refs_stack().EndAndPop( Parse::NodeKind::ImplicitParamListStart); - context.node_stack() - .PopAndDiscardSoloNodeId(); context.node_stack().Push(node_id, refs_id); // The implicit parameter list's scope extends to the end of the following // parameter list. @@ -40,10 +40,10 @@ auto HandleParseNode(Context& context, Parse::PatternListCommaId /*node_id*/) } auto HandleParseNode(Context& context, Parse::TuplePatternId node_id) -> bool { + // Note the Start node remains on the stack, where the param list handler can + // make use of it. auto refs_id = context.param_and_arg_refs_stack().EndAndPop( Parse::NodeKind::TuplePatternStart); - context.node_stack() - .PopAndDiscardSoloNodeId(); context.node_stack().Push(node_id, refs_id); return true; } diff --git a/toolchain/check/impl.cpp b/toolchain/check/impl.cpp index dc9fcc67d87e8..18fd57028d738 100644 --- a/toolchain/check/impl.cpp +++ b/toolchain/check/impl.cpp @@ -54,7 +54,8 @@ static auto CheckAssociatedFunctionImplementation( // synthesize a suitable thunk. if (!CheckFunctionTypeMatches( context, context.functions().Get(impl_function_decl->function_id), - context.functions().Get(interface_function_id), substitutions)) { + context.functions().Get(interface_function_id), substitutions, + /*check_syntax=*/false)) { return SemIR::InstId::BuiltinError; } return impl_decl_id; @@ -87,7 +88,8 @@ static auto BuildInterfaceWitness( auto self_bind = context.insts().GetAs(interface.self_param_id); Substitution substitutions[1] = { - {.bind_id = context.bind_names().Get(self_bind.bind_name_id).bind_index, + {.bind_id = + context.entity_names().Get(self_bind.entity_name_id).bind_index, .replacement_id = context.types().GetConstantId(impl.self_id)}}; for (auto decl_id : assoc_entities) { diff --git a/toolchain/check/import.cpp b/toolchain/check/import.cpp index ae72ecd1929d4..51b13c97ae3c9 100644 --- a/toolchain/check/import.cpp +++ b/toolchain/check/import.cpp @@ -20,6 +20,13 @@ namespace Carbon::Check { +// Returns name information for an EntityWithParamsBase. +template +static auto GetImportNameForEntity(const T& entity) + -> std::pair { + return {entity.name_id, entity.parent_scope_id}; +} + // Returns name information for the entity, corresponding to IDs in the import // IR rather than the current IR. static auto GetImportName(const SemIR::File& import_sem_ir, @@ -31,31 +38,28 @@ static auto GetImportName(const SemIR::File& import_sem_ir, case SemIR::BindSymbolicName::Kind: case SemIR::ExportDecl::Kind: { auto bind_inst = import_inst.As(); - const auto& bind_name = - import_sem_ir.bind_names().Get(bind_inst.bind_name_id); - return {bind_name.name_id, bind_name.parent_scope_id}; + return GetImportNameForEntity( + import_sem_ir.entity_names().Get(bind_inst.entity_name_id)); } case CARBON_KIND(SemIR::ClassDecl class_decl): { - const auto& class_info = import_sem_ir.classes().Get(class_decl.class_id); - return {class_info.name_id, class_info.parent_scope_id}; + return GetImportNameForEntity( + import_sem_ir.classes().Get(class_decl.class_id)); } case CARBON_KIND(SemIR::FunctionDecl function_decl): { - const auto& function = - import_sem_ir.functions().Get(function_decl.function_id); - return {function.name_id, function.parent_scope_id}; + return GetImportNameForEntity( + import_sem_ir.functions().Get(function_decl.function_id)); } case CARBON_KIND(SemIR::InterfaceDecl interface_decl): { - const auto& interface = - import_sem_ir.interfaces().Get(interface_decl.interface_id); - return {interface.name_id, interface.parent_scope_id}; + return GetImportNameForEntity( + import_sem_ir.interfaces().Get(interface_decl.interface_id)); } case CARBON_KIND(SemIR::Namespace ns): { - const auto& scope = import_sem_ir.name_scopes().Get(ns.name_scope_id); - return {scope.name_id, scope.parent_scope_id}; + return GetImportNameForEntity( + import_sem_ir.name_scopes().Get(ns.name_scope_id)); } default: @@ -84,7 +88,7 @@ static auto AddNamespace( Context& context, SemIR::TypeId namespace_type_id, SemIR::NameId name_id, SemIR::NameScopeId parent_scope_id, bool diagnose_duplicate_namespace, std::optional> make_import_id) - -> std::tuple { + -> std::tuple { auto* parent_scope = &context.name_scopes().Get(parent_scope_id); auto insert_result = parent_scope->name_map.Insert(name_id, parent_scope->names.size()); @@ -97,8 +101,7 @@ static auto AddNamespace( CARBON_CHECK(import_id.is_valid()); context.DiagnoseDuplicateName(import_id, prev_inst_id); } - return {namespace_inst->name_scope_id, - context.constant_values().Get(prev_inst_id), true}; + return {namespace_inst->name_scope_id, prev_inst_id, true}; } } @@ -107,8 +110,9 @@ static auto AddNamespace( auto namespace_inst = SemIR::Namespace{ namespace_type_id, SemIR::NameScopeId::Invalid, import_id}; auto namespace_id = - context.AddPlaceholderInst(SemIR::LocIdAndInst::ReusingLoc( + context.AddPlaceholderInstInNoBlock(SemIR::LocIdAndInst::ReusingLoc( context.insts().GetLocId(import_id), namespace_inst)); + context.import_ref_ids().push_back(namespace_id); namespace_inst.name_scope_id = context.name_scopes().Add(namespace_id, name_id, parent_scope_id); context.ReplaceInstBeforeConstantUse(namespace_id, namespace_inst); @@ -130,8 +134,7 @@ static auto AddNamespace( .access_kind = SemIR::AccessKind::Public}); } - return {namespace_inst.name_scope_id, - context.constant_values().Get(namespace_id), false}; + return {namespace_inst.name_scope_id, namespace_id, false}; } // Adds a copied namespace to the cache. @@ -153,24 +156,27 @@ static auto CopySingleNameScopeFromImportIR( Map* copied_namespaces, SemIR::ImportIRId ir_id, SemIR::InstId import_inst_id, SemIR::NameScopeId import_scope_id, SemIR::NameScopeId parent_scope_id, - SemIR::NameId name_id) -> SemIR::NameScopeId { + SemIR::NameId name_id) -> std::pair { // Produce the namespace for the entry. auto make_import_id = [&]() { - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = parent_scope_id, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); auto import_ir_inst_id = context.import_ir_insts().Add( {.ir_id = ir_id, .inst_id = import_inst_id}); - return context.AddInst( + auto inst_id = context.AddInstInNoBlock( import_ir_inst_id, {.type_id = namespace_type_id, .import_ir_inst_id = import_ir_inst_id, - .bind_name_id = bind_name_id}); + .entity_name_id = entity_name_id}); + context.import_ref_ids().push_back(inst_id); + return inst_id; }; - auto [namespace_scope_id, namespace_const_id, _] = + auto [namespace_scope_id, namespace_inst_id, _] = AddNamespace(context, namespace_type_id, name_id, parent_scope_id, /*diagnose_duplicate_namespace=*/false, make_import_id); + auto namespace_const_id = context.constant_values().Get(namespace_inst_id); context.import_ir_constant_values()[ir_id.index].Set(import_inst_id, namespace_const_id); @@ -178,7 +184,7 @@ static auto CopySingleNameScopeFromImportIR( CacheCopiedNamespace(*copied_namespaces, import_scope_id, namespace_scope_id); } - return namespace_scope_id; + return {namespace_scope_id, namespace_inst_id}; } // Copies ancestor name scopes from the import IR. Handles the parent traversal. @@ -222,9 +228,11 @@ static auto CopyAncestorNameScopesFromImportIR( auto import_scope = import_sem_ir.name_scopes().Get(import_scope_id); auto name_id = CopyNameFromImportIR(context, import_sem_ir, import_scope.name_id); - scope_cursor = CopySingleNameScopeFromImportIR( - context, namespace_type_id, &copied_namespaces, ir_id, - import_scope.inst_id, import_scope_id, scope_cursor, name_id); + scope_cursor = + CopySingleNameScopeFromImportIR( + context, namespace_type_id, &copied_namespaces, ir_id, + import_scope.inst_id, import_scope_id, scope_cursor, name_id) + .first; } return scope_cursor; @@ -239,7 +247,7 @@ static auto AddImportRefOrMerge(Context& context, SemIR::ImportIRId ir_id, // Leave a placeholder that the inst comes from the other IR. auto& parent_scope = context.name_scopes().Get(parent_scope_id); auto insert = parent_scope.name_map.Insert(name_id, [&] { - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = parent_scope_id, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); @@ -248,7 +256,7 @@ static auto AddImportRefOrMerge(Context& context, SemIR::ImportIRId ir_id, {.name_id = name_id, .inst_id = AddImportRef(context, {.ir_id = ir_id, .inst_id = import_inst_id}, - bind_name_id), + entity_name_id), .access_kind = SemIR::AccessKind::Public}); return index; }); @@ -278,6 +286,25 @@ struct TodoScope { }; } // namespace +// Adds an ImportRef to a name scope. +static auto AddScopedImportRef(Context& context, + SemIR::NameScopeId parent_scope_id, + SemIR::NameScope& parent_scope, + SemIR::NameId name_id, + SemIR::ImportIRInst import_inst, + SemIR::AccessKind access_kind) -> SemIR::InstId { + // Add an ImportRef for other instructions. + auto impl_entity_name_id = context.entity_names().Add( + {.name_id = name_id, + .parent_scope_id = parent_scope_id, + .bind_index = SemIR::CompileTimeBindIndex::Invalid}); + auto import_ref_id = AddImportRef(context, import_inst, impl_entity_name_id); + parent_scope.AddRequired({.name_id = name_id, + .inst_id = import_ref_id, + .access_kind = access_kind}); + return import_ref_id; +} + // Imports entries in a specific scope into the current file. static auto ImportScopeFromApiFile(Context& context, const SemIR::File& api_sem_ir, @@ -310,17 +337,10 @@ static auto ImportScopeFromApiFile(Context& context, .impl_parent_scope_id = impl_scope_id}); } else { // Add an ImportRef for other instructions. - auto impl_bind_name_id = context.bind_names().Add( - {.name_id = impl_name_id, - .parent_scope_id = impl_scope_id, - .bind_index = SemIR::CompileTimeBindIndex::Invalid}); - auto import_ref_id = AddImportRef(context, - {.ir_id = SemIR::ImportIRId::ApiForImpl, - .inst_id = api_entry.inst_id}, - impl_bind_name_id); - impl_scope.AddRequired({.name_id = impl_name_id, - .inst_id = import_ref_id, - .access_kind = api_entry.access_kind}); + AddScopedImportRef(context, impl_scope_id, impl_scope, impl_name_id, + {.ir_id = SemIR::ImportIRId::ApiForImpl, + .inst_id = api_entry.inst_id}, + api_entry.access_kind); } } } @@ -336,11 +356,13 @@ auto ImportApiFile(Context& context, SemIR::TypeId namespace_type_id, SemIR::NameScopeId::Package, todo_scopes); while (!todo_scopes.empty()) { auto todo_scope = todo_scopes.pop_back_val(); - auto impl_scope_id = CopySingleNameScopeFromImportIR( - context, namespace_type_id, /*copied_namespaces=*/nullptr, - SemIR::ImportIRId::ApiForImpl, todo_scope.api_inst_id, - todo_scope.api_scope_id, todo_scope.impl_parent_scope_id, - todo_scope.impl_name_id); + auto impl_scope_id = + CopySingleNameScopeFromImportIR( + context, namespace_type_id, /*copied_namespaces=*/nullptr, + SemIR::ImportIRId::ApiForImpl, todo_scope.api_inst_id, + todo_scope.api_scope_id, todo_scope.impl_parent_scope_id, + todo_scope.impl_name_id) + .first; ImportScopeFromApiFile(context, api_sem_ir, todo_scope.api_scope_id, impl_scope_id, todo_scopes); } @@ -404,9 +426,10 @@ auto ImportLibrariesFromOtherPackage(Context& context, auto name_id = SemIR::NameId::ForIdentifier(package_id); - auto [namespace_scope_id, namespace_const_id, is_duplicate] = AddNamespace( + auto [namespace_scope_id, namespace_inst_id, is_duplicate] = AddNamespace( context, namespace_type_id, name_id, SemIR::NameScopeId::Package, /*diagnose_duplicate_namespace=*/true, [&] { return import_decl_id; }); + auto namespace_const_id = context.constant_values().Get(namespace_inst_id); auto& scope = context.name_scopes().Get(namespace_scope_id); scope.is_closed_import = !is_duplicate; @@ -421,4 +444,146 @@ auto ImportLibrariesFromOtherPackage(Context& context, } } +// Looks up a name in a scope imported from another package. An `identifier` is +// provided if `name_id` corresponds to an identifier in the current file; +// otherwise, `name_id` is file-agnostic and can be used directly. +static auto LookupNameInImport(const SemIR::File& import_ir, + SemIR::NameScopeId import_scope_id, + SemIR::NameId name_id, + llvm::StringRef identifier) + -> const Carbon::SemIR::NameScope::Entry* { + // Determine the NameId in the import IR. + SemIR::NameId import_name_id = name_id; + if (!identifier.empty()) { + auto import_identifier_id = import_ir.identifiers().Lookup(identifier); + if (!import_identifier_id.is_valid()) { + // Name doesn't exist in the import IR. + return nullptr; + } + import_name_id = SemIR::NameId::ForIdentifier(import_identifier_id); + } + + // Look up the name in the import scope. + const auto& import_scope = import_ir.name_scopes().Get(import_scope_id); + auto lookup = import_scope.name_map.Lookup(import_name_id); + if (!lookup) { + // Name doesn't exist in the import scope. + return nullptr; + } + + const auto& import_scope_entry = import_scope.names[lookup.value()]; + if (import_scope_entry.access_kind != SemIR::AccessKind::Public) { + // Ignore cross-package non-public names. + return nullptr; + } + + return &import_scope_entry; +} + +// Adds a namespace that points to one in another package. +static auto AddNamespaceFromOtherPackage(Context& context, + SemIR::ImportIRId import_ir_id, + SemIR::InstId import_inst_id, + SemIR::Namespace import_ns, + SemIR::NameScopeId parent_scope_id, + SemIR::NameId name_id) + -> SemIR::InstId { + auto namespace_type_id = + context.GetBuiltinType(SemIR::BuiltinInstKind::NamespaceType); + auto [new_scope_id, namespace_inst_id] = CopySingleNameScopeFromImportIR( + context, namespace_type_id, /*copied_namespaces=*/nullptr, import_ir_id, + import_inst_id, import_ns.name_scope_id, parent_scope_id, name_id); + context.name_scopes() + .Get(new_scope_id) + .import_ir_scopes.push_back({import_ir_id, import_ns.name_scope_id}); + return namespace_inst_id; +} + +auto ImportNameFromOtherPackage( + Context& context, SemIRLoc loc, SemIR::NameScopeId scope_id, + llvm::ArrayRef> + import_ir_scopes, + SemIR::NameId name_id) -> SemIR::InstId { + // If the name is an identifier, get the string first so that it can be shared + // when there are multiple IRs. + llvm::StringRef identifier; + if (auto identifier_id = name_id.AsIdentifierId(); identifier_id.is_valid()) { + identifier = context.identifiers().Get(identifier_id); + CARBON_CHECK(!identifier.empty()); + } + + // Annotate diagnostics as occurring during this name lookup. + DiagnosticAnnotationScope annotate_diagnostics( + &context.emitter(), [&](auto& builder) { + CARBON_DIAGNOSTIC(InNameLookup, Note, "In name lookup for `{0}`.", + SemIR::NameId); + builder.Note(loc, InNameLookup, name_id); + }); + + // Although we track the result here and look in each IR, we pretty much use + // the first result. + auto result_id = SemIR::InstId::Invalid; + // The canonical IR and inst_id for where `result_id` came from, which may be + // indirectly imported. This is only resolved on a conflict, when it can be + // used to determine the conflict is actually the same instruction. + std::optional canonical_result_inst; + + for (auto [import_ir_id, import_scope_id] : import_ir_scopes) { + auto& import_ir = context.import_irs().Get(import_ir_id); + + const auto* import_scope_entry = LookupNameInImport( + *import_ir.sem_ir, import_scope_id, name_id, identifier); + if (!import_scope_entry) { + continue; + } + auto import_inst = + import_ir.sem_ir->insts().Get(import_scope_entry->inst_id); + if (import_inst.Is()) { + // This entity was added to name lookup by using an import, and is not + // exported. + continue; + } + + // Add the first result found. + if (!result_id.is_valid()) { + // If the imported instruction is a namespace, we add it directly instead + // of as an ImportRef. + if (auto import_ns = import_inst.TryAs()) { + result_id = AddNamespaceFromOtherPackage(context, import_ir_id, + import_scope_entry->inst_id, + *import_ns, scope_id, name_id); + } else { + result_id = AddScopedImportRef( + context, scope_id, context.name_scopes().Get(scope_id), name_id, + {.ir_id = import_ir_id, .inst_id = import_scope_entry->inst_id}, + SemIR::AccessKind::Public); + LoadImportRef(context, result_id); + } + continue; + } + + // When namespaces collide between files, merge lookup in the scopes. + if (auto import_ns = import_inst.TryAs()) { + if (auto ns = context.insts().TryGetAs(result_id)) { + auto& name_scope = context.name_scopes().Get(ns->name_scope_id); + name_scope.import_ir_scopes.push_back( + {import_ir_id, import_ns->name_scope_id}); + continue; + } + } + + // When there's a name collision, they need to either be the same canonical + // instruction, or we'll diagnose. + if (!canonical_result_inst) { + canonical_result_inst = + GetCanonicalImportIRInst(context, &context.sem_ir(), result_id); + } + VerifySameCanonicalImportIRInst(context, result_id, *canonical_result_inst, + import_ir_id, import_ir.sem_ir, + import_scope_entry->inst_id); + } + + return result_id; +} + } // namespace Carbon::Check diff --git a/toolchain/check/import.h b/toolchain/check/import.h index 2c07c0a18fea2..e126deab8f831 100644 --- a/toolchain/check/import.h +++ b/toolchain/check/import.h @@ -38,6 +38,23 @@ auto ImportLibrariesFromOtherPackage(Context& context, llvm::ArrayRef import_irs, bool has_load_error) -> void; +// Given a name scope that corresponds to another package (having one or more +// import_irs), looks for the name in imports. Name resolution results are added +// to the scope, and the InstId (possibly invalid) is returned. +// +// In general, this will add an ImportRef and load it; it's never left unloaded +// because the result is expected to be immediately used. Namespaces will be +// directly produced, similar to how they function for imports from the current +// package. Conflicts will be resolved and diagnosed. +// +// Arguments are all in the context of the current IR. Scope lookup is expected +// to be resolved first. +auto ImportNameFromOtherPackage( + Context& context, SemIRLoc loc, SemIR::NameScopeId scope_id, + llvm::ArrayRef> + import_ir_scopes, + SemIR::NameId name_id) -> SemIR::InstId; + } // namespace Carbon::Check #endif // CARBON_TOOLCHAIN_CHECK_IMPORT_H_ diff --git a/toolchain/check/import_ref.cpp b/toolchain/check/import_ref.cpp index bb89e823312b8..de182c1baf5a1 100644 --- a/toolchain/check/import_ref.cpp +++ b/toolchain/check/import_ref.cpp @@ -8,6 +8,7 @@ #include "toolchain/base/kind_switch.h" #include "toolchain/check/context.h" #include "toolchain/check/eval.h" +#include "toolchain/check/generic.h" #include "toolchain/parse/node_ids.h" #include "toolchain/sem_ir/constant.h" #include "toolchain/sem_ir/file.h" @@ -54,10 +55,10 @@ auto AddImportIR(Context& context, SemIR::ImportIR import_ir) } auto AddImportRef(Context& context, SemIR::ImportIRInst import_ir_inst, - SemIR::BindNameId bind_name_id) -> SemIR::InstId { + SemIR::EntityNameId entity_name_id) -> SemIR::InstId { auto import_ir_inst_id = context.import_ir_insts().Add(import_ir_inst); SemIR::ImportRefUnloaded inst = {.import_ir_inst_id = import_ir_inst_id, - .bind_name_id = bind_name_id}; + .entity_name_id = entity_name_id}; auto import_ref_id = context.AddPlaceholderInstInNoBlock( SemIR::LocIdAndInst(import_ir_inst_id, inst)); @@ -114,7 +115,7 @@ auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id, } auto conflict_id = AddImportRef(context, {.ir_id = new_ir_id, .inst_id = new_inst_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); context.DiagnoseDuplicateName(conflict_id, prev_id); } @@ -130,30 +131,38 @@ auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id, // - If `retry` is set, we process it again, because it didn't complete last // time, even though we have a constant value already. // 2. Resolve the instruction: (TryResolveInst/TryResolveTypedInst) +// - For a symbolic constant within a generic, find the generic itself. If it +// needs to be imported, return Retry() to import the generic before we +// import the constant. // - For instructions that can be forward declared, if we don't already have // a constant value from a previous attempt at resolution, start by making // a forward declared constant value to address circular references. // - Gather all input constants. // - Gathering constants directly adds unresolved values to work_stack_. // - If any need to be resolved (HasNewWork), return Retry(): this -// instruction needs two calls to complete. +// instruction needs another call to complete. // - If the constant value is already known because we have made a forward // declaration, pass it to Retry(). It will be passed to future attempts // to resolve this instruction so the earlier work can be found, and will // be made available for other instructions to use. -// - The second attempt to resolve this instruction must produce the same -// constant, because the value may have already been used by resolved -// instructions. +// - The subsequent attempt to resolve this instruction must produce the +// same constant, because the value may have already been used by +// resolved instructions. // - Build any necessary IR structures, and return the output constant. // 3. If resolve didn't return Retry(), pop the work. Otherwise, it needs to // remain, and may no longer be at the top of the stack; set `retry` on it so // we'll make sure to run it again later. // -// TryResolveInst/TryResolveTypedInst can complete in one call for a given -// instruction, but should always complete within two calls. However, due to the -// chance of a second call, it's important to reserve all expensive logic until -// it's been established that input constants are available; this in particular -// includes GetTypeIdForTypeConstant calls which do a hash table lookup. +// TryResolveInst can complete in one call for a given instruction, but should +// always complete within three calls: +// +// - TryResolveInst can retry once if the generic is not yet loaded. +// - TryResolveTypedInst can retry once if its inputs are not yet loaded. +// - The third call should succeed. +// +// Due to the chance of a second call to TryResolveTypedInst, it's important to +// reserve all expensive logic until it's been established that input constants +// are available. // // TODO: Fix class `extern` handling and merging, rewrite tests. // - check/testdata/class/cross_package_import.carbon @@ -209,20 +218,52 @@ class ImportRefResolver { return constant_id; } + // Wraps constant evaluation with logic to handle constants. + auto ResolveConstant(SemIR::ConstantId import_const_id) -> SemIR::ConstantId { + if (!import_const_id.is_valid()) { + return import_const_id; + } + + // For template constants, the corresponding instruction has the desired + // constant value. + if (!import_const_id.is_symbolic()) { + return Resolve(import_ir_.constant_values().GetInstId(import_const_id)); + } + + // For abstract symbolic constants, the corresponding instruction has the + // desired constant value. + const auto& symbolic_const = + import_ir_.constant_values().GetSymbolicConstant(import_const_id); + if (!symbolic_const.generic_id.is_valid()) { + return Resolve(import_ir_.constant_values().GetInstId(import_const_id)); + } + + // For a symbolic constant in a generic, pick the corresponding instruction + // out of the eval block for the generic and resolve its constant value. + const auto& generic = import_ir_.generics().Get(symbolic_const.generic_id); + auto block = generic.GetEvalBlock(symbolic_const.index.region()); + return Resolve( + import_ir_.inst_blocks().Get(block)[symbolic_const.index.index()]); + } + // Wraps constant evaluation with logic to handle types. auto ResolveType(SemIR::TypeId import_type_id) -> SemIR::TypeId { if (!import_type_id.is_valid()) { return import_type_id; } - auto import_type_inst_id = import_ir_.types().GetInstId(import_type_id); - CARBON_CHECK(import_type_inst_id.is_valid()); + auto import_type_const_id = + import_ir_.types().GetConstantId(import_type_id); + CARBON_CHECK(import_type_const_id.is_valid()); - if (import_type_inst_id.is_builtin()) { + if (auto import_type_inst_id = + import_ir_.constant_values().GetInstId(import_type_const_id); + import_type_inst_id.is_builtin()) { // Builtins don't require constant resolution; we can use them directly. return context_.GetBuiltinType(import_type_inst_id.builtin_inst_kind()); } else { - return context_.GetTypeIdForTypeConstant(Resolve(import_type_inst_id)); + return context_.GetTypeIdForTypeConstant( + ResolveConstant(import_type_id.AsConstantId())); } } @@ -266,6 +307,22 @@ class ImportRefResolver { llvm::SmallVector indirect_insts = {}; }; + // Local information associated with an imported generic. + struct GenericData { + llvm::SmallVector bindings; + // TODO: Add data for the self specific. + llvm::SmallVector decl_block; + llvm::SmallVector definition_block; + }; + + // Local information associated with an imported specific. + struct SpecificData { + SemIR::ConstantId generic_const_id; + llvm::SmallVector args; + llvm::SmallVector decl_block; + llvm::SmallVector definition_block; + }; + // Looks to see if an instruction has been resolved. If a constant is only // found indirectly, sets the constant for any indirect steps that don't // already have the constant. If a constant isn't found, returns the indirect @@ -396,6 +453,18 @@ class ImportRefResolver { return inst_ids; } + // Gets a local instruction block ID corresponding to an imported inst block + // whose contents were already imported, for example by + // GetLocalInstBlockContents. + auto GetLocalInstBlockId(SemIR::InstBlockId import_block_id, + llvm::ArrayRef contents) + -> SemIR::InstBlockId { + if (!import_block_id.is_valid()) { + return SemIR::InstBlockId::Invalid; + } + return context_.inst_blocks().Add(contents); + } + // Gets a local canonical instruction block ID corresponding to an imported // inst block whose contents were already imported, for example by // GetLocalInstBlockContents. @@ -408,43 +477,153 @@ class ImportRefResolver { return context_.inst_blocks().AddCanonical(contents); } - // Gets a local version of an imported generic. - auto GetLocalGeneric(SemIR::GenericId generic_id) -> SemIR::GenericId { + // Gets an incomplete local version of an imported generic. Most fields are + // set in the second pass. + auto MakeIncompleteGeneric(SemIR::InstId decl_id, SemIR::GenericId generic_id) + -> SemIR::GenericId { if (!generic_id.is_valid()) { return SemIR::GenericId::Invalid; } - // TODO: Support importing generics. Note that this comes up in the prelude, - // so for now we fall back to producing `Invalid` and treating imported - // generics as non-generic. - return SemIR::GenericId::Invalid; + return context_.generics().Add( + {.decl_id = decl_id, + .bindings_id = SemIR::InstBlockId::Invalid, + .self_specific_id = SemIR::SpecificId::Invalid}); } - // Gets a local argument list corresponding to the arguments of an imported - // generic instance. - auto GetLocalGenericInstanceArgs(SemIR::GenericInstanceId instance_id) - -> llvm::SmallVector { - if (!instance_id.is_valid()) { - return {}; + // Gets a local version of the data associated with a generic. + auto GetLocalGenericData(SemIR::GenericId generic_id) -> GenericData { + if (!generic_id.is_valid()) { + return GenericData(); + } + + const auto& generic = import_ir_.generics().Get(generic_id); + return { + .bindings = GetLocalInstBlockContents(generic.bindings_id), + .decl_block = GetLocalInstBlockContents(generic.decl_block_id), + .definition_block = + GetLocalInstBlockContents(generic.definition_block_id), + }; + } + + // Given the local constant values for the elements of the eval block, builds + // and returns the eval block for a region of a generic. + auto GetLocalEvalBlock(const SemIR::Generic& import_generic, + SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, + llvm::ArrayRef inst_ids) + -> SemIR::InstBlockId { + auto import_block_id = import_generic.GetEvalBlock(region); + if (!import_block_id.is_valid()) { + return SemIR::InstBlockId::Invalid; } - return GetLocalInstBlockContents( - import_ir_.generic_instances().Get(instance_id).args_id); + return RebuildGenericEvalBlock(context_, generic_id, region, inst_ids); + } + + // Adds the given local generic data to the given generic. + auto SetGenericData(SemIR::GenericId import_generic_id, + SemIR::GenericId new_generic_id, + const GenericData& generic_data) -> void { + if (!import_generic_id.is_valid()) { + return; + } + + const auto& import_generic = import_ir_.generics().Get(import_generic_id); + auto& new_generic = context_.generics().Get(new_generic_id); + new_generic.bindings_id = GetLocalCanonicalInstBlockId( + import_generic.bindings_id, generic_data.bindings); + // TODO: Import or rebuild the self specific. + new_generic.decl_block_id = GetLocalEvalBlock( + import_generic, new_generic_id, + SemIR::GenericInstIndex::Region::Declaration, generic_data.decl_block); + new_generic.definition_block_id = + GetLocalEvalBlock(import_generic, new_generic_id, + SemIR::GenericInstIndex::Region::Definition, + generic_data.definition_block); } - // Gets a local generic instance whose arguments were already imported by - // GetLocalGenericInstanceArgs. Does not add any new work. - auto GetLocalGenericInstance(SemIR::GenericInstanceId instance_id, - llvm::ArrayRef args) - -> SemIR::GenericInstanceId { - if (!instance_id.is_valid()) { - return SemIR::GenericInstanceId::Invalid; + // Gets a local constant value corresponding to an imported generic ID. May + // add work to the work stack and return `Invalid`. + auto GetLocalConstantId(SemIR::GenericId generic_id) -> SemIR::ConstantId { + if (!generic_id.is_valid()) { + return SemIR::ConstantId::Invalid; } - const auto& instance = import_ir_.generic_instances().Get(instance_id); - // TODO: Import the generic. - auto generic_id = SemIR::GenericId::Invalid; - auto args_id = GetLocalCanonicalInstBlockId(instance.args_id, args); - // TODO: Also import the generic instance. - return context_.generic_instances().GetOrAdd(generic_id, args_id); + return GetLocalConstantId( + import_ir_.insts() + .Get(import_ir_.generics().Get(generic_id).decl_id) + .type_id()); + } + + // Gets a local generic ID given the corresponding local constant ID returned + // by GetLocalConstantId for the imported generic. Does not add any new work. + auto GetLocalGenericId(SemIR::ConstantId local_const_id) -> SemIR::GenericId { + if (!local_const_id.is_valid()) { + return SemIR::GenericId::Invalid; + } + auto type = context_.insts().Get( + context_.constant_values().GetInstId(local_const_id)); + CARBON_KIND_SWITCH(type) { + case CARBON_KIND(SemIR::FunctionType fn_type): { + return context_.functions().Get(fn_type.function_id).generic_id; + } + case CARBON_KIND(SemIR::GenericClassType class_type): { + return context_.classes().Get(class_type.class_id).generic_id; + } + case CARBON_KIND(SemIR::GenericInterfaceType interface_type): { + return context_.interfaces() + .Get(interface_type.interface_id) + .generic_id; + } + default: { + CARBON_FATAL() << "Unexpected type for generic declaration: " << type; + } + } + } + + // Gets local information about an imported specific. + auto GetLocalSpecificData(SemIR::SpecificId specific_id) -> SpecificData { + if (!specific_id.is_valid()) { + return {.generic_const_id = SemIR::ConstantId::Invalid, .args = {}}; + } + + const auto& specific = import_ir_.specifics().Get(specific_id); + return { + .generic_const_id = GetLocalConstantId(specific.generic_id), + .args = GetLocalInstBlockContents(specific.args_id), + .decl_block = GetLocalInstBlockContents(specific.decl_block_id), + .definition_block = + GetLocalInstBlockContents(specific.definition_block_id), + }; + } + + // Gets a local specific whose data was already imported by + // GetLocalSpecificData. Does not add any new work. + auto GetOrAddLocalSpecific(SemIR::SpecificId import_specific_id, + const SpecificData& data) -> SemIR::SpecificId { + if (!import_specific_id.is_valid()) { + return SemIR::SpecificId::Invalid; + } + + // Form a corresponding local specific ID. + const auto& import_specific = + import_ir_.specifics().Get(import_specific_id); + auto generic_id = GetLocalGenericId(data.generic_const_id); + auto args_id = + GetLocalCanonicalInstBlockId(import_specific.args_id, data.args); + + // Populate the specific. Note that we might get data from multiple + // different import IRs, so only import data we don't already have. + auto specific_id = context_.specifics().GetOrAdd(generic_id, args_id); + auto& specific = context_.specifics().Get(specific_id); + if (!specific.decl_block_id.is_valid()) { + specific.decl_block_id = + GetLocalInstBlockId(import_specific.decl_block_id, data.decl_block); + } + if (!specific.definition_block_id.is_valid()) { + specific.definition_block_id = GetLocalInstBlockId( + import_specific.definition_block_id, data.definition_block); + } + return specific_id; } // Returns the ConstantId for each parameter's type. Adds unresolved constants @@ -519,29 +698,26 @@ class ImportRefResolver { if (bind_inst) { switch (bind_inst->kind) { case SemIR::BindName::Kind: { - auto bind_name_id = context_.bind_names().Add( + auto entity_name_id = context_.entity_names().Add( {.name_id = name_id, .parent_scope_id = SemIR::NameScopeId::Invalid, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); new_param_id = context_.AddInstInNoBlock( AddImportIRInst(bind_id), {.type_id = type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = new_param_id}); break; } case SemIR::BindSymbolicName::Kind: { - // The symbolic name will be created on first reference, so might - // already exist. Update the value in it to refer to the parameter. + // We already imported a constant value for this symbolic binding. + // We can reuse most of it. auto new_bind_inst_id = GetLocalConstantInstId(bind_id); auto new_bind_inst = context_.insts().GetAs( new_bind_inst_id); new_bind_inst.value_id = new_param_id; - // This is not before constant use, but doesn't change the - // constant value of the instruction. - context_.ReplaceInstBeforeConstantUse(new_bind_inst_id, - new_bind_inst); - new_param_id = new_bind_inst_id; + new_param_id = context_.AddInstInNoBlock(AddImportIRInst(bind_id), + new_bind_inst); break; } default: { @@ -641,6 +817,33 @@ class ImportRefResolver { << name_scope_inst; } + // Given an imported entity base, returns an incomplete, local version of it. + // + // Most fields are set in the second pass once they're imported. Import enough + // of the parameter lists that we know whether this interface is a generic + // interface and can build the right constant value for it. + // + // TODO: Add a better way to represent a generic prior to importing the + // parameters. + auto GetIncompleteLocalEntityBase( + SemIR::InstId decl_id, const SemIR::EntityWithParamsBase& import_base) + -> SemIR::EntityWithParamsBase { + return { + .name_id = GetLocalNameId(import_base.name_id), + .parent_scope_id = SemIR::NameScopeId::Invalid, + .generic_id = MakeIncompleteGeneric(decl_id, import_base.generic_id), + .first_param_node_id = Parse::NodeId::Invalid, + .last_param_node_id = Parse::NodeId::Invalid, + .implicit_param_refs_id = import_base.implicit_param_refs_id.is_valid() + ? SemIR::InstBlockId::Empty + : SemIR::InstBlockId::Invalid, + .param_refs_id = import_base.param_refs_id.is_valid() + ? SemIR::InstBlockId::Empty + : SemIR::InstBlockId::Invalid, + .decl_id = decl_id, + }; + } + // Adds ImportRefUnloaded entries for members of the imported scope, for name // lookup. auto AddNameScopeImportRefs(const SemIR::NameScope& import_scope, @@ -648,7 +851,7 @@ class ImportRefResolver { for (auto entry : import_scope.names) { auto ref_id = AddImportRef( context_, {.ir_id = import_ir_id_, .inst_id = entry.inst_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); new_scope.AddRequired({.name_id = GetLocalNameId(entry.name_id), .inst_id = ref_id, .access_kind = entry.access_kind}); @@ -669,7 +872,7 @@ class ImportRefResolver { for (auto inst_id : associated_entities) { new_associated_entities.push_back( AddImportRef(context_, {.ir_id = import_ir_id_, .inst_id = inst_id}, - SemIR::BindNameId::Invalid)); + SemIR::EntityNameId::Invalid)); } return context_.inst_blocks().Add(new_associated_entities); } @@ -684,6 +887,39 @@ class ImportRefResolver { // TODO: Error is returned when support is missing, but that should go away. auto TryResolveInst(SemIR::InstId inst_id, SemIR::ConstantId const_id) -> ResolveResult { + auto inst_const_id = import_ir_.constant_values().Get(inst_id); + if (!inst_const_id.is_valid() || !inst_const_id.is_symbolic() || + const_id.is_valid()) { + return TryResolveInstCanonical(inst_id, const_id); + } + + // Try to import the generic, and retry if it's not ready yet. Note that if + // this retries, we can require three passes to import an instruction. + const auto& symbolic_const = + import_ir_.constant_values().GetSymbolicConstant(inst_const_id); + auto initial_work = work_stack_.size(); + auto generic_const_id = GetLocalConstantId(symbolic_const.generic_id); + if (HasNewWork(initial_work)) { + return ResolveResult::Retry(); + } + + // Import the constant and rebuild the symbolic constant data. + auto result = TryResolveInstCanonical(inst_id, const_id); + if (result.const_id.is_valid()) { + result.const_id = context_.constant_values().AddSymbolicConstant( + {.inst_id = context_.constant_values().GetInstId(result.const_id), + .generic_id = GetLocalGenericId(generic_const_id), + .index = symbolic_const.index}); + } + return result; + } + + // Tries to resolve the InstId, returning a canonical constant when ready, or + // Invalid if more has been added to the stack. This is the same as + // TryResolveInst, except that it may resolve symbolic constants as canonical + // constants instead of as constants associated with a particular generic. + auto TryResolveInstCanonical(SemIR::InstId inst_id, + SemIR::ConstantId const_id) -> ResolveResult { if (inst_id.is_builtin()) { CARBON_CHECK(!const_id.is_valid()); // Constants for builtins can be directly copied. @@ -727,7 +963,7 @@ class ImportRefResolver { return TryResolveTypedInst(inst, inst_id); } case CARBON_KIND(SemIR::FunctionDecl inst): { - return TryResolveTypedInst(inst); + return TryResolveTypedInst(inst, const_id); } case CARBON_KIND(SemIR::FunctionType inst): { return TryResolveTypedInst(inst); @@ -810,7 +1046,7 @@ class ImportRefResolver { // Add a lazy reference to the target declaration. auto decl_id = AddImportRef( context_, {.ir_id = import_ir_id_, .inst_id = inst.decl_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); return ResolveAs( {.type_id = context_.GetTypeIdForTypeConstant(type_const_id), @@ -829,11 +1065,22 @@ class ImportRefResolver { return ResolveResult::Retry(); } + // TODO: Track an interface type, not an interface ID, on + // AssociatedEntityType. + auto interface_inst = context_.insts().Get(interface_inst_id); + SemIR::InterfaceId interface_id = SemIR::InterfaceId::Invalid; + if (interface_inst.Is()) { + interface_id = interface_inst.As().interface_id; + } else { + interface_id = + context_.types() + .GetAs(interface_inst.type_id()) + .interface_id; + } + return ResolveAs( {.type_id = SemIR::TypeId::TypeType, - .interface_id = context_.insts() - .GetAs(interface_inst_id) - .interface_id, + .interface_id = interface_id, .entity_type_id = context_.GetTypeIdForTypeConstant(entity_type_const_id)}); } @@ -873,16 +1120,16 @@ class ImportRefResolver { return ResolveResult::Retry(); } - const auto& import_bind_info = - import_ir_.bind_names().Get(inst.bind_name_id); - auto name_id = GetLocalNameId(import_bind_info.name_id); - auto bind_name_id = context_.bind_names().Add( + const auto& import_entity_name = + import_ir_.entity_names().Get(inst.entity_name_id); + auto name_id = GetLocalNameId(import_entity_name.name_id); + auto entity_name_id = context_.entity_names().Add( {.name_id = name_id, .parent_scope_id = SemIR::NameScopeId::Invalid, - .bind_index = import_bind_info.bind_index}); + .bind_index = import_entity_name.bind_index}); return ResolveAs( {.type_id = context_.GetTypeIdForTypeConstant(type_id), - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = SemIR::InstId::Invalid}); } @@ -896,30 +1143,12 @@ class ImportRefResolver { .decl_block_id = SemIR::InstBlockId::Empty}; auto class_decl_id = context_.AddPlaceholderInstInNoBlock( SemIR::LocIdAndInst(AddImportIRInst(import_class.decl_id), class_decl)); - // TODO: Support for importing generics. - auto generic_id = GetLocalGeneric(import_class.generic_id); // Regardless of whether ClassDecl is a complete type, we first need an // incomplete type so that any references have something to point at. - class_decl.class_id = context_.classes().Add({ - .name_id = GetLocalNameId(import_class.name_id), - // These are set in the second pass once we've imported them. Import - // enough of the parameter lists that we know whether this class is a - // generic class and can build the right constant value for it. - // TODO: Add a better way to represent a generic `Class` prior to - // importing the parameters. - .parent_scope_id = SemIR::NameScopeId::Invalid, - .generic_id = generic_id, - .implicit_param_refs_id = import_class.implicit_param_refs_id.is_valid() - ? SemIR::InstBlockId::Empty - : SemIR::InstBlockId::Invalid, - .param_refs_id = import_class.param_refs_id.is_valid() - ? SemIR::InstBlockId::Empty - : SemIR::InstBlockId::Invalid, - .self_type_id = SemIR::TypeId::Invalid, - // These fields can be set immediately. - .decl_id = class_decl_id, - .inheritance_kind = import_class.inheritance_kind, - }); + class_decl.class_id = context_.classes().Add( + {GetIncompleteLocalEntityBase(class_decl_id, import_class), + {.self_type_id = SemIR::TypeId::Invalid, + .inheritance_kind = import_class.inheritance_kind}}); if (import_class.is_generic()) { class_decl.type_id = context_.GetGenericClassType(class_decl.class_id); @@ -1002,6 +1231,7 @@ class ImportRefResolver { GetLocalParamConstantIds(import_class.implicit_param_refs_id); llvm::SmallVector param_const_ids = GetLocalParamConstantIds(import_class.param_refs_id); + auto generic_data = GetLocalGenericData(import_class.generic_id); auto self_const_id = GetLocalConstantId(import_class.self_type_id); auto object_repr_const_id = import_class.object_repr_id.is_valid() @@ -1021,6 +1251,7 @@ class ImportRefResolver { import_class.implicit_param_refs_id, implicit_param_const_ids); new_class.param_refs_id = GetLocalParamRefsId(import_class.param_refs_id, param_const_ids); + SetGenericData(import_class.generic_id, new_class.generic_id, generic_data); new_class.self_type_id = context_.GetTypeIdForTypeConstant(self_const_id); if (import_class.is_defined()) { @@ -1036,7 +1267,7 @@ class ImportRefResolver { CARBON_CHECK(inst.type_id == SemIR::TypeId::TypeType); auto class_const_id = GetLocalConstantId(import_ir_.classes().Get(inst.class_id).decl_id); - auto args = GetLocalGenericInstanceArgs(inst.instance_id); + auto specific_data = GetLocalSpecificData(inst.specific_id); if (HasNewWork(initial_work)) { return ResolveResult::Retry(); } @@ -1051,11 +1282,11 @@ class ImportRefResolver { } else { auto generic_class_type = context_.types().GetAs( class_const_inst.type_id()); - auto instance_id = GetLocalGenericInstance(inst.instance_id, args); + auto specific_id = GetOrAddLocalSpecific(inst.specific_id, specific_data); return ResolveAs( {.type_id = SemIR::TypeId::TypeType, .class_id = generic_class_type.class_id, - .instance_id = instance_id}); + .specific_id = specific_id}); } } @@ -1095,69 +1326,101 @@ class ImportRefResolver { return {.const_id = context_.constant_values().Get(inst_id)}; } - auto TryResolveTypedInst(SemIR::FunctionDecl inst) -> ResolveResult { + // Make a declaration of a function. This is done as a separate step from + // importing the function declaration in order to resolve cycles. + auto MakeFunctionDecl(const SemIR::Function& import_function) + -> std::pair { + SemIR::FunctionDecl function_decl = { + .type_id = SemIR::TypeId::Invalid, + .function_id = SemIR::FunctionId::Invalid, + .decl_block_id = SemIR::InstBlockId::Empty}; + auto function_decl_id = + context_.AddPlaceholderInstInNoBlock(SemIR::LocIdAndInst( + AddImportIRInst(import_function.latest_decl_id()), function_decl)); + + // Start with an incomplete function. + function_decl.function_id = context_.functions().Add( + {GetIncompleteLocalEntityBase(function_decl_id, import_function), + {.return_storage_id = SemIR::InstId::Invalid, + .is_extern = import_function.is_extern, + .builtin_function_kind = import_function.builtin_function_kind}}); + + // TODO: Import this or recompute it. + auto specific_id = SemIR::SpecificId::Invalid; + function_decl.type_id = + context_.GetFunctionType(function_decl.function_id, specific_id); + + // Write the function ID and type into the FunctionDecl. + context_.ReplaceInstBeforeConstantUse(function_decl_id, function_decl); + return {function_decl.function_id, + context_.constant_values().Get(function_decl_id)}; + } + + auto TryResolveTypedInst(SemIR::FunctionDecl inst, + SemIR::ConstantId function_const_id) + -> ResolveResult { + const auto& import_function = import_ir_.functions().Get(inst.function_id); + + SemIR::FunctionId function_id = SemIR::FunctionId::Invalid; + if (!function_const_id.is_valid()) { + // On the first pass, create a forward declaration of the interface. + std::tie(function_id, function_const_id) = + MakeFunctionDecl(import_function); + } else { + // On the second pass, compute the function ID from the constant value of + // the declaration. + auto function_const_inst = context_.insts().Get( + context_.constant_values().GetInstId(function_const_id)); + auto function_type = context_.types().GetAs( + function_const_inst.type_id()); + function_id = function_type.function_id; + } + auto initial_work = work_stack_.size(); - const auto& function = import_ir_.functions().Get(inst.function_id); auto return_type_const_id = SemIR::ConstantId::Invalid; - if (function.return_storage_id.is_valid()) { + if (import_function.return_storage_id.is_valid()) { return_type_const_id = - GetLocalConstantId(function.declared_return_type(import_ir_)); + GetLocalConstantId(import_function.GetDeclaredReturnType(import_ir_)); } - auto parent_scope_id = GetLocalNameScopeId(function.parent_scope_id); + auto parent_scope_id = GetLocalNameScopeId(import_function.parent_scope_id); llvm::SmallVector implicit_param_const_ids = - GetLocalParamConstantIds(function.implicit_param_refs_id); + GetLocalParamConstantIds(import_function.implicit_param_refs_id); llvm::SmallVector param_const_ids = - GetLocalParamConstantIds(function.param_refs_id); + GetLocalParamConstantIds(import_function.param_refs_id); + auto generic_data = GetLocalGenericData(import_function.generic_id); if (HasNewWork(initial_work)) { - return ResolveResult::Retry(); + return ResolveResult::Retry(function_const_id); } // Add the function declaration. - SemIR::FunctionDecl function_decl = { - .type_id = SemIR::TypeId::Invalid, - .function_id = SemIR::FunctionId::Invalid, - .decl_block_id = SemIR::InstBlockId::Empty}; - // Prefer pointing diagnostics towards a definition. - auto import_ir_inst_id = AddImportIRInst(function.definition_id.is_valid() - ? function.definition_id - : function.decl_id); - auto function_decl_id = context_.AddPlaceholderInstInNoBlock( - SemIR::LocIdAndInst(import_ir_inst_id, function_decl)); - // TODO: Implement import for generics. - auto generic_id = GetLocalGeneric(function.generic_id); - - auto new_return_storage = SemIR::InstId::Invalid; - if (function.return_storage_id.is_valid()) { + auto& new_function = context_.functions().Get(function_id); + new_function.parent_scope_id = parent_scope_id; + new_function.implicit_param_refs_id = GetLocalParamRefsId( + import_function.implicit_param_refs_id, implicit_param_const_ids); + new_function.param_refs_id = + GetLocalParamRefsId(import_function.param_refs_id, param_const_ids); + SetGenericData(import_function.generic_id, new_function.generic_id, + generic_data); + + if (import_function.return_storage_id.is_valid()) { // Recreate the return slot from scratch. // TODO: Once we import function definitions, we'll need to make sure we // use the same return storage variable in the declaration and definition. - new_return_storage = context_.AddInstInNoBlock( - AddImportIRInst(function.return_storage_id), - {.type_id = context_.GetTypeIdForTypeConstant(return_type_const_id), - .name_id = SemIR::NameId::ReturnSlot}); + new_function.return_storage_id = + context_.AddInstInNoBlock( + AddImportIRInst(import_function.return_storage_id), + {.type_id = + context_.GetTypeIdForTypeConstant(return_type_const_id), + .name_id = SemIR::NameId::ReturnSlot}); } - function_decl.function_id = context_.functions().Add( - {.name_id = GetLocalNameId(function.name_id), - .parent_scope_id = parent_scope_id, - .decl_id = function_decl_id, - .generic_id = generic_id, - .implicit_param_refs_id = GetLocalParamRefsId( - function.implicit_param_refs_id, implicit_param_const_ids), - .param_refs_id = - GetLocalParamRefsId(function.param_refs_id, param_const_ids), - .return_storage_id = new_return_storage, - .is_extern = function.is_extern, - .return_slot = function.return_slot, - .builtin_function_kind = function.builtin_function_kind, - .definition_id = function.definition_id.is_valid() - ? function_decl_id - : SemIR::InstId::Invalid}); - function_decl.type_id = context_.GetFunctionType(function_decl.function_id); - // Write the function ID into the FunctionDecl. - context_.ReplaceInstBeforeConstantUse(function_decl_id, function_decl); - return {.const_id = context_.constant_values().Get(function_decl_id)}; + + if (import_function.definition_id.is_valid()) { + new_function.definition_id = new_function.decl_id; + } + + return {.const_id = function_const_id}; } auto TryResolveTypedInst(SemIR::FunctionType inst) -> ResolveResult { @@ -1165,12 +1428,18 @@ class ImportRefResolver { CARBON_CHECK(inst.type_id == SemIR::TypeId::TypeType); auto fn_val_id = GetLocalConstantInstId( import_ir_.functions().Get(inst.function_id).decl_id); + auto specific_data = GetLocalSpecificData(inst.specific_id); if (HasNewWork(initial_work)) { return ResolveResult::Retry(); } - auto fn_val = context_.insts().Get(fn_val_id); - CARBON_CHECK(context_.types().Is(fn_val.type_id())); - return {.const_id = context_.types().GetConstantId(fn_val.type_id())}; + auto fn_type_id = context_.insts().Get(fn_val_id).type_id(); + return ResolveAs( + {.type_id = SemIR::TypeId::TypeType, + .function_id = context_.types() + .GetAs(fn_type_id) + .function_id, + .specific_id = + GetOrAddLocalSpecific(inst.specific_id, specific_data)}); } auto TryResolveTypedInst(SemIR::GenericClassType inst) -> ResolveResult { @@ -1237,27 +1506,10 @@ class ImportRefResolver { context_.AddPlaceholderInstInNoBlock(SemIR::LocIdAndInst( AddImportIRInst(import_interface.decl_id), interface_decl)); - // TODO: Support for importing generics. - auto generic_id = GetLocalGeneric(import_interface.generic_id); // Start with an incomplete interface. - interface_decl.interface_id = context_.interfaces().Add({ - .name_id = GetLocalNameId(import_interface.name_id), - // These are set in the second pass once we've imported them. Import - // enough of the parameter lists that we know whether this interface is - // a generic interface and can build the right constant value for it. - // TODO: Add a better way to represent a generic `Interface` prior to - // importing the parameters. - .parent_scope_id = SemIR::NameScopeId::Invalid, - .generic_id = generic_id, - .implicit_param_refs_id = - import_interface.implicit_param_refs_id.is_valid() - ? SemIR::InstBlockId::Empty - : SemIR::InstBlockId::Invalid, - .param_refs_id = import_interface.param_refs_id.is_valid() - ? SemIR::InstBlockId::Empty - : SemIR::InstBlockId::Invalid, - .decl_id = interface_decl_id, - }); + interface_decl.interface_id = context_.interfaces().Add( + {GetIncompleteLocalEntityBase(interface_decl_id, import_interface), + {}}); if (import_interface.is_generic()) { interface_decl.type_id = @@ -1329,7 +1581,12 @@ class ImportRefResolver { GetLocalParamConstantIds(import_interface.implicit_param_refs_id); llvm::SmallVector param_const_ids = GetLocalParamConstantIds(import_interface.param_refs_id); - auto self_param_id = GetLocalConstantInstId(import_interface.self_param_id); + auto generic_data = GetLocalGenericData(import_interface.generic_id); + + std::optional self_param_id; + if (import_interface.is_defined()) { + self_param_id = GetLocalConstantInstId(import_interface.self_param_id); + } if (HasNewWork(initial_work)) { return ResolveResult::Retry(interface_const_id); @@ -1341,9 +1598,12 @@ class ImportRefResolver { import_interface.implicit_param_refs_id, implicit_param_const_ids); new_interface.param_refs_id = GetLocalParamRefsId(import_interface.param_refs_id, param_const_ids); + SetGenericData(import_interface.generic_id, new_interface.generic_id, + generic_data); if (import_interface.is_defined()) { - AddInterfaceDefinition(import_interface, new_interface, self_param_id); + CARBON_CHECK(self_param_id); + AddInterfaceDefinition(import_interface, new_interface, *self_param_id); } return {.const_id = interface_const_id}; } @@ -1353,7 +1613,7 @@ class ImportRefResolver { CARBON_CHECK(inst.type_id == SemIR::TypeId::TypeType); auto interface_const_id = GetLocalConstantId( import_ir_.interfaces().Get(inst.interface_id).decl_id); - auto args = GetLocalGenericInstanceArgs(inst.instance_id); + auto specific_data = GetLocalSpecificData(inst.specific_id); if (HasNewWork(initial_work)) { return ResolveResult::Retry(); } @@ -1370,11 +1630,11 @@ class ImportRefResolver { auto generic_interface_type = context_.types().GetAs( interface_const_inst.type_id()); - auto instance_id = GetLocalGenericInstance(inst.instance_id, args); + auto specific_id = GetOrAddLocalSpecific(inst.specific_id, specific_data); return ResolveAs( {.type_id = SemIR::TypeId::TypeType, .interface_id = generic_interface_type.interface_id, - .instance_id = instance_id}); + .specific_id = specific_id}); } } @@ -1598,7 +1858,7 @@ auto LoadImportRef(Context& context, SemIR::InstId inst_id) -> void { inst_id, SemIR::ImportRefLoaded{.type_id = type_id, .import_ir_inst_id = inst->import_ir_inst_id, - .bind_name_id = inst->bind_name_id}); + .entity_name_id = inst->entity_name_id}); // Store the constant for both the ImportRefLoaded and indirect instructions. context.constant_values().Set(inst_id, constant_id); @@ -1628,7 +1888,7 @@ static auto ImportImpl(Context& context, SemIR::ImportIRId import_ir_id, auto& impl = context.impls().Get(impl_id); impl.witness_id = AddImportRef( context, {.ir_id = import_ir_id, .inst_id = import_impl.witness_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); } } diff --git a/toolchain/check/import_ref.h b/toolchain/check/import_ref.h index 9d8d1821fbad2..5b5bc9235537d 100644 --- a/toolchain/check/import_ref.h +++ b/toolchain/check/import_ref.h @@ -22,7 +22,7 @@ auto AddImportIR(Context& context, SemIR::ImportIR import_ir) // Adds an import_ref instruction for the specified instruction in the // specified IR. The import_ref is initially marked as unused. auto AddImportRef(Context& context, SemIR::ImportIRInst import_ir_inst, - SemIR::BindNameId bind_name_id) -> SemIR::InstId; + SemIR::EntityNameId entity_name_id) -> SemIR::InstId; // Returns the canonical IR inst for an entity. Returns an invalid ir_id for the // current IR. diff --git a/toolchain/check/inst_block_stack.cpp b/toolchain/check/inst_block_stack.cpp index 7220e49af1d5a..9ffcc3540b513 100644 --- a/toolchain/check/inst_block_stack.cpp +++ b/toolchain/check/inst_block_stack.cpp @@ -61,16 +61,17 @@ auto InstBlockStack::PopAndDiscard() -> void { CARBON_VLOG() << name_ << " PopAndDiscard " << id_stack_.size() << "\n"; } -auto InstBlockStack::PrintForStackDump(llvm::raw_ostream& output) const +auto InstBlockStack::PrintForStackDump(SemIR::Formatter& formatter, int indent, + llvm::raw_ostream& output) const -> void { + output.indent(indent); output << name_ << ":\n"; for (const auto& [i, id] : llvm::enumerate(id_stack_)) { - output << "\t" << i << ".\t" << id << "\t{"; - llvm::ListSeparator sep; - for (auto id : insts_stack_.PeekArrayAt(i)) { - output << sep << id; - } - output << "}\n"; + output.indent(indent + 2); + output << i << ". " << id; + formatter.PrintPartialTrailingCodeBlock(insts_stack_.PeekArrayAt(i), + indent + 4, output); + output << "\n"; } } diff --git a/toolchain/check/inst_block_stack.h b/toolchain/check/inst_block_stack.h index 159cf3ccb340d..0115861d4bcf7 100644 --- a/toolchain/check/inst_block_stack.h +++ b/toolchain/check/inst_block_stack.h @@ -8,6 +8,7 @@ #include "common/array_stack.h" #include "llvm/ADT/SmallVector.h" #include "toolchain/sem_ir/file.h" +#include "toolchain/sem_ir/formatter.h" namespace Carbon::Check { @@ -69,7 +70,8 @@ class InstBlockStack { } // Prints the stack for a stack dump. - auto PrintForStackDump(llvm::raw_ostream& output) const -> void; + auto PrintForStackDump(SemIR::Formatter& formatter, int indent, + llvm::raw_ostream& output) const -> void; // Runs verification that the processing cleanly finished. auto VerifyOnFinish() const -> void { diff --git a/toolchain/check/member_access.cpp b/toolchain/check/member_access.cpp index d5e4af2603ca6..6086f22e07f3a 100644 --- a/toolchain/check/member_access.cpp +++ b/toolchain/check/member_access.cpp @@ -8,7 +8,6 @@ #include "toolchain/base/kind_switch.h" #include "toolchain/check/context.h" #include "toolchain/check/convert.h" -#include "toolchain/check/generic.h" #include "toolchain/check/import_ref.h" #include "toolchain/check/subst.h" #include "toolchain/diagnostics/diagnostic_emitter.h" @@ -27,7 +26,7 @@ static auto GetAsLookupScope(Context& context, Parse::NodeId node_id, auto base = context.insts().Get(base_id); if (auto base_as_namespace = base.TryAs()) { return LookupScope{.name_scope_id = base_as_namespace->name_scope_id, - .instance_id = SemIR::GenericInstanceId::Invalid}; + .specific_id = SemIR::SpecificId::Invalid}; } // TODO: Consider refactoring the near-identical class and interface support // below. @@ -43,7 +42,7 @@ static auto GetAsLookupScope(Context& context, Parse::NodeId node_id, }); auto& class_info = context.classes().Get(base_as_class->class_id); return LookupScope{.name_scope_id = class_info.scope_id, - .instance_id = base_as_class->instance_id}; + .specific_id = base_as_class->specific_id}; } if (auto base_as_interface = base.TryAs()) { context.TryToDefineType( @@ -58,7 +57,7 @@ static auto GetAsLookupScope(Context& context, Parse::NodeId node_id, auto& interface_info = context.interfaces().Get(base_as_interface->interface_id); return LookupScope{.name_scope_id = interface_info.scope_id, - .instance_id = base_as_interface->instance_id}; + .specific_id = base_as_interface->specific_id}; } // TODO: Per the design, if `base_id` is any kind of type, then lookup should // treat it as a name scope, even if it doesn't have members. For example, @@ -197,7 +196,8 @@ static auto PerformImplLookup(Context& context, Parse::NodeId node_id, auto self_param = context.insts().GetAs(interface.self_param_id); Substitution substitutions[1] = { - {.bind_id = context.bind_names().Get(self_param.bind_name_id).bind_index, + {.bind_id = + context.entity_names().Get(self_param.entity_name_id).bind_index, .replacement_id = type_const_id}}; auto subst_type_id = SubstType(context, assoc_type.entity_type_id, substitutions); @@ -217,7 +217,7 @@ static auto LookupMemberNameInScope(Context& context, Parse::NodeId node_id, SemIR::NameId name_id, SemIR::ConstantId name_scope_const_id, LookupScope lookup_scope) -> SemIR::InstId { - LookupResult result = {.instance_id = SemIR::GenericInstanceId::Invalid, + LookupResult result = {.specific_id = SemIR::SpecificId::Invalid, .inst_id = SemIR::InstId::BuiltinError}; if (lookup_scope.name_scope_id.is_valid()) { result = context.LookupQualifiedName(node_id, name_id, lookup_scope); @@ -225,17 +225,18 @@ static auto LookupMemberNameInScope(Context& context, Parse::NodeId node_id, // TODO: This duplicates the work that HandleNameAsExpr does. Factor this out. auto inst = context.insts().Get(result.inst_id); - auto type_id = GetTypeInInstance(context, result.instance_id, inst.type_id()); + auto type_id = SemIR::GetTypeInSpecific(context.sem_ir(), result.specific_id, + inst.type_id()); CARBON_CHECK(type_id.is_valid()) << "Missing type for member " << inst; - // If the named entity has a constant value that depends on its generic - // instance, store the instance too. - if (result.instance_id.is_valid() && + // If the named entity has a constant value that depends on its specific, + // store the specific too. + if (result.specific_id.is_valid() && context.constant_values().Get(result.inst_id).is_symbolic()) { result.inst_id = context.AddInst( node_id, {.type_id = type_id, .inst_id = result.inst_id, - .instance_id = result.instance_id}); + .specific_id = result.specific_id}); } // TODO: Use a different kind of instruction that also references the @@ -408,6 +409,9 @@ auto PerformCompoundMemberAccess(Context& context, Parse::NodeId node_id, member.type_id())) { member_id = PerformImplLookup(context, node_id, base_type_const_id, *assoc_type, member_id); + } else if (context.insts().Is( + context.constant_values().GetInstId(base_type_const_id))) { + return PerformTupleIndex(context, node_id, base_id, member_expr_id); } // Perform instance binding if we found an instance member. @@ -427,4 +431,73 @@ auto PerformCompoundMemberAccess(Context& context, Parse::NodeId node_id, return member_id; } +// Validates that the index (required to be an IntLiteral) is valid within the +// tuple size. Returns the index on success, or nullptr on failure. +static auto ValidateTupleIndex(Context& context, Parse::NodeId node_id, + SemIR::Inst operand_inst, + SemIR::IntLiteral index_inst, int size) + -> const llvm::APInt* { + const auto& index_val = context.ints().Get(index_inst.int_id); + if (index_val.uge(size)) { + CARBON_DIAGNOSTIC( + TupleIndexOutOfBounds, Error, + "Tuple element index `{0}` is past the end of type `{1}`.", TypedInt, + SemIR::TypeId); + context.emitter().Emit(node_id, TupleIndexOutOfBounds, + {.type = index_inst.type_id, .value = index_val}, + operand_inst.type_id()); + return nullptr; + } + return &index_val; +} + +auto PerformTupleIndex(Context& context, Parse::NodeId node_id, + SemIR::InstId tuple_inst_id, SemIR::InstId index_inst_id) + -> SemIR::InstId { + tuple_inst_id = ConvertToValueOrRefExpr(context, tuple_inst_id); + auto tuple_inst = context.insts().Get(tuple_inst_id); + auto tuple_type_id = tuple_inst.type_id(); + + auto tuple_type = context.types().TryGetAs(tuple_type_id); + if (!tuple_type) { + CARBON_DIAGNOSTIC(TupleIndexOnANonTupleType, Error, + "Type `{0}` does not support tuple indexing. Only " + "tuples can be indexed that way.", + SemIR::TypeId); + context.emitter().Emit(node_id, TupleIndexOnANonTupleType, tuple_type_id); + return SemIR::InstId::BuiltinError; + } + + SemIR::TypeId element_type_id = SemIR::TypeId::Error; + auto index_node_id = context.insts().GetLocId(index_inst_id); + index_inst_id = ConvertToValueOfType( + context, index_node_id, index_inst_id, + context.GetBuiltinType(SemIR::BuiltinInstKind::IntType)); + auto index_const_id = context.constant_values().Get(index_inst_id); + if (index_const_id == SemIR::ConstantId::Error) { + index_inst_id = SemIR::InstId::BuiltinError; + } else if (!index_const_id.is_template()) { + // TODO: Decide what to do if the index is a symbolic constant. + CARBON_DIAGNOSTIC(TupleIndexNotConstant, Error, + "Tuple index must be a constant."); + context.emitter().Emit(node_id, TupleIndexNotConstant); + index_inst_id = SemIR::InstId::BuiltinError; + } else { + auto index_literal = context.insts().GetAs( + context.constant_values().GetInstId(index_const_id)); + auto type_block = context.type_blocks().Get(tuple_type->elements_id); + if (const auto* index_val = ValidateTupleIndex( + context, node_id, tuple_inst, index_literal, type_block.size())) { + element_type_id = type_block[index_val->getZExtValue()]; + } else { + index_inst_id = SemIR::InstId::BuiltinError; + } + } + + return context.AddInst(node_id, + {.type_id = element_type_id, + .tuple_id = tuple_inst_id, + .index_id = index_inst_id}); +} + } // namespace Carbon::Check diff --git a/toolchain/check/member_access.h b/toolchain/check/member_access.h index 562d3c3a14b86..a03a1627fb519 100644 --- a/toolchain/check/member_access.h +++ b/toolchain/check/member_access.h @@ -23,6 +23,12 @@ auto PerformCompoundMemberAccess(Context& context, Parse::NodeId node_id, SemIR::InstId base_id, SemIR::InstId member_expr_id) -> SemIR::InstId; +// Creates SemIR to perform a tuple index with base expression `tuple_inst_id` and +// index expression `index_inst_id`. Returns the result of the access. +auto PerformTupleIndex(Context& context, Parse::NodeId node_id, + SemIR::InstId tuple_inst_id, SemIR::InstId index_inst_id) + -> SemIR::InstId; + } // namespace Carbon::Check #endif // CARBON_TOOLCHAIN_CHECK_MEMBER_ACCESS_H_ diff --git a/toolchain/check/merge.cpp b/toolchain/check/merge.cpp index de85034f8f237..f241098c4b56e 100644 --- a/toolchain/check/merge.cpp +++ b/toolchain/check/merge.cpp @@ -171,6 +171,8 @@ static auto CheckRedeclParam(Context& context, .Emit(); }; + // TODO: Pass in a specific ID for the previous declaration instead of + // substitutions. auto new_param_ref = context.insts().Get(new_param_ref_id); auto prev_param_ref = context.insts().Get(prev_param_ref_id); if (new_param_ref.kind() != prev_param_ref.kind() || @@ -268,9 +270,79 @@ static auto CheckRedeclParams(Context& context, SemIRLoc new_decl_loc, return true; } +// Returns true if the two nodes represent the same syntax. +// TODO: Detect raw identifiers (will require token changes). +static auto IsNodeSyntaxEqual(Context& context, Parse::NodeId new_node_id, + Parse::NodeId prev_node_id) -> bool { + if (context.parse_tree().node_kind(new_node_id) != + context.parse_tree().node_kind(prev_node_id)) { + return false; + } + + // TODO: Should there be a trivial way to check if we need to check spellings? + // Identifiers and literals need their text checked for cross-file matching, + // but not intra-file. Keywords and operators shouldn't need the token text + // examined at all. + auto new_spelling = context.tokens().GetTokenText( + context.parse_tree().node_token(new_node_id)); + auto prev_spelling = context.tokens().GetTokenText( + context.parse_tree().node_token(prev_node_id)); + return new_spelling == prev_spelling; +} + +// Returns false if redeclaration parameter syntax doesn't match. +static auto CheckRedeclParamSyntax(Context& context, + Parse::NodeId new_first_param_node_id, + Parse::NodeId new_last_param_node_id, + Parse::NodeId prev_first_param_node_id, + Parse::NodeId prev_last_param_node_id) + -> bool { + // Parse nodes may not always be available to compare. + // TODO: Support cross-file syntax checks. Right now imports provide invalid + // nodes, and we'll need to follow the declaration to its original file to + // get the parse tree. + if (!new_first_param_node_id.is_valid() || + !prev_first_param_node_id.is_valid()) { + return true; + } + CARBON_CHECK(new_last_param_node_id.is_valid()) + << "new_last_param_node_id.is_valid should match " + "new_first_param_node_id.is_valid"; + CARBON_CHECK(prev_last_param_node_id.is_valid()) + << "prev_last_param_node_id.is_valid should match " + "prev_first_param_node_id.is_valid"; + + auto new_range = Parse::Tree::PostorderIterator::MakeRange( + new_first_param_node_id, new_last_param_node_id); + auto prev_range = Parse::Tree::PostorderIterator::MakeRange( + prev_first_param_node_id, prev_last_param_node_id); + + // zip is using the shortest range. If they differ in length, there should be + // some difference inside the range because the range includes parameter + // brackets. As a consequence, we don't explicitly handle different range + // sizes here. + for (auto [new_node_id, prev_node_id] : llvm::zip(new_range, prev_range)) { + if (!IsNodeSyntaxEqual(context, new_node_id, prev_node_id)) { + CARBON_DIAGNOSTIC(RedeclParamSyntaxDiffers, Error, + "Redeclaration syntax differs here."); + CARBON_DIAGNOSTIC(RedeclParamSyntaxPrevious, Note, + "Comparing with previous declaration here."); + context.emitter() + .Build(new_node_id, RedeclParamSyntaxDiffers) + .Note(prev_node_id, RedeclParamSyntaxPrevious) + .Emit(); + + return false; + } + } + + return true; +} + auto CheckRedeclParamsMatch(Context& context, const DeclParams& new_entity, const DeclParams& prev_entity, - Substitutions substitutions) -> bool { + Substitutions substitutions, bool check_syntax) + -> bool { if (EntityHasParamError(context, new_entity) || EntityHasParamError(context, prev_entity)) { return false; @@ -278,12 +350,21 @@ auto CheckRedeclParamsMatch(Context& context, const DeclParams& new_entity, if (!CheckRedeclParams(context, new_entity.loc, new_entity.implicit_param_refs_id, prev_entity.loc, prev_entity.implicit_param_refs_id, "implicit ", - substitutions) || - !CheckRedeclParams(context, new_entity.loc, new_entity.param_refs_id, + substitutions)) { + return false; + } + if (!CheckRedeclParams(context, new_entity.loc, new_entity.param_refs_id, prev_entity.loc, prev_entity.param_refs_id, "", substitutions)) { return false; } + if (check_syntax && + !CheckRedeclParamSyntax(context, new_entity.first_param_node_id, + new_entity.last_param_node_id, + prev_entity.first_param_node_id, + prev_entity.last_param_node_id)) { + return false; + } return true; } diff --git a/toolchain/check/merge.h b/toolchain/check/merge.h index d7a96b9a94d84..9496629e51008 100644 --- a/toolchain/check/merge.h +++ b/toolchain/check/merge.h @@ -44,20 +44,32 @@ auto ReplacePrevInstForMerge(Context& context, SemIR::NameScopeId scope_id, // Information about the parameters of a declaration, which is common across // different kinds of entity such as classes and functions. struct DeclParams { - template - explicit DeclParams(const Entity& entity) - : loc(entity.decl_id), - implicit_param_refs_id(entity.implicit_param_refs_id), - param_refs_id(entity.param_refs_id) {} + explicit DeclParams(const SemIR::EntityWithParamsBase& base) + : loc(base.decl_id), + first_param_node_id(base.first_param_node_id), + last_param_node_id(base.last_param_node_id), + implicit_param_refs_id(base.implicit_param_refs_id), + param_refs_id(base.param_refs_id) {} - DeclParams(SemIRLoc loc, SemIR::InstBlockId implicit_params_id, + DeclParams(SemIRLoc loc, Parse::NodeId first_param_node_id, + Parse::NodeId last_param_node_id, + SemIR::InstBlockId implicit_params_id, SemIR::InstBlockId params_id) : loc(loc), + first_param_node_id(first_param_node_id), + last_param_node_id(last_param_node_id), implicit_param_refs_id(implicit_params_id), param_refs_id(params_id) {} // The location of the declaration of the entity. SemIRLoc loc; + + // Parse tree bounds for the parameters, including both implicit and explicit + // parameters. These will be compared to match between declaration and + // definition. + Parse::NodeId first_param_node_id; + Parse::NodeId last_param_node_id; + // The implicit parameters of the entity. Can be Invalid if there is no // implicit parameter list. SemIR::InstBlockId implicit_param_refs_id; @@ -71,8 +83,8 @@ struct DeclParams { // returns false. auto CheckRedeclParamsMatch(Context& context, const DeclParams& new_entity, const DeclParams& prev_entity, - Substitutions substitutions = Substitutions()) - -> bool; + Substitutions substitutions = Substitutions(), + bool check_syntax = true) -> bool; } // namespace Carbon::Check diff --git a/toolchain/check/name_component.cpp b/toolchain/check/name_component.cpp index b5c785132af89..7c92754303cd5 100644 --- a/toolchain/check/name_component.cpp +++ b/toolchain/check/name_component.cpp @@ -9,15 +9,40 @@ namespace Carbon::Check { auto PopNameComponent(Context& context) -> NameComponent { + Parse::NodeId first_param_node_id = Parse::InvalidNodeId(); + Parse::NodeId last_param_node_id = Parse::InvalidNodeId(); + + // Explicit params. auto [params_loc_id, params_id] = context.node_stack().PopWithNodeIdIf(); + if (params_id) { + first_param_node_id = + context.node_stack() + .PopForSoloNodeId(); + last_param_node_id = params_loc_id; + } + + // Implicit params. auto [implicit_params_loc_id, implicit_params_id] = context.node_stack() .PopWithNodeIdIf(); + if (implicit_params_id) { + // Implicit params always come before explicit params. + first_param_node_id = + context.node_stack() + .PopForSoloNodeId(); + // Only use the end of implicit params if there weren't explicit params. + if (last_param_node_id.is_valid()) { + last_param_node_id = params_loc_id; + } + } + auto [name_loc_id, name_id] = context.node_stack().PopNameWithNodeId(); return { .name_loc_id = name_loc_id, .name_id = name_id, + .first_param_node_id = first_param_node_id, + .last_param_node_id = last_param_node_id, .implicit_params_loc_id = implicit_params_loc_id, .implicit_params_id = implicit_params_id.value_or(SemIR::InstBlockId::Invalid), diff --git a/toolchain/check/name_component.h b/toolchain/check/name_component.h index 4adecac7ce82c..e058e52eacf0d 100644 --- a/toolchain/check/name_component.h +++ b/toolchain/check/name_component.h @@ -20,6 +20,12 @@ struct NameComponent { Parse::NodeId name_loc_id; SemIR::NameId name_id; + // Parse tree bounds for the parameters, including both implicit and explicit + // parameters. These will be compared to match between declaration and + // definition. + Parse::NodeId first_param_node_id; + Parse::NodeId last_param_node_id; + // The implicit parameter list. Parse::NodeId implicit_params_loc_id; SemIR::InstBlockId implicit_params_id; diff --git a/toolchain/check/node_stack.cpp b/toolchain/check/node_stack.cpp index 13cb9f432e97a..8b28e0707d782 100644 --- a/toolchain/check/node_stack.cpp +++ b/toolchain/check/node_stack.cpp @@ -8,21 +8,28 @@ namespace Carbon::Check { -auto NodeStack::PrintForStackDump(llvm::raw_ostream& output) const -> void { +auto NodeStack::PrintForStackDump(SemIR::Formatter& formatter, int indent, + llvm::raw_ostream& output) const -> void { auto print_id = [&](Id id) { if constexpr (Kind == Id::Kind::None) { - output << " -> no value"; + output << "no value\n"; } else if constexpr (Kind == Id::Kind::Invalid) { CARBON_FATAL() << "Should not be in node stack"; + } else if constexpr (Kind == Id::KindFor()) { + output << "\n"; + formatter.PrintInst(id.As()>(), indent + 4, + output); } else { - output << " -> " << id.As(); + output << id.As() << "\n"; } }; + output.indent(indent); output << "NodeStack:\n"; for (auto [i, entry] : llvm::enumerate(stack_)) { auto node_kind = parse_tree_->node_kind(entry.node_id); - output << "\t" << i << ".\t" << node_kind; + output.indent(indent + 2); + output << i << ". " << node_kind << ": "; switch (node_kind) { #define CARBON_PARSE_NODE_KIND(Kind) \ case Parse::NodeKind::Kind: \ @@ -30,7 +37,6 @@ auto NodeStack::PrintForStackDump(llvm::raw_ostream& output) const -> void { break; #include "toolchain/parse/node_kind.def" } - output << "\n"; } } diff --git a/toolchain/check/node_stack.h b/toolchain/check/node_stack.h index 989f964c4c064..463979cb81053 100644 --- a/toolchain/check/node_stack.h +++ b/toolchain/check/node_stack.h @@ -11,6 +11,7 @@ #include "toolchain/parse/node_kind.h" #include "toolchain/parse/tree.h" #include "toolchain/parse/typed_nodes.h" +#include "toolchain/sem_ir/formatter.h" #include "toolchain/sem_ir/id_kind.h" #include "toolchain/sem_ir/ids.h" @@ -325,7 +326,8 @@ class NodeStack { } // Prints the stack for a stack dump. - auto PrintForStackDump(llvm::raw_ostream& output) const -> void; + auto PrintForStackDump(SemIR::Formatter& formatter, int indent, + llvm::raw_ostream& output) const -> void; auto empty() const -> bool { return stack_.empty(); } auto size() const -> size_t { return stack_.size(); } diff --git a/toolchain/check/operator.cpp b/toolchain/check/operator.cpp index 4bae63e6d0a2b..7aab3388a863e 100644 --- a/toolchain/check/operator.cpp +++ b/toolchain/check/operator.cpp @@ -38,10 +38,9 @@ static auto GetOperatorOpFunction(Context& context, Parse::AnyExprId node_id, return SemIR::InstId::Invalid; } - // TODO: For a parameterized interface, find the corresponding generic - // instance. + // TODO: For a parameterized interface, find the corresponding specific. LookupScope scope = {.name_scope_id = interface_scope_id, - .instance_id = SemIR::GenericInstanceId::Invalid}; + .specific_id = SemIR::SpecificId::Invalid}; // Lookup `Interface.Op`. auto op_ident_id = context.identifiers().Add(op.op_name); @@ -53,8 +52,8 @@ static auto GetOperatorOpFunction(Context& context, Parse::AnyExprId node_id, } // Look through import_refs and aliases. - auto op_const_id = GetConstantValueInInstance( - context.sem_ir(), op_result.instance_id, op_result.inst_id); + auto op_const_id = GetConstantValueInSpecific( + context.sem_ir(), op_result.specific_id, op_result.inst_id); auto op_id = context.constant_values().GetInstId(op_const_id); // We expect it to be an associated function. diff --git a/toolchain/check/param_and_arg_refs_stack.h b/toolchain/check/param_and_arg_refs_stack.h index aa91838f5b7bd..dbdfa516feddb 100644 --- a/toolchain/check/param_and_arg_refs_stack.h +++ b/toolchain/check/param_and_arg_refs_stack.h @@ -72,8 +72,9 @@ class ParamAndArgRefsStack { auto VerifyOnFinish() -> void { stack_.VerifyOnFinish(); } // Prints the stack for a stack dump. - auto PrintForStackDump(llvm::raw_ostream& output) const -> void { - return stack_.PrintForStackDump(output); + auto PrintForStackDump(SemIR::Formatter& formatter, int indent, + llvm::raw_ostream& output) const -> void { + return stack_.PrintForStackDump(formatter, indent, output); } private: diff --git a/toolchain/check/return.cpp b/toolchain/check/return.cpp index 9af50d88c9ab5..f02513711b5ec 100644 --- a/toolchain/check/return.cpp +++ b/toolchain/check/return.cpp @@ -56,10 +56,18 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node, Parse::NodeId name_node, SemIR::NameId name_id, Parse::NodeId type_node, SemIR::TypeId type_id) -> SemIR::InstId { - // A `returned var` requires an explicit return type. auto& function = GetCurrentFunction(context); - auto return_type_id = function.declared_return_type(context.sem_ir()); - if (!return_type_id.is_valid()) { + auto return_info = + SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), function); + if (!return_info.is_valid()) { + // We already diagnosed this when we started defining the function. Create a + // placeholder for error recovery. + return context.AddInst( + name_node, {.type_id = type_id, .name_id = name_id}); + } + + // A `returned var` requires an explicit return type. + if (!return_info.type_id.is_valid()) { CARBON_DIAGNOSTIC(ReturnedVarWithNoReturnType, Error, "Cannot declare a `returned var` in this function."); auto diag = @@ -70,21 +78,21 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node, } // The declared type of the var must match the return type of the function. - if (return_type_id != type_id) { + if (return_info.type_id != type_id) { CARBON_DIAGNOSTIC(ReturnedVarWrongType, Error, "Type `{0}` of `returned var` does not match " "return type of enclosing function.", SemIR::TypeId); auto diag = context.emitter().Build(type_node, ReturnedVarWrongType, type_id); - NoteReturnType(diag, function, return_type_id); + NoteReturnType(diag, function, return_info.type_id); diag.Emit(); return SemIR::InstId::BuiltinError; } // The variable aliases the return slot if there is one. If not, it has its // own storage. - if (function.has_return_slot()) { + if (return_info.has_return_slot()) { return function.return_storage_id; } return context.AddInst( @@ -106,7 +114,7 @@ auto RegisterReturnedVar(Context& context, SemIR::InstId bind_id) -> void { auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id) -> void { const auto& function = GetCurrentFunction(context); - auto return_type_id = function.declared_return_type(context.sem_ir()); + auto return_type_id = function.GetDeclaredReturnType(context.sem_ir()); if (return_type_id.is_valid()) { CARBON_DIAGNOSTIC(ReturnStatementMissingExpr, Error, @@ -124,9 +132,10 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id, const auto& function = GetCurrentFunction(context); auto returned_var_id = GetCurrentReturnedVar(context); auto return_slot_id = SemIR::InstId::Invalid; - auto return_type_id = function.declared_return_type(context.sem_ir()); + auto return_info = + SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), function); - if (!return_type_id.is_valid()) { + if (!return_info.type_id.is_valid()) { CARBON_DIAGNOSTIC( ReturnStatementDisallowExpr, Error, "No return expression should be provided in this context."); @@ -142,14 +151,16 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id, NoteReturnedVar(diag, returned_var_id); diag.Emit(); expr_id = SemIR::InstId::BuiltinError; - } else if (function.has_return_slot()) { + } else if (!return_info.is_valid()) { + // We already diagnosed that the return type is invalid. Don't try to + // convert to it. + expr_id = SemIR::InstId::BuiltinError; + } else if (return_info.has_return_slot()) { expr_id = Initialize(context, node_id, function.return_storage_id, expr_id); return_slot_id = function.return_storage_id; - } else if (function.return_slot == SemIR::Function::ReturnSlot::Error) { - // Don't produce a second error complaining the return type is incomplete. - expr_id = SemIR::InstId::BuiltinError; } else { - expr_id = ConvertToValueOfType(context, node_id, expr_id, return_type_id); + expr_id = + ConvertToValueOfType(context, node_id, expr_id, return_info.type_id); } context.AddInst( @@ -169,7 +180,8 @@ auto BuildReturnVar(Context& context, Parse::ReturnStatementId node_id) } auto return_slot_id = function.return_storage_id; - if (!function.has_return_slot()) { + if (!SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), function) + .has_return_slot()) { // If we don't have a return slot, we're returning by value. Convert to a // value expression. returned_var_id = ConvertToValueExpr(context, returned_var_id); diff --git a/toolchain/check/scope_stack.cpp b/toolchain/check/scope_stack.cpp index ebb94fb5279b7..8df737f512e3f 100644 --- a/toolchain/check/scope_stack.cpp +++ b/toolchain/check/scope_stack.cpp @@ -14,14 +14,21 @@ auto ScopeStack::VerifyOnFinish() -> void { } auto ScopeStack::Push(SemIR::InstId scope_inst_id, SemIR::NameScopeId scope_id, - SemIR::GenericInstanceId instance_id, + SemIR::SpecificId specific_id, bool lexical_lookup_has_load_error) -> void { + // If this scope doesn't have a specific of its own, it lives in the enclosing + // scope's specific, if any. + auto enclosing_specific_id = specific_id; + if (!specific_id.is_valid() && !scope_stack_.empty()) { + enclosing_specific_id = PeekSpecificId(); + } + compile_time_binding_stack_.PushArray(); scope_stack_.push_back( {.index = next_scope_index_, .scope_inst_id = scope_inst_id, .scope_id = scope_id, - .instance_id = instance_id, + .specific_id = enclosing_specific_id, .next_compile_time_bind_index = SemIR::CompileTimeBindIndex( compile_time_binding_stack_.all_values_size()), .lexical_lookup_has_load_error = @@ -29,13 +36,13 @@ auto ScopeStack::Push(SemIR::InstId scope_inst_id, SemIR::NameScopeId scope_id, if (scope_id.is_valid()) { non_lexical_scope_stack_.push_back({.scope_index = next_scope_index_, .name_scope_id = scope_id, - .instance_id = instance_id}); + .specific_id = enclosing_specific_id}); } else { // For lexical lookups, unqualified lookup doesn't know how to find the - // associated generic instance, so if we start adding lexical scopes with - // generic instances, we'll need to somehow track them in lookup. - CARBON_CHECK(!instance_id.is_valid()) - << "Lexical scope should not have an associated generic instance."; + // associated specific, so if we start adding lexical scopes associated with + // specifics, we'll need to somehow track them in lookup. + CARBON_CHECK(!specific_id.is_valid()) + << "Lexical scope should not have an associated specific."; } // TODO: Handle this case more gracefully. @@ -219,7 +226,7 @@ auto ScopeStack::Restore(SuspendedScope scope) -> void { non_lexical_scope_stack_.push_back( {.scope_index = scope.entry.index, .name_scope_id = scope.entry.scope_id, - .instance_id = scope.entry.instance_id}); + .specific_id = scope.entry.specific_id}); } scope_stack_.push_back(std::move(scope.entry)); } diff --git a/toolchain/check/scope_stack.h b/toolchain/check/scope_stack.h index a0a3fdea37242..6e87bc66536ca 100644 --- a/toolchain/check/scope_stack.h +++ b/toolchain/check/scope_stack.h @@ -47,8 +47,8 @@ class ScopeStack { // The corresponding name scope. SemIR::NameScopeId name_scope_id; - // The corresponding generic instance. - SemIR::GenericInstanceId instance_id; + // The corresponding specific. + SemIR::SpecificId specific_id; }; // Information about a scope that has been temporarily removed from the stack. @@ -58,11 +58,10 @@ class ScopeStack { // scopes. lexical_lookup_has_load_error is used to limit diagnostics when a // given namespace may contain a mix of both successful and failed name // imports. - auto Push( - SemIR::InstId scope_inst_id = SemIR::InstId::Invalid, - SemIR::NameScopeId scope_id = SemIR::NameScopeId::Invalid, - SemIR::GenericInstanceId instance_id = SemIR::GenericInstanceId::Invalid, - bool lexical_lookup_has_load_error = false) -> void; + auto Push(SemIR::InstId scope_inst_id = SemIR::InstId::Invalid, + SemIR::NameScopeId scope_id = SemIR::NameScopeId::Invalid, + SemIR::SpecificId specific_id = SemIR::SpecificId::Invalid, + bool lexical_lookup_has_load_error = false) -> void; // Pops the top scope from scope_stack_, cleaning up names from // lexical_lookup_. @@ -88,6 +87,14 @@ class ScopeStack { // there is no such instruction, such as for a block scope. auto PeekInstId() const -> SemIR::InstId { return Peek().scope_inst_id; } + // Returns the specific associated with the innermost enclosing scope that is + // associated with a specific. This will generally be the self specific of the + // innermost enclosing generic, as there is no way to enter any other specific + // scope. + auto PeekSpecificId() const -> SemIR::SpecificId { + return Peek().specific_id; + } + // Returns the current scope, if it is of the specified kind. Otherwise, // returns nullopt. template @@ -173,8 +180,8 @@ class ScopeStack { // The name scope associated with this entry, if any. SemIR::NameScopeId scope_id; - // The generic instance associated with this entry, if any. - SemIR::GenericInstanceId instance_id; + // The specific associated with this entry, if any. + SemIR::SpecificId specific_id; // The next compile-time binding index to allocate in this scope. SemIR::CompileTimeBindIndex next_compile_time_bind_index; diff --git a/toolchain/check/subst.cpp b/toolchain/check/subst.cpp index 57916002677d5..dffd5515848ef 100644 --- a/toolchain/check/subst.cpp +++ b/toolchain/check/subst.cpp @@ -82,11 +82,11 @@ static auto PushOperand(Context& context, Worklist& worklist, worklist.Push(context.types().GetInstId(type_id)); } break; - case SemIR::IdKind::For: - if (auto instance_id = static_cast(arg); - instance_id.is_valid()) { + case SemIR::IdKind::For: + if (auto specific_id = static_cast(arg); + specific_id.is_valid()) { PushOperand(context, worklist, SemIR::IdKind::For, - context.generic_instances().Get(instance_id).args_id.index); + context.specifics().Get(specific_id).args_id.index); } break; default: @@ -145,17 +145,17 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind, } return new_type_block.GetCanonical().index; } - case SemIR::IdKind::For: { - auto instance_id = SemIR::GenericInstanceId(arg); - if (!instance_id.is_valid()) { + case SemIR::IdKind::For: { + auto specific_id = SemIR::SpecificId(arg); + if (!specific_id.is_valid()) { return arg; } - auto& instance = context.generic_instances().Get(instance_id); + auto& specific = context.specifics().Get(specific_id); auto args_id = PopOperand(context, worklist, SemIR::IdKind::For, - instance.args_id.index); - return MakeGenericInstance(context, instance.generic_id, - SemIR::InstBlockId(args_id)) + specific.args_id.index); + return MakeSpecific(context, specific.generic_id, + SemIR::InstBlockId(args_id)) .index; } default: @@ -248,7 +248,7 @@ auto SubstInst(Context& context, SemIR::InstId inst_id, namespace { // Callbacks for performing substitution of a set of Substitutions into a // symbolic constant. -class SubstConstantCallbacks : public SubstInstCallbacks { +class SubstConstantCallbacks final : public SubstInstCallbacks { public: SubstConstantCallbacks(Context& context, Substitutions substitutions) : context_(context), substitutions_(substitutions) {} @@ -271,7 +271,7 @@ class SubstConstantCallbacks : public SubstInstCallbacks { // TODO: Consider building a hash map for substitutions. We might have a // lot of them. for (auto [bind_index, replacement_id] : substitutions_) { - if (context_.bind_names().Get(bind->bind_name_id).bind_index == + if (context_.entity_names().Get(bind->entity_name_id).bind_index == bind_index) { // This is the binding we're replacing. Perform substitution. inst_id = context_.constant_values().GetInstId(replacement_id); diff --git a/toolchain/check/testdata/alias/fail_bool_value.carbon b/toolchain/check/testdata/alias/fail_bool_value.carbon index 439fad059bd5d..f7befe5beca39 100644 --- a/toolchain/check/testdata/alias/fail_bool_value.carbon +++ b/toolchain/check/testdata/alias/fail_bool_value.carbon @@ -24,17 +24,26 @@ let a_test: bool = a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .a_test = @__global_init.%a_test // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc14: bool = bool_literal false [template = constants.%.1] // CHECK:STDOUT: %a: = bind_alias a, [template = ] // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] diff --git a/toolchain/check/testdata/alias/fail_builtins.carbon b/toolchain/check/testdata/alias/fail_builtins.carbon index ff34fe2978b4a..7b58bb3177cf8 100644 --- a/toolchain/check/testdata/alias/fail_builtins.carbon +++ b/toolchain/check/testdata/alias/fail_builtins.carbon @@ -30,18 +30,28 @@ alias b = bool; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %a: = bind_alias a, [template = ] // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] diff --git a/toolchain/check/testdata/alias/fail_control_flow.carbon b/toolchain/check/testdata/alias/fail_control_flow.carbon index 496d0986f4fb1..ba75eaca5e237 100644 --- a/toolchain/check/testdata/alias/fail_control_flow.carbon +++ b/toolchain/check/testdata/alias/fail_control_flow.carbon @@ -28,6 +28,18 @@ alias a = true or false; // CHECK:STDOUT: %.2: bool = bool_literal false [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace .inst+1, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: %.loc22: bool = block_arg [template = constants.%.1] // CHECK:STDOUT: %a: = bind_alias a, [template = ] diff --git a/toolchain/check/testdata/alias/no_prelude/export_name.carbon b/toolchain/check/testdata/alias/no_prelude/export_name.carbon index d81e4b5ac03b6..c26a4205c63d1 100644 --- a/toolchain/check/testdata/alias/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/alias/no_prelude/export_name.carbon @@ -98,9 +98,9 @@ var d: D* = &c; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+5, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//base, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//base, inst+5, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -125,9 +125,9 @@ var d: D* = &c; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+5, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+5, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -155,8 +155,8 @@ var d: D* = &c; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+8, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+8, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -191,7 +191,7 @@ var d: D* = &c; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+8, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//export, inst+8, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -224,9 +224,9 @@ var d: D* = &c; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+8, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir2, inst+8, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+8, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//export_orig, inst+8, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export_orig, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/alias/no_prelude/import.carbon b/toolchain/check/testdata/alias/no_prelude/import.carbon index 21b116cd83d8f..f6d4098f56ffc 100644 --- a/toolchain/check/testdata/alias/no_prelude/import.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import.carbon @@ -105,10 +105,10 @@ var c: () = a_alias_alias; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+5, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//class1, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//class1, inst+5, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//class1, inst+10, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//class1, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -142,9 +142,9 @@ var c: () = a_alias_alias; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+8, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//class2, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//class2, inst+15, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//class2, inst+8, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -202,8 +202,8 @@ var c: () = a_alias_alias; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+5, unloaded -// CHECK:STDOUT: %import_ref.2: ref %.1 = import_ref ir1, inst+12, loaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//var1, inst+5, unloaded +// CHECK:STDOUT: %import_ref.2: ref %.1 = import_ref Main//var1, inst+12, loaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -239,8 +239,8 @@ var c: () = a_alias_alias; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: ref %.1 = import_ref ir1, inst+6, loaded [template = ] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %import_ref.1: ref %.1 = import_ref Main//var2, inst+6, loaded [template = ] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//var2, inst+10, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/alias/no_prelude/import_access.carbon b/toolchain/check/testdata/alias/no_prelude/import_access.carbon index 448bb3b120a3f..c72f384034fe4 100644 --- a/toolchain/check/testdata/alias/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import_access.carbon @@ -85,9 +85,9 @@ var inst: Test.A = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir0, inst+5, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir0, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Test//def, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Test//def, inst+5, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Test//def, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -124,7 +124,7 @@ var inst: Test.A = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Test//def, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -151,14 +151,19 @@ var inst: Test.A = {}; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .inst = %inst // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} -// CHECK:STDOUT: %Test.ref: = name_ref Test, %Test [template = %Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %A.ref: = name_ref A, [template = ] // CHECK:STDOUT: %inst.var: ref = var inst // CHECK:STDOUT: %inst: ref = bind_name inst, %inst.var diff --git a/toolchain/check/testdata/alias/no_prelude/import_order.carbon b/toolchain/check/testdata/alias/no_prelude/import_order.carbon index 3da804665c5c9..4cf1ab26c76b2 100644 --- a/toolchain/check/testdata/alias/no_prelude/import_order.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import_order.carbon @@ -81,13 +81,13 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: type = import_ref ir1, inst+16, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir1, inst+18, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.7: %.4 = import_ref ir1, inst+7, loaded [template = %.1] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//a, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//a, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//a, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//a, inst+16, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.5: type = import_ref Main//a, inst+18, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.6 = import_ref Main//a, inst+2, unloaded +// CHECK:STDOUT: %import_ref.7: %.4 = import_ref Main//a, inst+7, loaded [template = %.1] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/array/array_in_place.carbon b/toolchain/check/testdata/array/array_in_place.carbon index 7e55375aac68e..41a9a51dda4cf 100644 --- a/toolchain/check/testdata/array/array_in_place.carbon +++ b/toolchain/check/testdata/array/array_in_place.carbon @@ -36,22 +36,26 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_17: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/array/array_vs_tuple.carbon b/toolchain/check/testdata/array/array_vs_tuple.carbon index 77a3ad9a1eb2b..66c77eb2bcbdc 100644 --- a/toolchain/check/testdata/array/array_vs_tuple.carbon +++ b/toolchain/check/testdata/array/array_vs_tuple.carbon @@ -36,19 +36,25 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/assign_return_value.carbon b/toolchain/check/testdata/array/assign_return_value.carbon index 9a356bc032ad1..4b1a4168432a5 100644 --- a/toolchain/check/testdata/array/assign_return_value.carbon +++ b/toolchain/check/testdata/array/assign_return_value.carbon @@ -34,18 +34,26 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_16.1: %.2 = tuple_literal (%int.make_type_32) diff --git a/toolchain/check/testdata/array/assign_var.carbon b/toolchain/check/testdata/array/assign_var.carbon index 59ab13c390e58..b1e19c20cafe6 100644 --- a/toolchain/check/testdata/array/assign_var.carbon +++ b/toolchain/check/testdata/array/assign_var.carbon @@ -30,20 +30,26 @@ var b: [i32; 3] = a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/array/base.carbon b/toolchain/check/testdata/array/base.carbon index c1be1e189ffd7..884886506bd40 100644 --- a/toolchain/check/testdata/array/base.carbon +++ b/toolchain/check/testdata/array/base.carbon @@ -45,19 +45,29 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/array/canonicalize_index.carbon b/toolchain/check/testdata/array/canonicalize_index.carbon index 458de1e6e03fc..44adce5a07b04 100644 --- a/toolchain/check/testdata/array/canonicalize_index.carbon +++ b/toolchain/check/testdata/array/canonicalize_index.carbon @@ -32,22 +32,27 @@ let b: [i32; 3]* = &a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .a = %a.loc13 // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/array/fail_bound_negative.carbon b/toolchain/check/testdata/array/fail_bound_negative.carbon index 8723e4649bbce..065151aefa5b0 100644 --- a/toolchain/check/testdata/array/fail_bound_negative.carbon +++ b/toolchain/check/testdata/array/fail_bound_negative.carbon @@ -28,19 +28,26 @@ var a: [i32; Negate(1)]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32.loc11_14 [template = i32] diff --git a/toolchain/check/testdata/array/fail_bound_overflow.carbon b/toolchain/check/testdata/array/fail_bound_overflow.carbon index 1f63502f37a08..205e058148dc4 100644 --- a/toolchain/check/testdata/array/fail_bound_overflow.carbon +++ b/toolchain/check/testdata/array/fail_bound_overflow.carbon @@ -36,17 +36,26 @@ var b: [1; 39999999999999999993]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc18_9.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc18_9.2: type = converted %int.make_type_32, %.loc18_9.1 [template = i32] diff --git a/toolchain/check/testdata/array/fail_incomplete_element.carbon b/toolchain/check/testdata/array/fail_incomplete_element.carbon index 1a2a222376e3f..e2699c3effe58 100644 --- a/toolchain/check/testdata/array/fail_incomplete_element.carbon +++ b/toolchain/check/testdata/array/fail_incomplete_element.carbon @@ -30,15 +30,26 @@ var p: Incomplete* = &a[0]; // CHECK:STDOUT: %.4: i32 = int_literal 0 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Incomplete = %Incomplete.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .p = %p // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} // CHECK:STDOUT: %Incomplete.ref.loc19: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] // CHECK:STDOUT: %.loc19_21: i32 = int_literal 1 [template = constants.%.1] diff --git a/toolchain/check/testdata/array/fail_invalid_type.carbon b/toolchain/check/testdata/array/fail_invalid_type.carbon index dbb5524b534cf..b4a6eef10c6b7 100644 --- a/toolchain/check/testdata/array/fail_invalid_type.carbon +++ b/toolchain/check/testdata/array/fail_invalid_type.carbon @@ -19,13 +19,24 @@ var a: [1; 1]; // CHECK:STDOUT: %.1: i32 = int_literal 1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc14_9: i32 = int_literal 1 [template = constants.%.1] // CHECK:STDOUT: %.loc14_12: i32 = int_literal 1 [template = constants.%.1] // CHECK:STDOUT: %.loc14_13: type = array_type %.loc14_12, [template = ] diff --git a/toolchain/check/testdata/array/fail_out_of_bound.carbon b/toolchain/check/testdata/array/fail_out_of_bound.carbon index d2da77bfe6091..9ad57ebaf3171 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound.carbon @@ -28,16 +28,25 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_14: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc14_9.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon index 39ef9c5cd5adb..aaee0b9f57f0c 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon @@ -33,18 +33,26 @@ var b: i32 = a[{.index = 3}.index]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 3 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/array/fail_type_mismatch.carbon b/toolchain/check/testdata/array/fail_type_mismatch.carbon index 3ef3679706d7d..9eba79f71b06b 100644 --- a/toolchain/check/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/array/fail_type_mismatch.carbon @@ -58,18 +58,22 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .t1 = %t1 // CHECK:STDOUT: .b = %b @@ -78,7 +82,6 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_14: i32 = int_literal 3 [template = constants.%.2] // CHECK:STDOUT: %.loc15_9.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] diff --git a/toolchain/check/testdata/array/function_param.carbon b/toolchain/check/testdata/array/function_param.carbon index 4a09481db68ad..9e4046a137a97 100644 --- a/toolchain/check/testdata/array/function_param.carbon +++ b/toolchain/check/testdata/array/function_param.carbon @@ -37,20 +37,26 @@ fn G() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17: i32 = int_literal 3 [template = constants.%.2] diff --git a/toolchain/check/testdata/array/generic_empty.carbon b/toolchain/check/testdata/array/generic_empty.carbon index 8dc53cd8be6a1..74e48924a2f5c 100644 --- a/toolchain/check/testdata/array/generic_empty.carbon +++ b/toolchain/check/testdata/array/generic_empty.carbon @@ -26,31 +26,53 @@ fn G(T:! type) { // CHECK:STDOUT: %array: %.3 = tuple_value () [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @G.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @G.%T (constants.%T)] +// CHECK:STDOUT: @G.%T.loc11: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @G.%T.1 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G(%T.loc11: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = array_type constants.%.2, @G.%T.1 (%T) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %array: @G.%.1 (%.3) = tuple_value () [symbolic = %array (constants.%array)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc11: type) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc13_16: i32 = int_literal 0 [template = constants.%.2] +// CHECK:STDOUT: %.loc13_17: type = array_type %.loc13_16, %T [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %arr.var: ref @G.%.1 (%.3) = var arr +// CHECK:STDOUT: %arr: ref @G.%.1 (%.3) = bind_name arr, %arr.var +// CHECK:STDOUT: %.loc13_22.1: %.1 = tuple_literal () +// CHECK:STDOUT: %.loc13_22.2: init @G.%.1 (%.3) = array_init () to %arr.var [symbolic = %array (constants.%array)] +// CHECK:STDOUT: %.loc13_23: init @G.%.1 (%.3) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)] +// CHECK:STDOUT: assign %arr.var, %.loc13_23 +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%T: type) -// CHECK:STDOUT: generic [%T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc13_16: i32 = int_literal 0 [template = constants.%.2] -// CHECK:STDOUT: %.loc13_17: type = array_type %.loc13_16, %T [symbolic = constants.%.3] -// CHECK:STDOUT: %arr.var: ref %.3 = var arr -// CHECK:STDOUT: %arr: ref %.3 = bind_name arr, %arr.var -// CHECK:STDOUT: %.loc13_22.1: %.1 = tuple_literal () -// CHECK:STDOUT: %.loc13_22.2: init %.3 = array_init () to %arr.var [symbolic = constants.%array] -// CHECK:STDOUT: %.loc13_23: init %.3 = converted %.loc13_22.1, %.loc13_22.2 [symbolic = constants.%array] -// CHECK:STDOUT: assign %arr.var, %.loc13_23 -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @G(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/index_not_literal.carbon b/toolchain/check/testdata/array/index_not_literal.carbon index 81495763f00d2..d5c55b78fffd0 100644 --- a/toolchain/check/testdata/array/index_not_literal.carbon +++ b/toolchain/check/testdata/array/index_not_literal.carbon @@ -30,18 +30,26 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 3 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/array/nine_elements.carbon b/toolchain/check/testdata/array/nine_elements.carbon index 05a5d03a2b889..7b8fb2fa215a1 100644 --- a/toolchain/check/testdata/array/nine_elements.carbon +++ b/toolchain/check/testdata/array/nine_elements.carbon @@ -33,16 +33,25 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 9 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/as/adapter_conversion.carbon b/toolchain/check/testdata/as/adapter_conversion.carbon index 0c98999569ab8..4ded9a1f9d2b4 100644 --- a/toolchain/check/testdata/as/adapter_conversion.carbon +++ b/toolchain/check/testdata/as/adapter_conversion.carbon @@ -122,13 +122,22 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .a_ref = %a_ref @@ -138,7 +147,6 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: .b_factory = %b_factory // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %A.ref.loc17: type = name_ref A, %A.decl [template = constants.%A] @@ -246,21 +254,27 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .n = @__global_init.%n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] @@ -312,9 +326,21 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %struct: %.1 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl @@ -322,7 +348,6 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: .d = @__global_init.%d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} @@ -391,20 +416,28 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .b_value = @__global_init.%b_value // CHECK:STDOUT: .b_init = %b_init // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %B.ref.loc13: type = name_ref B, %B.decl [template = constants.%B] @@ -493,18 +526,27 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B] diff --git a/toolchain/check/testdata/as/as_type.carbon b/toolchain/check/testdata/as/as_type.carbon index 08d292f3caf9a..192f9dec6aa66 100644 --- a/toolchain/check/testdata/as/as_type.carbon +++ b/toolchain/check/testdata/as/as_type.carbon @@ -21,17 +21,25 @@ let t: type = (i32, i32) as type; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .t = @__global_init.%t // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/as/basic.carbon b/toolchain/check/testdata/as/basic.carbon index e325391fc09c6..07c3601d7fa46 100644 --- a/toolchain/check/testdata/as/basic.carbon +++ b/toolchain/check/testdata/as/basic.carbon @@ -24,17 +24,25 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/as/fail_no_conversion.carbon b/toolchain/check/testdata/as/fail_no_conversion.carbon index ede3a142c0700..6ba3acc455fdf 100644 --- a/toolchain/check/testdata/as/fail_no_conversion.carbon +++ b/toolchain/check/testdata/as/fail_no_conversion.carbon @@ -26,19 +26,25 @@ let n: (i32, i32) = 1 as (i32, i32); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = @__global_init.%n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc14_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc14_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%int.make_type_32.loc14_9, %int.make_type_32.loc14_14) diff --git a/toolchain/check/testdata/as/fail_not_type.carbon b/toolchain/check/testdata/as/fail_not_type.carbon index e9e53aff1dbe2..a0f59fe3792a7 100644 --- a/toolchain/check/testdata/as/fail_not_type.carbon +++ b/toolchain/check/testdata/as/fail_not_type.carbon @@ -24,16 +24,25 @@ let n: i32 = 1 as 2; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = @__global_init.%n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_8.2: type = converted %int.make_type_32, %.loc14_8.1 [template = i32] diff --git a/toolchain/check/testdata/as/identity.carbon b/toolchain/check/testdata/as/identity.carbon index dac8a8477807a..2605182bcf0f2 100644 --- a/toolchain/check/testdata/as/identity.carbon +++ b/toolchain/check/testdata/as/identity.carbon @@ -46,9 +46,21 @@ fn Initializing() { // CHECK:STDOUT: %Initializing: %Initializing.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .X = %X.decl // CHECK:STDOUT: .Value = %Value.decl // CHECK:STDOUT: .Reference = %Reference.decl @@ -56,7 +68,6 @@ fn Initializing() { // CHECK:STDOUT: .Initializing = %Initializing.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} // CHECK:STDOUT: %Value.decl: %Value.type = fn_decl @Value [template = constants.%Value] { // CHECK:STDOUT: %X.ref.loc17: type = name_ref X, %X.decl [template = constants.%X] diff --git a/toolchain/check/testdata/basics/builtin_insts.carbon b/toolchain/check/testdata/basics/builtin_insts.carbon index 3a550706dd162..9b55fde946bff 100644 --- a/toolchain/check/testdata/basics/builtin_insts.carbon +++ b/toolchain/check/testdata/basics/builtin_insts.carbon @@ -18,13 +18,15 @@ // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {}} -// CHECK:STDOUT: bind_names: {} +// CHECK:STDOUT: entity_names: {} // CHECK:STDOUT: functions: {} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} -// CHECK:STDOUT: generic_instances: {} +// CHECK:STDOUT: specifics: {} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} // CHECK:STDOUT: type_blocks: {} // CHECK:STDOUT: insts: // CHECK:STDOUT: instTypeType: {kind: BuiltinInst, arg0: TypeType, type: typeTypeType} @@ -36,18 +38,19 @@ // CHECK:STDOUT: instBoundMethodType: {kind: BuiltinInst, arg0: BoundMethodType, type: typeTypeType} // CHECK:STDOUT: instNamespaceType: {kind: BuiltinInst, arg0: NamespaceType, type: typeTypeType} // CHECK:STDOUT: instWitnessType: {kind: BuiltinInst, arg0: WitnessType, type: typeTypeType} -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: instTypeType: template instTypeType -// CHECK:STDOUT: instError: template instError -// CHECK:STDOUT: instBoolType: template instBoolType -// CHECK:STDOUT: instIntType: template instIntType -// CHECK:STDOUT: instFloatType: template instFloatType -// CHECK:STDOUT: instStringType: template instStringType -// CHECK:STDOUT: instBoundMethodType: template instBoundMethodType -// CHECK:STDOUT: instNamespaceType: template instNamespaceType -// CHECK:STDOUT: instWitnessType: template instWitnessType -// CHECK:STDOUT: 'inst+0': template inst+0 +// CHECK:STDOUT: instTypeType: templateConstant(instTypeType) +// CHECK:STDOUT: instError: templateConstant(instError) +// CHECK:STDOUT: instBoolType: templateConstant(instBoolType) +// CHECK:STDOUT: instIntType: templateConstant(instIntType) +// CHECK:STDOUT: instFloatType: templateConstant(instFloatType) +// CHECK:STDOUT: instStringType: templateConstant(instStringType) +// CHECK:STDOUT: instBoundMethodType: templateConstant(instBoundMethodType) +// CHECK:STDOUT: instNamespaceType: templateConstant(instNamespaceType) +// CHECK:STDOUT: instWitnessType: templateConstant(instWitnessType) +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: symbolic_constants: {} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: {} diff --git a/toolchain/check/testdata/basics/builtin_types.carbon b/toolchain/check/testdata/basics/builtin_types.carbon index c399cfef7946f..3556e01d82a12 100644 --- a/toolchain/check/testdata/basics/builtin_types.carbon +++ b/toolchain/check/testdata/basics/builtin_types.carbon @@ -29,21 +29,30 @@ var test_type: type = i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_i32 = %test_i32 // CHECK:STDOUT: .test_f64 = %test_f64 // CHECK:STDOUT: .test_str = @__global_init.%test_str // CHECK:STDOUT: .test_type = %test_type // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_15.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc11_15.2: type = converted %int.make_type_32, %.loc11_15.1 [template = i32] diff --git a/toolchain/check/testdata/basics/fail_bad_run.carbon b/toolchain/check/testdata/basics/fail_bad_run.carbon index 80c1caa5ad061..9dd55dc5b36db 100644 --- a/toolchain/check/testdata/basics/fail_bad_run.carbon +++ b/toolchain/check/testdata/basics/fail_bad_run.carbon @@ -26,13 +26,24 @@ fn Run() -> String {} // CHECK:STDOUT: %.2: type = ptr_type String [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] { // CHECK:STDOUT: @Run.%return: ref String = var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/fail_bad_run_2.carbon b/toolchain/check/testdata/basics/fail_bad_run_2.carbon index 21509f5d35c3a..0d8ae5f3718a0 100644 --- a/toolchain/check/testdata/basics/fail_bad_run_2.carbon +++ b/toolchain/check/testdata/basics/fail_bad_run_2.carbon @@ -24,16 +24,25 @@ fn Run(n: i32) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/basics/fail_non_type_as_type.carbon b/toolchain/check/testdata/basics/fail_non_type_as_type.carbon index 3f31a9befa164..070a8a458079b 100644 --- a/toolchain/check/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/check/testdata/basics/fail_non_type_as_type.carbon @@ -19,13 +19,24 @@ var x: type = 42; // CHECK:STDOUT: %.1: i32 = int_literal 42 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %x.var: ref type = var x // CHECK:STDOUT: %x: ref type = bind_name x, %x.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon b/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon index db8d70d37d91b..ec6b0744341b6 100644 --- a/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon +++ b/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon @@ -49,16 +49,24 @@ let e: f64 = 5.0e39999999999999999993; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: .c = @__global_init.%c @@ -66,7 +74,6 @@ let e: f64 = 5.0e39999999999999999993; // CHECK:STDOUT: .e = @__global_init.%e // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32.loc15, %.loc15_8.1 [template = i32] diff --git a/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon index b1852c98ede6b..5fc7bc71a7f7d 100644 --- a/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon @@ -23,18 +23,26 @@ var y: i32 = x.b; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_8.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] // CHECK:STDOUT: %.loc11_8.2: type = converted %int.make_type_32.loc11, %.loc11_8.1 [template = i32] diff --git a/toolchain/check/testdata/basics/multifile.carbon b/toolchain/check/testdata/basics/multifile.carbon index 66aae5f872a7b..7369eb5422f0c 100644 --- a/toolchain/check/testdata/basics/multifile.carbon +++ b/toolchain/check/testdata/basics/multifile.carbon @@ -26,13 +26,24 @@ fn B() {} // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -49,13 +60,24 @@ fn B() {} // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon index 84cb5d5d5a78b..252df75a92d16 100644 --- a/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon @@ -34,31 +34,34 @@ fn B() { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+1}} -// CHECK:STDOUT: bind_names: {} +// CHECK:STDOUT: entity_names: {} // CHECK:STDOUT: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [block4]} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} -// CHECK:STDOUT: generic_instances: {} +// CHECK:STDOUT: specifics: {} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} -// CHECK:STDOUT: type1: {constant: template inst+2, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type2: {constant: template inst+3, value_rep: {kind: none, type: type2}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} +// CHECK:STDOUT: 'type(inst+2)': {kind: none, type: type(inst+3)} +// CHECK:STDOUT: 'type(inst+3)': {kind: none, type: type(inst+3)} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: insts: -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} -// CHECK:STDOUT: 'inst+1': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type1} -// CHECK:STDOUT: 'inst+2': {kind: FunctionType, arg0: function0, type: typeTypeType} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} +// CHECK:STDOUT: 'inst+1': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type(inst+2)} +// CHECK:STDOUT: 'inst+2': {kind: FunctionType, arg0: function0, arg1: specific, type: typeTypeType} // CHECK:STDOUT: 'inst+3': {kind: TupleType, arg0: type_block0, type: typeTypeType} -// CHECK:STDOUT: 'inst+4': {kind: StructValue, arg0: empty, type: type1} +// CHECK:STDOUT: 'inst+4': {kind: StructValue, arg0: empty, type: type(inst+2)} // CHECK:STDOUT: 'inst+5': {kind: Return} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+1': template inst+4 -// CHECK:STDOUT: 'inst+2': template inst+2 -// CHECK:STDOUT: 'inst+3': template inst+3 -// CHECK:STDOUT: 'inst+4': template inst+4 +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: 'inst+1': templateConstant(inst+4) +// CHECK:STDOUT: 'inst+2': templateConstant(inst+2) +// CHECK:STDOUT: 'inst+3': templateConstant(inst+3) +// CHECK:STDOUT: 'inst+4': templateConstant(inst+4) +// CHECK:STDOUT: symbolic_constants: {} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: @@ -103,57 +106,61 @@ fn B() { // CHECK:STDOUT: import_ir_inst1: {ir_id: ir1, inst_id: inst+1} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name1: inst+2, name0: inst+3}} -// CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} +// CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst+8}} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} // CHECK:STDOUT: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} -// CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1, param_refs: empty} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [block4]} +// CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} -// CHECK:STDOUT: generic_instances: {} +// CHECK:STDOUT: specifics: {} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} -// CHECK:STDOUT: type1: {constant: template inst+4, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type2: {constant: template inst+5, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type3: {constant: template inst+10, value_rep: {kind: none, type: type2}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} +// CHECK:STDOUT: 'type(inst+4)': {kind: none, type: type(inst+5)} +// CHECK:STDOUT: 'type(inst+5)': {kind: none, type: type(inst+5)} +// CHECK:STDOUT: 'type(inst+10)': {kind: none, type: type(inst+5)} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: insts: -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} // CHECK:STDOUT: 'inst+1': {kind: ImportDecl, arg0: name1} -// CHECK:STDOUT: 'inst+2': {kind: Namespace, arg0: name_scope1, arg1: inst+1, type: type0} -// CHECK:STDOUT: 'inst+3': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type1} -// CHECK:STDOUT: 'inst+4': {kind: FunctionType, arg0: function0, type: typeTypeType} +// CHECK:STDOUT: 'inst+2': {kind: Namespace, arg0: name_scope1, arg1: inst+1, type: type(instNamespaceType)} +// CHECK:STDOUT: 'inst+3': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type(inst+4)} +// CHECK:STDOUT: 'inst+4': {kind: FunctionType, arg0: function0, arg1: specific, type: typeTypeType} // CHECK:STDOUT: 'inst+5': {kind: TupleType, arg0: type_block0, type: typeTypeType} -// CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type1} -// CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type0} -// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: bind_name0, type: type3} -// CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type3} -// CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, type: typeTypeType} -// CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type3} -// CHECK:STDOUT: 'inst+12': {kind: NameRef, arg0: name1, arg1: inst+8, type: type3} -// CHECK:STDOUT: 'inst+13': {kind: Call, arg0: inst+12, arg1: block5, type: type2} +// CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type(inst+4)} +// CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type(instNamespaceType)} +// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst+10)} +// CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type(inst+10)} +// CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, arg1: specific, type: typeTypeType} +// CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type(inst+10)} +// CHECK:STDOUT: 'inst+12': {kind: NameRef, arg0: name1, arg1: inst+8, type: type(inst+10)} +// CHECK:STDOUT: 'inst+13': {kind: Call, arg0: inst+12, arg1: block5, type: type(inst+5)} // CHECK:STDOUT: 'inst+14': {kind: Return} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+2': template inst+2 -// CHECK:STDOUT: 'inst+3': template inst+6 -// CHECK:STDOUT: 'inst+4': template inst+4 -// CHECK:STDOUT: 'inst+5': template inst+5 -// CHECK:STDOUT: 'inst+6': template inst+6 -// CHECK:STDOUT: 'inst+7': template inst+2 -// CHECK:STDOUT: 'inst+8': template inst+11 -// CHECK:STDOUT: 'inst+9': template inst+11 -// CHECK:STDOUT: 'inst+10': template inst+10 -// CHECK:STDOUT: 'inst+11': template inst+11 -// CHECK:STDOUT: 'inst+12': template inst+11 +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: 'inst+2': templateConstant(inst+2) +// CHECK:STDOUT: 'inst+3': templateConstant(inst+6) +// CHECK:STDOUT: 'inst+4': templateConstant(inst+4) +// CHECK:STDOUT: 'inst+5': templateConstant(inst+5) +// CHECK:STDOUT: 'inst+6': templateConstant(inst+6) +// CHECK:STDOUT: 'inst+7': templateConstant(inst+2) +// CHECK:STDOUT: 'inst+8': templateConstant(inst+11) +// CHECK:STDOUT: 'inst+9': templateConstant(inst+11) +// CHECK:STDOUT: 'inst+10': templateConstant(inst+10) +// CHECK:STDOUT: 'inst+11': templateConstant(inst+11) +// CHECK:STDOUT: 'inst+12': templateConstant(inst+11) +// CHECK:STDOUT: symbolic_constants: {} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: // CHECK:STDOUT: 0: inst+3 // CHECK:STDOUT: import_refs: -// CHECK:STDOUT: 0: inst+8 +// CHECK:STDOUT: 0: inst+2 +// CHECK:STDOUT: 1: inst+8 // CHECK:STDOUT: global_init: {} // CHECK:STDOUT: block4: // CHECK:STDOUT: 0: inst+7 @@ -164,8 +171,7 @@ fn B() { // CHECK:STDOUT: block6: // CHECK:STDOUT: 0: inst+0 // CHECK:STDOUT: 1: inst+1 -// CHECK:STDOUT: 2: inst+2 -// CHECK:STDOUT: 3: inst+3 +// CHECK:STDOUT: 2: inst+3 // CHECK:STDOUT: ... // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon @@ -179,22 +185,25 @@ fn B() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir1, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %A: = namespace file.%A.import, [template] { +// CHECK:STDOUT: .A = %import_ref +// CHECK:STDOUT: import A//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %A.type = import_ref A//default, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %A +// CHECK:STDOUT: .A = imports.%A // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } // CHECK:STDOUT: %A.import = import A -// CHECK:STDOUT: %A: = namespace %A.import, [template] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %A.ref.loc6_3: = name_ref A, file.%A [template = file.%A] +// CHECK:STDOUT: %A.ref.loc6_3: = name_ref A, imports.%A [template = imports.%A] // CHECK:STDOUT: %A.ref.loc6_4: %A.type = name_ref A, imports.%import_ref [template = constants.%A] // CHECK:STDOUT: %A.call: init %.1 = call %A.ref.loc6_4() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon index 68453f0e290dc..770e5650d1f8c 100644 --- a/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon @@ -34,31 +34,34 @@ fn B() { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+1}} -// CHECK:STDOUT: bind_names: {} +// CHECK:STDOUT: entity_names: {} // CHECK:STDOUT: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [block4]} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} -// CHECK:STDOUT: generic_instances: {} +// CHECK:STDOUT: specifics: {} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} -// CHECK:STDOUT: type1: {constant: template inst+2, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type2: {constant: template inst+3, value_rep: {kind: none, type: type2}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} +// CHECK:STDOUT: 'type(inst+2)': {kind: none, type: type(inst+3)} +// CHECK:STDOUT: 'type(inst+3)': {kind: none, type: type(inst+3)} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: insts: -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} -// CHECK:STDOUT: 'inst+1': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type1} -// CHECK:STDOUT: 'inst+2': {kind: FunctionType, arg0: function0, type: typeTypeType} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} +// CHECK:STDOUT: 'inst+1': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type(inst+2)} +// CHECK:STDOUT: 'inst+2': {kind: FunctionType, arg0: function0, arg1: specific, type: typeTypeType} // CHECK:STDOUT: 'inst+3': {kind: TupleType, arg0: type_block0, type: typeTypeType} -// CHECK:STDOUT: 'inst+4': {kind: StructValue, arg0: empty, type: type1} +// CHECK:STDOUT: 'inst+4': {kind: StructValue, arg0: empty, type: type(inst+2)} // CHECK:STDOUT: 'inst+5': {kind: Return} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+1': template inst+4 -// CHECK:STDOUT: 'inst+2': template inst+2 -// CHECK:STDOUT: 'inst+3': template inst+3 -// CHECK:STDOUT: 'inst+4': template inst+4 +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: 'inst+1': templateConstant(inst+4) +// CHECK:STDOUT: 'inst+2': templateConstant(inst+2) +// CHECK:STDOUT: 'inst+3': templateConstant(inst+3) +// CHECK:STDOUT: 'inst+4': templateConstant(inst+4) +// CHECK:STDOUT: symbolic_constants: {} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: @@ -82,57 +85,61 @@ fn B() { // CHECK:STDOUT: import_ir_inst1: {ir_id: ir1, inst_id: inst+1} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name1: inst+2, name0: inst+3}} -// CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} +// CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst+8}} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} // CHECK:STDOUT: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} -// CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1, param_refs: empty} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [block4]} +// CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} -// CHECK:STDOUT: generic_instances: {} +// CHECK:STDOUT: specifics: {} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} -// CHECK:STDOUT: type1: {constant: template inst+4, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type2: {constant: template inst+5, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type3: {constant: template inst+10, value_rep: {kind: none, type: type2}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} +// CHECK:STDOUT: 'type(inst+4)': {kind: none, type: type(inst+5)} +// CHECK:STDOUT: 'type(inst+5)': {kind: none, type: type(inst+5)} +// CHECK:STDOUT: 'type(inst+10)': {kind: none, type: type(inst+5)} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: insts: -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} // CHECK:STDOUT: 'inst+1': {kind: ImportDecl, arg0: name1} -// CHECK:STDOUT: 'inst+2': {kind: Namespace, arg0: name_scope1, arg1: inst+1, type: type0} -// CHECK:STDOUT: 'inst+3': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type1} -// CHECK:STDOUT: 'inst+4': {kind: FunctionType, arg0: function0, type: typeTypeType} +// CHECK:STDOUT: 'inst+2': {kind: Namespace, arg0: name_scope1, arg1: inst+1, type: type(instNamespaceType)} +// CHECK:STDOUT: 'inst+3': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type(inst+4)} +// CHECK:STDOUT: 'inst+4': {kind: FunctionType, arg0: function0, arg1: specific, type: typeTypeType} // CHECK:STDOUT: 'inst+5': {kind: TupleType, arg0: type_block0, type: typeTypeType} -// CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type1} -// CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type0} -// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: bind_name0, type: type3} -// CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type3} -// CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, type: typeTypeType} -// CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type3} -// CHECK:STDOUT: 'inst+12': {kind: NameRef, arg0: name1, arg1: inst+8, type: type3} -// CHECK:STDOUT: 'inst+13': {kind: Call, arg0: inst+12, arg1: block5, type: type2} +// CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type(inst+4)} +// CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type(instNamespaceType)} +// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst+10)} +// CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type(inst+10)} +// CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, arg1: specific, type: typeTypeType} +// CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type(inst+10)} +// CHECK:STDOUT: 'inst+12': {kind: NameRef, arg0: name1, arg1: inst+8, type: type(inst+10)} +// CHECK:STDOUT: 'inst+13': {kind: Call, arg0: inst+12, arg1: block5, type: type(inst+5)} // CHECK:STDOUT: 'inst+14': {kind: Return} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+2': template inst+2 -// CHECK:STDOUT: 'inst+3': template inst+6 -// CHECK:STDOUT: 'inst+4': template inst+4 -// CHECK:STDOUT: 'inst+5': template inst+5 -// CHECK:STDOUT: 'inst+6': template inst+6 -// CHECK:STDOUT: 'inst+7': template inst+2 -// CHECK:STDOUT: 'inst+8': template inst+11 -// CHECK:STDOUT: 'inst+9': template inst+11 -// CHECK:STDOUT: 'inst+10': template inst+10 -// CHECK:STDOUT: 'inst+11': template inst+11 -// CHECK:STDOUT: 'inst+12': template inst+11 +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: 'inst+2': templateConstant(inst+2) +// CHECK:STDOUT: 'inst+3': templateConstant(inst+6) +// CHECK:STDOUT: 'inst+4': templateConstant(inst+4) +// CHECK:STDOUT: 'inst+5': templateConstant(inst+5) +// CHECK:STDOUT: 'inst+6': templateConstant(inst+6) +// CHECK:STDOUT: 'inst+7': templateConstant(inst+2) +// CHECK:STDOUT: 'inst+8': templateConstant(inst+11) +// CHECK:STDOUT: 'inst+9': templateConstant(inst+11) +// CHECK:STDOUT: 'inst+10': templateConstant(inst+10) +// CHECK:STDOUT: 'inst+11': templateConstant(inst+11) +// CHECK:STDOUT: 'inst+12': templateConstant(inst+11) +// CHECK:STDOUT: symbolic_constants: {} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: // CHECK:STDOUT: 0: inst+3 // CHECK:STDOUT: import_refs: -// CHECK:STDOUT: 0: inst+8 +// CHECK:STDOUT: 0: inst+2 +// CHECK:STDOUT: 1: inst+8 // CHECK:STDOUT: global_init: {} // CHECK:STDOUT: block4: // CHECK:STDOUT: 0: inst+7 @@ -143,6 +150,5 @@ fn B() { // CHECK:STDOUT: block6: // CHECK:STDOUT: 0: inst+0 // CHECK:STDOUT: 1: inst+1 -// CHECK:STDOUT: 2: inst+2 -// CHECK:STDOUT: 3: inst+3 +// CHECK:STDOUT: 2: inst+3 // CHECK:STDOUT: ... diff --git a/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon index d0a0342f9195a..a919288cc82aa 100644 --- a/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon @@ -24,77 +24,80 @@ fn Foo(n: ()) -> ((), ()) { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+14}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind} // CHECK:STDOUT: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: block4, return_storage: inst+13, return_slot: present, body: [block7]} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, return_storage: inst+13, body: [block7]} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} -// CHECK:STDOUT: generic_instances: {} +// CHECK:STDOUT: specifics: {} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} -// CHECK:STDOUT: type1: {constant: template inst+1, value_rep: {kind: none, type: type1}} -// CHECK:STDOUT: type2: {constant: template inst+8, value_rep: {kind: pointer, type: type4}} -// CHECK:STDOUT: type3: {constant: template inst+15, value_rep: {kind: none, type: type1}} -// CHECK:STDOUT: type4: {constant: template inst+17, value_rep: {kind: copy, type: type4}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} +// CHECK:STDOUT: 'type(inst+15)': {kind: none, type: type(inst+1)} +// CHECK:STDOUT: 'type(inst+1)': {kind: none, type: type(inst+1)} +// CHECK:STDOUT: 'type(inst+8)': {kind: pointer, type: type(inst+17)} +// CHECK:STDOUT: 'type(inst+17)': {kind: copy, type: type(inst+17)} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: type_block1: -// CHECK:STDOUT: 0: type1 -// CHECK:STDOUT: 1: type1 +// CHECK:STDOUT: 0: type(inst+1) +// CHECK:STDOUT: 1: type(inst+1) // CHECK:STDOUT: insts: -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} // CHECK:STDOUT: 'inst+1': {kind: TupleType, arg0: type_block0, type: typeTypeType} -// CHECK:STDOUT: 'inst+2': {kind: TupleLiteral, arg0: empty, type: type1} +// CHECK:STDOUT: 'inst+2': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} // CHECK:STDOUT: 'inst+3': {kind: Converted, arg0: inst+2, arg1: inst+1, type: typeTypeType} -// CHECK:STDOUT: 'inst+4': {kind: Param, arg0: name1, type: type1} -// CHECK:STDOUT: 'inst+5': {kind: BindName, arg0: bind_name0, arg1: inst+4, type: type1} -// CHECK:STDOUT: 'inst+6': {kind: TupleLiteral, arg0: empty, type: type1} -// CHECK:STDOUT: 'inst+7': {kind: TupleLiteral, arg0: empty, type: type1} +// CHECK:STDOUT: 'inst+4': {kind: Param, arg0: name1, type: type(inst+1)} +// CHECK:STDOUT: 'inst+5': {kind: BindName, arg0: entity_name0, arg1: inst+4, type: type(inst+1)} +// CHECK:STDOUT: 'inst+6': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} +// CHECK:STDOUT: 'inst+7': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} // CHECK:STDOUT: 'inst+8': {kind: TupleType, arg0: type_block1, type: typeTypeType} -// CHECK:STDOUT: 'inst+9': {kind: TupleLiteral, arg0: block5, type: type2} +// CHECK:STDOUT: 'inst+9': {kind: TupleLiteral, arg0: block5, type: type(inst+8)} // CHECK:STDOUT: 'inst+10': {kind: Converted, arg0: inst+6, arg1: inst+1, type: typeTypeType} // CHECK:STDOUT: 'inst+11': {kind: Converted, arg0: inst+7, arg1: inst+1, type: typeTypeType} // CHECK:STDOUT: 'inst+12': {kind: Converted, arg0: inst+9, arg1: inst+8, type: typeTypeType} -// CHECK:STDOUT: 'inst+13': {kind: VarStorage, arg0: nameReturnSlot, type: type2} -// CHECK:STDOUT: 'inst+14': {kind: FunctionDecl, arg0: function0, arg1: block6, type: type3} -// CHECK:STDOUT: 'inst+15': {kind: FunctionType, arg0: function0, type: typeTypeType} -// CHECK:STDOUT: 'inst+16': {kind: StructValue, arg0: empty, type: type3} -// CHECK:STDOUT: 'inst+17': {kind: PointerType, arg0: type2, type: typeTypeType} -// CHECK:STDOUT: 'inst+18': {kind: NameRef, arg0: name1, arg1: inst+5, type: type1} -// CHECK:STDOUT: 'inst+19': {kind: TupleLiteral, arg0: empty, type: type1} -// CHECK:STDOUT: 'inst+20': {kind: TupleLiteral, arg0: block8, type: type2} -// CHECK:STDOUT: 'inst+21': {kind: TupleAccess, arg0: inst+13, arg1: element0, type: type1} -// CHECK:STDOUT: 'inst+22': {kind: TupleInit, arg0: block9, arg1: inst+21, type: type1} -// CHECK:STDOUT: 'inst+23': {kind: TupleValue, arg0: block10, type: type1} -// CHECK:STDOUT: 'inst+24': {kind: Converted, arg0: inst+18, arg1: inst+22, type: type1} -// CHECK:STDOUT: 'inst+25': {kind: TupleAccess, arg0: inst+13, arg1: element1, type: type1} -// CHECK:STDOUT: 'inst+26': {kind: TupleInit, arg0: empty, arg1: inst+25, type: type1} -// CHECK:STDOUT: 'inst+27': {kind: Converted, arg0: inst+19, arg1: inst+26, type: type1} -// CHECK:STDOUT: 'inst+28': {kind: TupleInit, arg0: block11, arg1: inst+13, type: type2} -// CHECK:STDOUT: 'inst+29': {kind: TupleValue, arg0: block12, type: type2} -// CHECK:STDOUT: 'inst+30': {kind: Converted, arg0: inst+20, arg1: inst+28, type: type2} +// CHECK:STDOUT: 'inst+13': {kind: VarStorage, arg0: nameReturnSlot, type: type(inst+8)} +// CHECK:STDOUT: 'inst+14': {kind: FunctionDecl, arg0: function0, arg1: block6, type: type(inst+15)} +// CHECK:STDOUT: 'inst+15': {kind: FunctionType, arg0: function0, arg1: specific, type: typeTypeType} +// CHECK:STDOUT: 'inst+16': {kind: StructValue, arg0: empty, type: type(inst+15)} +// CHECK:STDOUT: 'inst+17': {kind: PointerType, arg0: type(inst+8), type: typeTypeType} +// CHECK:STDOUT: 'inst+18': {kind: NameRef, arg0: name1, arg1: inst+5, type: type(inst+1)} +// CHECK:STDOUT: 'inst+19': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} +// CHECK:STDOUT: 'inst+20': {kind: TupleLiteral, arg0: block8, type: type(inst+8)} +// CHECK:STDOUT: 'inst+21': {kind: TupleAccess, arg0: inst+13, arg1: element0, type: type(inst+1)} +// CHECK:STDOUT: 'inst+22': {kind: TupleInit, arg0: block9, arg1: inst+21, type: type(inst+1)} +// CHECK:STDOUT: 'inst+23': {kind: TupleValue, arg0: block10, type: type(inst+1)} +// CHECK:STDOUT: 'inst+24': {kind: Converted, arg0: inst+18, arg1: inst+22, type: type(inst+1)} +// CHECK:STDOUT: 'inst+25': {kind: TupleAccess, arg0: inst+13, arg1: element1, type: type(inst+1)} +// CHECK:STDOUT: 'inst+26': {kind: TupleInit, arg0: empty, arg1: inst+25, type: type(inst+1)} +// CHECK:STDOUT: 'inst+27': {kind: Converted, arg0: inst+19, arg1: inst+26, type: type(inst+1)} +// CHECK:STDOUT: 'inst+28': {kind: TupleInit, arg0: block11, arg1: inst+13, type: type(inst+8)} +// CHECK:STDOUT: 'inst+29': {kind: TupleValue, arg0: block12, type: type(inst+8)} +// CHECK:STDOUT: 'inst+30': {kind: Converted, arg0: inst+20, arg1: inst+28, type: type(inst+8)} // CHECK:STDOUT: 'inst+31': {kind: ReturnExpr, arg0: inst+30, arg1: inst+13} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+1': template inst+1 -// CHECK:STDOUT: 'inst+3': template inst+1 -// CHECK:STDOUT: 'inst+8': template inst+8 -// CHECK:STDOUT: 'inst+10': template inst+1 -// CHECK:STDOUT: 'inst+11': template inst+1 -// CHECK:STDOUT: 'inst+12': template inst+8 -// CHECK:STDOUT: 'inst+14': template inst+16 -// CHECK:STDOUT: 'inst+15': template inst+15 -// CHECK:STDOUT: 'inst+16': template inst+16 -// CHECK:STDOUT: 'inst+17': template inst+17 -// CHECK:STDOUT: 'inst+22': template inst+23 -// CHECK:STDOUT: 'inst+23': template inst+23 -// CHECK:STDOUT: 'inst+24': template inst+23 -// CHECK:STDOUT: 'inst+26': template inst+23 -// CHECK:STDOUT: 'inst+27': template inst+23 -// CHECK:STDOUT: 'inst+28': template inst+29 -// CHECK:STDOUT: 'inst+29': template inst+29 -// CHECK:STDOUT: 'inst+30': template inst+29 +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: 'inst+1': templateConstant(inst+1) +// CHECK:STDOUT: 'inst+3': templateConstant(inst+1) +// CHECK:STDOUT: 'inst+8': templateConstant(inst+8) +// CHECK:STDOUT: 'inst+10': templateConstant(inst+1) +// CHECK:STDOUT: 'inst+11': templateConstant(inst+1) +// CHECK:STDOUT: 'inst+12': templateConstant(inst+8) +// CHECK:STDOUT: 'inst+14': templateConstant(inst+16) +// CHECK:STDOUT: 'inst+15': templateConstant(inst+15) +// CHECK:STDOUT: 'inst+16': templateConstant(inst+16) +// CHECK:STDOUT: 'inst+17': templateConstant(inst+17) +// CHECK:STDOUT: 'inst+22': templateConstant(inst+23) +// CHECK:STDOUT: 'inst+23': templateConstant(inst+23) +// CHECK:STDOUT: 'inst+24': templateConstant(inst+23) +// CHECK:STDOUT: 'inst+26': templateConstant(inst+23) +// CHECK:STDOUT: 'inst+27': templateConstant(inst+23) +// CHECK:STDOUT: 'inst+28': templateConstant(inst+29) +// CHECK:STDOUT: 'inst+29': templateConstant(inst+29) +// CHECK:STDOUT: 'inst+30': templateConstant(inst+29) +// CHECK:STDOUT: symbolic_constants: {} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: diff --git a/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon index d620a6ae3cf63..d8066b1372111 100644 --- a/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon @@ -24,85 +24,99 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+16}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind0} -// CHECK:STDOUT: bind_name1: {name: name2, parent_scope: name_scope, index: comp_time_bind} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind0} +// CHECK:STDOUT: entity_name1: {name: name2, parent_scope: name_scope, index: comp_time_bind} // CHECK:STDOUT: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: block5, return_storage: inst+15, return_slot: present, body: [block11]} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, return_storage: inst+15, body: [block12]} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: // CHECK:STDOUT: generic0: {decl: inst+16, bindings: block8} -// CHECK:STDOUT: generic_instances: -// CHECK:STDOUT: genericInstance0: {generic: generic0, args: block10} +// CHECK:STDOUT: specifics: +// CHECK:STDOUT: specific0: {generic: generic0, args: block10} // CHECK:STDOUT: types: -// CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}} -// CHECK:STDOUT: type1: {constant: symbolic 0, value_rep: {kind: copy, type: type1}} -// CHECK:STDOUT: type2: {constant: template inst+8, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type3: {constant: template inst+10, value_rep: {kind: unknown, type: type}} -// CHECK:STDOUT: type4: {constant: symbolic 1, value_rep: {kind: pointer, type: type8}} -// CHECK:STDOUT: type5: {constant: symbolic 2, value_rep: {kind: copy, type: type5}} -// CHECK:STDOUT: type6: {constant: symbolic 3, value_rep: {kind: unknown, type: type}} -// CHECK:STDOUT: type7: {constant: template inst+17, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type8: {constant: symbolic 4, value_rep: {kind: copy, type: type8}} +// CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType} +// CHECK:STDOUT: typeError: {kind: copy, type: typeError} +// CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)} +// CHECK:STDOUT: 'type(inst+19)': {kind: none, type: type(inst+8)} +// CHECK:STDOUT: 'type(inst+8)': {kind: none, type: type(inst+8)} +// CHECK:STDOUT: 'type(symbolicConstant0)': {kind: copy, type: type(symbolicConstant0)} +// CHECK:STDOUT: 'type(symbolicConstant1)': {kind: pointer, type: type(symbolicConstant4)} +// CHECK:STDOUT: 'type(symbolicConstant4)': {kind: copy, type: type(symbolicConstant4)} +// CHECK:STDOUT: 'type(symbolicConstant2)': {kind: copy, type: type(symbolicConstant2)} +// CHECK:STDOUT: 'type(symbolicConstant3)': {kind: pointer, type: type(symbolicConstant4)} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: type_block1: // CHECK:STDOUT: 0: typeTypeType -// CHECK:STDOUT: 1: type2 +// CHECK:STDOUT: 1: type(inst+8) // CHECK:STDOUT: type_block2: -// CHECK:STDOUT: 0: type1 -// CHECK:STDOUT: 1: type2 +// CHECK:STDOUT: 0: type(symbolicConstant0) +// CHECK:STDOUT: 1: type(inst+8) +// CHECK:STDOUT: type_block3: +// CHECK:STDOUT: 0: type(symbolicConstant2) +// CHECK:STDOUT: 1: type(inst+8) // CHECK:STDOUT: insts: -// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type0} +// CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} // CHECK:STDOUT: 'inst+1': {kind: Param, arg0: name1, type: typeTypeType} -// CHECK:STDOUT: 'inst+2': {kind: BindSymbolicName, arg0: bind_name0, arg1: inst+1, type: typeTypeType} -// CHECK:STDOUT: 'inst+3': {kind: BindSymbolicName, arg0: bind_name0, arg1: inst, type: typeTypeType} +// CHECK:STDOUT: 'inst+2': {kind: BindSymbolicName, arg0: entity_name0, arg1: inst+1, type: typeTypeType} +// CHECK:STDOUT: 'inst+3': {kind: BindSymbolicName, arg0: entity_name0, arg1: inst, type: typeTypeType} // CHECK:STDOUT: 'inst+4': {kind: NameRef, arg0: name1, arg1: inst+2, type: typeTypeType} -// CHECK:STDOUT: 'inst+5': {kind: Param, arg0: name2, type: type5} -// CHECK:STDOUT: 'inst+6': {kind: BindName, arg0: bind_name1, arg1: inst+5, type: type5} +// CHECK:STDOUT: 'inst+5': {kind: Param, arg0: name2, type: type(symbolicConstant2)} +// CHECK:STDOUT: 'inst+6': {kind: BindName, arg0: entity_name1, arg1: inst+5, type: type(symbolicConstant2)} // CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: typeTypeType} // CHECK:STDOUT: 'inst+8': {kind: TupleType, arg0: type_block0, type: typeTypeType} -// CHECK:STDOUT: 'inst+9': {kind: TupleLiteral, arg0: empty, type: type2} +// CHECK:STDOUT: 'inst+9': {kind: TupleLiteral, arg0: empty, type: type(inst+8)} // CHECK:STDOUT: 'inst+10': {kind: TupleType, arg0: type_block1, type: typeTypeType} -// CHECK:STDOUT: 'inst+11': {kind: TupleLiteral, arg0: block6, type: type3} +// CHECK:STDOUT: 'inst+11': {kind: TupleLiteral, arg0: block6, type: type(inst+10)} // CHECK:STDOUT: 'inst+12': {kind: Converted, arg0: inst+9, arg1: inst+8, type: typeTypeType} // CHECK:STDOUT: 'inst+13': {kind: TupleType, arg0: type_block2, type: typeTypeType} // CHECK:STDOUT: 'inst+14': {kind: Converted, arg0: inst+11, arg1: inst+13, type: typeTypeType} -// CHECK:STDOUT: 'inst+15': {kind: VarStorage, arg0: nameReturnSlot, type: type4} -// CHECK:STDOUT: 'inst+16': {kind: FunctionDecl, arg0: function0, arg1: block7, type: type7} -// CHECK:STDOUT: 'inst+17': {kind: FunctionType, arg0: function0, type: typeTypeType} -// CHECK:STDOUT: 'inst+18': {kind: StructValue, arg0: empty, type: type7} -// CHECK:STDOUT: 'inst+19': {kind: PointerType, arg0: type4, type: typeTypeType} -// CHECK:STDOUT: 'inst+20': {kind: NameRef, arg0: name2, arg1: inst+6, type: type1} -// CHECK:STDOUT: 'inst+21': {kind: TupleLiteral, arg0: empty, type: type2} -// CHECK:STDOUT: 'inst+22': {kind: TupleLiteral, arg0: block12, type: type4} -// CHECK:STDOUT: 'inst+23': {kind: TupleAccess, arg0: inst+15, arg1: element0, type: type1} -// CHECK:STDOUT: 'inst+24': {kind: InitializeFrom, arg0: inst+20, arg1: inst+23, type: type1} -// CHECK:STDOUT: 'inst+25': {kind: TupleAccess, arg0: inst+15, arg1: element1, type: type2} -// CHECK:STDOUT: 'inst+26': {kind: TupleInit, arg0: empty, arg1: inst+25, type: type2} -// CHECK:STDOUT: 'inst+27': {kind: TupleValue, arg0: block14, type: type2} -// CHECK:STDOUT: 'inst+28': {kind: Converted, arg0: inst+21, arg1: inst+26, type: type2} -// CHECK:STDOUT: 'inst+29': {kind: TupleInit, arg0: block13, arg1: inst+15, type: type4} -// CHECK:STDOUT: 'inst+30': {kind: Converted, arg0: inst+22, arg1: inst+29, type: type4} -// CHECK:STDOUT: 'inst+31': {kind: ReturnExpr, arg0: inst+30, arg1: inst+15} +// CHECK:STDOUT: 'inst+15': {kind: VarStorage, arg0: nameReturnSlot, type: type(symbolicConstant3)} +// CHECK:STDOUT: 'inst+16': {kind: FunctionDecl, arg0: function0, arg1: block7, type: type(inst+19)} +// CHECK:STDOUT: 'inst+17': {kind: BindSymbolicName, arg0: entity_name0, arg1: inst, type: typeTypeType} +// CHECK:STDOUT: 'inst+18': {kind: TupleType, arg0: type_block3, type: typeTypeType} +// CHECK:STDOUT: 'inst+19': {kind: FunctionType, arg0: function0, arg1: specific, type: typeTypeType} +// CHECK:STDOUT: 'inst+20': {kind: StructValue, arg0: empty, type: type(inst+19)} +// CHECK:STDOUT: 'inst+21': {kind: PointerType, arg0: type(symbolicConstant1), type: typeTypeType} +// CHECK:STDOUT: 'inst+22': {kind: NameRef, arg0: name2, arg1: inst+6, type: type(symbolicConstant2)} +// CHECK:STDOUT: 'inst+23': {kind: TupleLiteral, arg0: empty, type: type(inst+8)} +// CHECK:STDOUT: 'inst+24': {kind: TupleLiteral, arg0: block13, type: type(symbolicConstant3)} +// CHECK:STDOUT: 'inst+25': {kind: TupleAccess, arg0: inst+15, arg1: element0, type: type(symbolicConstant2)} +// CHECK:STDOUT: 'inst+26': {kind: InitializeFrom, arg0: inst+22, arg1: inst+25, type: type(symbolicConstant2)} +// CHECK:STDOUT: 'inst+27': {kind: TupleAccess, arg0: inst+15, arg1: element1, type: type(inst+8)} +// CHECK:STDOUT: 'inst+28': {kind: TupleInit, arg0: empty, arg1: inst+27, type: type(inst+8)} +// CHECK:STDOUT: 'inst+29': {kind: TupleValue, arg0: block15, type: type(inst+8)} +// CHECK:STDOUT: 'inst+30': {kind: Converted, arg0: inst+23, arg1: inst+28, type: type(inst+8)} +// CHECK:STDOUT: 'inst+31': {kind: TupleInit, arg0: block14, arg1: inst+15, type: type(symbolicConstant3)} +// CHECK:STDOUT: 'inst+32': {kind: Converted, arg0: inst+24, arg1: inst+31, type: type(symbolicConstant3)} +// CHECK:STDOUT: 'inst+33': {kind: ReturnExpr, arg0: inst+32, arg1: inst+15} // CHECK:STDOUT: constant_values: -// CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+2': symbolic 2 -// CHECK:STDOUT: 'inst+3': symbolic 0 -// CHECK:STDOUT: 'inst+4': symbolic 2 -// CHECK:STDOUT: 'inst+7': symbolic 2 -// CHECK:STDOUT: 'inst+8': template inst+8 -// CHECK:STDOUT: 'inst+10': template inst+10 -// CHECK:STDOUT: 'inst+12': template inst+8 -// CHECK:STDOUT: 'inst+13': symbolic 1 -// CHECK:STDOUT: 'inst+14': symbolic 3 -// CHECK:STDOUT: 'inst+16': template inst+18 -// CHECK:STDOUT: 'inst+17': template inst+17 -// CHECK:STDOUT: 'inst+18': template inst+18 -// CHECK:STDOUT: 'inst+19': symbolic 4 -// CHECK:STDOUT: 'inst+26': template inst+27 -// CHECK:STDOUT: 'inst+27': template inst+27 -// CHECK:STDOUT: 'inst+28': template inst+27 +// CHECK:STDOUT: 'inst+0': templateConstant(inst+0) +// CHECK:STDOUT: 'inst+2': symbolicConstant2 +// CHECK:STDOUT: 'inst+3': symbolicConstant0 +// CHECK:STDOUT: 'inst+4': symbolicConstant2 +// CHECK:STDOUT: 'inst+7': symbolicConstant2 +// CHECK:STDOUT: 'inst+8': templateConstant(inst+8) +// CHECK:STDOUT: 'inst+10': templateConstant(inst+10) +// CHECK:STDOUT: 'inst+12': templateConstant(inst+8) +// CHECK:STDOUT: 'inst+13': symbolicConstant1 +// CHECK:STDOUT: 'inst+14': symbolicConstant3 +// CHECK:STDOUT: 'inst+16': templateConstant(inst+20) +// CHECK:STDOUT: 'inst+17': symbolicConstant2 +// CHECK:STDOUT: 'inst+18': symbolicConstant3 +// CHECK:STDOUT: 'inst+19': templateConstant(inst+19) +// CHECK:STDOUT: 'inst+20': templateConstant(inst+20) +// CHECK:STDOUT: 'inst+21': symbolicConstant4 +// CHECK:STDOUT: 'inst+28': templateConstant(inst+29) +// CHECK:STDOUT: 'inst+29': templateConstant(inst+29) +// CHECK:STDOUT: 'inst+30': templateConstant(inst+29) +// CHECK:STDOUT: symbolic_constants: +// CHECK:STDOUT: symbolicConstant0: {inst: inst+3, generic: generic, index: genericInst} +// CHECK:STDOUT: symbolicConstant1: {inst: inst+13, generic: generic, index: genericInst} +// CHECK:STDOUT: symbolicConstant2: {inst: inst+3, generic: generic0, index: genericInstInDecl0} +// CHECK:STDOUT: symbolicConstant3: {inst: inst+13, generic: generic0, index: genericInstInDecl1} +// CHECK:STDOUT: symbolicConstant4: {inst: inst+21, generic: generic, index: genericInst} // CHECK:STDOUT: inst_blocks: // CHECK:STDOUT: empty: {} // CHECK:STDOUT: exports: @@ -131,30 +145,33 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: block8: // CHECK:STDOUT: 0: inst+2 // CHECK:STDOUT: block9: -// CHECK:STDOUT: 0: inst+2 -// CHECK:STDOUT: 1: inst+14 +// CHECK:STDOUT: 0: inst+17 +// CHECK:STDOUT: 1: inst+18 // CHECK:STDOUT: block10: // CHECK:STDOUT: 0: inst+3 // CHECK:STDOUT: block11: -// CHECK:STDOUT: 0: inst+20 -// CHECK:STDOUT: 1: inst+21 -// CHECK:STDOUT: 2: inst+22 -// CHECK:STDOUT: 3: inst+23 -// CHECK:STDOUT: 4: inst+24 -// CHECK:STDOUT: 5: inst+25 -// CHECK:STDOUT: 6: inst+26 -// CHECK:STDOUT: 7: inst+28 -// CHECK:STDOUT: 8: inst+29 -// CHECK:STDOUT: 9: inst+30 -// CHECK:STDOUT: 10: inst+31 +// CHECK:STDOUT: 0: inst+3 +// CHECK:STDOUT: 1: inst+13 // CHECK:STDOUT: block12: -// CHECK:STDOUT: 0: inst+20 -// CHECK:STDOUT: 1: inst+21 +// CHECK:STDOUT: 0: inst+22 +// CHECK:STDOUT: 1: inst+23 +// CHECK:STDOUT: 2: inst+24 +// CHECK:STDOUT: 3: inst+25 +// CHECK:STDOUT: 4: inst+26 +// CHECK:STDOUT: 5: inst+27 +// CHECK:STDOUT: 6: inst+28 +// CHECK:STDOUT: 7: inst+30 +// CHECK:STDOUT: 8: inst+31 +// CHECK:STDOUT: 9: inst+32 +// CHECK:STDOUT: 10: inst+33 // CHECK:STDOUT: block13: -// CHECK:STDOUT: 0: inst+24 -// CHECK:STDOUT: 1: inst+28 -// CHECK:STDOUT: block14: {} -// CHECK:STDOUT: block15: +// CHECK:STDOUT: 0: inst+22 +// CHECK:STDOUT: 1: inst+23 +// CHECK:STDOUT: block14: +// CHECK:STDOUT: 0: inst+26 +// CHECK:STDOUT: 1: inst+30 +// CHECK:STDOUT: block15: {} +// CHECK:STDOUT: block16: // CHECK:STDOUT: 0: inst+0 // CHECK:STDOUT: 1: inst+16 // CHECK:STDOUT: ... diff --git a/toolchain/check/testdata/basics/no_prelude/verbose.carbon b/toolchain/check/testdata/basics/no_prelude/verbose.carbon index 13bc20f1ce830..9a101360cdc01 100644 --- a/toolchain/check/testdata/basics/no_prelude/verbose.carbon +++ b/toolchain/check/testdata/basics/no_prelude/verbose.carbon @@ -9,7 +9,7 @@ // SET-CHECK-SUBSET // CHECK:STDERR: Node Push 0: FunctionIntroducer -> // CHECK:STDERR: AddPlaceholderInst: {kind: FunctionDecl, arg0: function, arg1: empty} -// CHECK:STDERR: ReplaceInst: inst+{{[0-9]+}} -> {kind: FunctionDecl, arg0: function{{[0-9]+}}, arg1: empty, type: type{{[0-9]+}}} +// CHECK:STDERR: ReplaceInst: inst+{{[0-9]+}} -> {kind: FunctionDecl, arg0: function{{[0-9]+}}, arg1: empty, type: type(inst+{{[0-9]+}})} // CHECK:STDERR: inst_block_stack_ Push 1 // CHECK:STDERR: AddInst: {kind: Return} // CHECK:STDERR: inst_block_stack_ Pop 1: block{{[0-9]+}} diff --git a/toolchain/check/testdata/basics/numeric_literals.carbon b/toolchain/check/testdata/basics/numeric_literals.carbon index 0a616792eb06a..89ce18b69138d 100644 --- a/toolchain/check/testdata/basics/numeric_literals.carbon +++ b/toolchain/check/testdata/basics/numeric_literals.carbon @@ -67,17 +67,27 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/parens.carbon b/toolchain/check/testdata/basics/parens.carbon index 18f22023af8cd..9e163a7322749 100644 --- a/toolchain/check/testdata/basics/parens.carbon +++ b/toolchain/check/testdata/basics/parens.carbon @@ -22,18 +22,26 @@ var b: i32 = ((2)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_8.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] // CHECK:STDOUT: %.loc11_8.2: type = converted %int.make_type_32.loc11, %.loc11_8.1 [template = i32] diff --git a/toolchain/check/testdata/basics/run.carbon b/toolchain/check/testdata/basics/run.carbon index 84a53f7c4cc75..a8eeded6cb04d 100644 --- a/toolchain/check/testdata/basics/run.carbon +++ b/toolchain/check/testdata/basics/run.carbon @@ -18,13 +18,24 @@ fn Run() {} // CHECK:STDOUT: %Run: %Run.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/run_i32.carbon b/toolchain/check/testdata/basics/run_i32.carbon index 41fb4f450da0d..f0b6c64491a1d 100644 --- a/toolchain/check/testdata/basics/run_i32.carbon +++ b/toolchain/check/testdata/basics/run_i32.carbon @@ -22,16 +22,25 @@ fn Run() -> i32 { return 0; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/basics/type_literals.carbon b/toolchain/check/testdata/basics/type_literals.carbon index 4376c46637060..d638242131700 100644 --- a/toolchain/check/testdata/basics/type_literals.carbon +++ b/toolchain/check/testdata/basics/type_literals.carbon @@ -126,20 +126,27 @@ var test_f128: f128; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.2: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.3: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int.type = import_ref Core//prelude/types, inst+14, loaded [template = constants.%Int] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_i8 = %test_i8 // CHECK:STDOUT: .test_i16 = %test_i16 // CHECK:STDOUT: .test_i64 = %test_i64 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc3_14.1: i32 = int_literal 8 [template = constants.%.1] // CHECK:STDOUT: %int.make_type_signed.loc3: init type = call constants.%Int(%.loc3_14.1) [template = constants.%.3] // CHECK:STDOUT: %.loc3_14.2: type = value_of_initializer %int.make_type_signed.loc3 [template = constants.%.3] @@ -176,15 +183,22 @@ var test_f128: f128; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.2: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.3: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.4: %Int.type = import_ref ir3, inst+14, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int.type = import_ref Core//prelude/types, inst+14, loaded [template = constants.%Int] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_i0 = %test_i0 // CHECK:STDOUT: .test_i1 = %test_i1 // CHECK:STDOUT: .test_i15 = %test_i15 @@ -192,7 +206,6 @@ var test_f128: f128; // CHECK:STDOUT: .test_i10000000000000000000 = %test_i10000000000000000000 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %i0.ref: = name_ref i0, [template = ] // CHECK:STDOUT: %test_i0.var: ref = var test_i0 // CHECK:STDOUT: %test_i0: ref = bind_name test_i0, %test_i0.var @@ -238,20 +251,27 @@ var test_f128: f128; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.2: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.3: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .UInt = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %UInt.type = import_ref Core//prelude/types, inst+23, loaded [template = constants.%UInt] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_u8 = %test_u8 // CHECK:STDOUT: .test_u16 = %test_u16 // CHECK:STDOUT: .test_u64 = %test_u64 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc3_14.1: i32 = int_literal 8 [template = constants.%.1] // CHECK:STDOUT: %int.make_type_unsigned.loc3: init type = call constants.%UInt(%.loc3_14.1) [template = constants.%.3] // CHECK:STDOUT: %.loc3_14.2: type = value_of_initializer %int.make_type_unsigned.loc3 [template = constants.%.3] @@ -288,15 +308,22 @@ var test_f128: f128; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.2: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.3: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.4: %UInt.type = import_ref ir3, inst+23, loaded [template = constants.%UInt] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .UInt = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %UInt.type = import_ref Core//prelude/types, inst+23, loaded [template = constants.%UInt] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_u0 = %test_u0 // CHECK:STDOUT: .test_u1 = %test_u1 // CHECK:STDOUT: .test_u15 = %test_u15 @@ -304,7 +331,6 @@ var test_f128: f128; // CHECK:STDOUT: .test_u10000000000000000000 = %test_u10000000000000000000 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %u0.ref: = name_ref u0, [template = ] // CHECK:STDOUT: %test_u0.var: ref = var test_u0 // CHECK:STDOUT: %test_u0: ref = bind_name test_u0, %test_u0.var diff --git a/toolchain/check/testdata/builtins/bool/make_type.carbon b/toolchain/check/testdata/builtins/bool/make_type.carbon index f119677eb52e7..6943ed39b64a9 100644 --- a/toolchain/check/testdata/builtins/bool/make_type.carbon +++ b/toolchain/check/testdata/builtins/bool/make_type.carbon @@ -30,13 +30,24 @@ var b: Bool() = false; // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Bool = %Bool.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Bool.decl: %Bool.type = fn_decl @Bool [template = constants.%Bool] { // CHECK:STDOUT: @Bool.%return: ref type = var // CHECK:STDOUT: } @@ -54,18 +65,26 @@ var b: Bool() = false; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir1, inst+4, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Main//types, inst+4, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Bool = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Bool.ref: %Bool.type = name_ref Bool, imports.%import_ref [template = constants.%Bool] // CHECK:STDOUT: %bool.make_type: init type = call %Bool.ref() [template = bool] // CHECK:STDOUT: %.loc6_13.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/builtins/float/add.carbon b/toolchain/check/testdata/builtins/float/add.carbon index 5e34d058b95fb..37ebfb3a82303 100644 --- a/toolchain/check/testdata/builtins/float/add.carbon +++ b/toolchain/check/testdata/builtins/float/add.carbon @@ -67,24 +67,27 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%.loc2_11.1) [template = f64] @@ -182,32 +185,24 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.11: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.12: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.13: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.14: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.15: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.16: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.17: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.18: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.19: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.20: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -217,7 +212,6 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%Float(%.loc8_14.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/div.carbon b/toolchain/check/testdata/builtins/float/div.carbon index bd9a41719e24a..c2bd335cd52e8 100644 --- a/toolchain/check/testdata/builtins/float/div.carbon +++ b/toolchain/check/testdata/builtins/float/div.carbon @@ -73,20 +73,22 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.9: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: .a = %a.loc8 @@ -94,7 +96,6 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%.loc2_11.1) [template = f64] @@ -214,32 +215,24 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.11: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.12: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.13: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.14: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.15: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.16: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.17: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.18: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.19: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.20: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -249,7 +242,6 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%Float(%.loc8_14.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/eq.carbon b/toolchain/check/testdata/builtins/float/eq.carbon index 47894581c22f2..27d74beea41d3 100644 --- a/toolchain/check/testdata/builtins/float/eq.carbon +++ b/toolchain/check/testdata/builtins/float/eq.carbon @@ -59,17 +59,24 @@ fn WrongResult(a: f64, b: f64) -> f64 = "float.eq"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Eq = %Eq.decl // CHECK:STDOUT: .True = %True.decl // CHECK:STDOUT: .False = %False.decl @@ -77,7 +84,6 @@ fn WrongResult(a: f64, b: f64) -> f64 = "float.eq"; // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Eq.decl: %Eq.type = fn_decl @Eq [template = constants.%Eq] { // CHECK:STDOUT: %.loc2_10.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_10: init type = call constants.%Float(%.loc2_10.1) [template = f64] @@ -208,18 +214,25 @@ fn WrongResult(a: f64, b: f64) -> f64 = "float.eq"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .WrongResult = %WrongResult.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %WrongResult.decl: %WrongResult.type = fn_decl @WrongResult [template = constants.%WrongResult] { // CHECK:STDOUT: %.loc7_19.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc7_19: init type = call constants.%Float(%.loc7_19.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/greater.carbon b/toolchain/check/testdata/builtins/float/greater.carbon index 176e77e47d29a..371d3aee8bada 100644 --- a/toolchain/check/testdata/builtins/float/greater.carbon +++ b/toolchain/check/testdata/builtins/float/greater.carbon @@ -58,19 +58,24 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Greater = %Greater.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -79,7 +84,6 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Greater.decl: %Greater.type = fn_decl @Greater [template = constants.%Greater] { // CHECK:STDOUT: %.loc2_15.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_15: init type = call constants.%Float(%.loc2_15.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/greater_eq.carbon b/toolchain/check/testdata/builtins/float/greater_eq.carbon index 622a6a490f78c..b384b20bb4804 100644 --- a/toolchain/check/testdata/builtins/float/greater_eq.carbon +++ b/toolchain/check/testdata/builtins/float/greater_eq.carbon @@ -58,19 +58,24 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .GreaterEq = %GreaterEq.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -79,7 +84,6 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %GreaterEq.decl: %GreaterEq.type = fn_decl @GreaterEq [template = constants.%GreaterEq] { // CHECK:STDOUT: %.loc2_17.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_17: init type = call constants.%Float(%.loc2_17.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/less.carbon b/toolchain/check/testdata/builtins/float/less.carbon index 18c6fbb21bba9..cb463da777d32 100644 --- a/toolchain/check/testdata/builtins/float/less.carbon +++ b/toolchain/check/testdata/builtins/float/less.carbon @@ -58,19 +58,24 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Less = %Less.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -79,7 +84,6 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Less.decl: %Less.type = fn_decl @Less [template = constants.%Less] { // CHECK:STDOUT: %.loc2_12.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_12: init type = call constants.%Float(%.loc2_12.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/less_eq.carbon b/toolchain/check/testdata/builtins/float/less_eq.carbon index 7c41c26f07849..ed31da0154fa4 100644 --- a/toolchain/check/testdata/builtins/float/less_eq.carbon +++ b/toolchain/check/testdata/builtins/float/less_eq.carbon @@ -58,19 +58,24 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .LessEq = %LessEq.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -79,7 +84,6 @@ fn RuntimeCall(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %LessEq.decl: %LessEq.type = fn_decl @LessEq [template = constants.%LessEq] { // CHECK:STDOUT: %.loc2_14.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_14: init type = call constants.%Float(%.loc2_14.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/make_type.carbon b/toolchain/check/testdata/builtins/float/make_type.carbon index 8168b58df2c89..428bd5e089358 100644 --- a/toolchain/check/testdata/builtins/float/make_type.carbon +++ b/toolchain/check/testdata/builtins/float/make_type.carbon @@ -55,16 +55,25 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Float = %Float.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Float.decl: %Float.type = fn_decl @Float [template = constants.%Float] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_16.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -94,20 +103,29 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir1, inst+15, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Main//types, inst+15, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Float = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: .GetFloat = %GetFloat.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Float.ref: %Float.type = name_ref Float, imports.%import_ref.1 [template = constants.%Float] // CHECK:STDOUT: %.loc6_14: i32 = int_literal 64 [template = constants.%.2] // CHECK:STDOUT: %float.make_type: init type = call %Float.ref(%.loc6_14) [template = f64] @@ -159,21 +177,30 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir1, inst+15, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Main//types, inst+15, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Float = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .invalid_float = %invalid_float // CHECK:STDOUT: .dyn_size = %dyn_size // CHECK:STDOUT: .dyn = %dyn // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Float.ref.loc10: %Float.type = name_ref Float, imports.%import_ref.1 [template = constants.%Float] // CHECK:STDOUT: %.loc10_26: i32 = int_literal 32 [template = constants.%.2] // CHECK:STDOUT: %float.make_type.loc10: init type = call %Float.ref.loc10(%.loc10_26) [template = ] diff --git a/toolchain/check/testdata/builtins/float/mul.carbon b/toolchain/check/testdata/builtins/float/mul.carbon index 9bdea70aefc49..d14de7f54cba7 100644 --- a/toolchain/check/testdata/builtins/float/mul.carbon +++ b/toolchain/check/testdata/builtins/float/mul.carbon @@ -67,24 +67,27 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mul = %Mul.decl // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mul.decl: %Mul.type = fn_decl @Mul [template = constants.%Mul] { // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%.loc2_11.1) [template = f64] @@ -182,32 +185,24 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.11: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.12: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.13: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.14: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.15: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.16: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.17: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.18: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.19: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.20: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -217,7 +212,6 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%Float(%.loc8_14.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/negate.carbon b/toolchain/check/testdata/builtins/float/negate.carbon index 9bd63af9ae464..8692ce51c1b13 100644 --- a/toolchain/check/testdata/builtins/float/negate.carbon +++ b/toolchain/check/testdata/builtins/float/negate.carbon @@ -87,23 +87,27 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %.loc2_14.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_14: init type = call constants.%Float(%.loc2_14.1) [template = f64] @@ -193,28 +197,24 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.9: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.10: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.11: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.12: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.13: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.14: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.15: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.16: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.17: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -224,7 +224,6 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc8: init type = call constants.%Float(%.loc8_16.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/neq.carbon b/toolchain/check/testdata/builtins/float/neq.carbon index d5c5a7868c0ff..67129d16cf9d0 100644 --- a/toolchain/check/testdata/builtins/float/neq.carbon +++ b/toolchain/check/testdata/builtins/float/neq.carbon @@ -59,17 +59,24 @@ fn WrongResult(a: f64, b: f64) -> f64 = "float.neq"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Neq = %Neq.decl // CHECK:STDOUT: .True = %True.decl // CHECK:STDOUT: .False = %False.decl @@ -77,7 +84,6 @@ fn WrongResult(a: f64, b: f64) -> f64 = "float.neq"; // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Neq.decl: %Neq.type = fn_decl @Neq [template = constants.%Neq] { // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%.loc2_11.1) [template = f64] @@ -208,18 +214,25 @@ fn WrongResult(a: f64, b: f64) -> f64 = "float.neq"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .WrongResult = %WrongResult.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %WrongResult.decl: %WrongResult.type = fn_decl @WrongResult [template = constants.%WrongResult] { // CHECK:STDOUT: %.loc7_19.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc7_19: init type = call constants.%Float(%.loc7_19.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/float/sub.carbon b/toolchain/check/testdata/builtins/float/sub.carbon index 043ebd6523125..22c8f0af1ed64 100644 --- a/toolchain/check/testdata/builtins/float/sub.carbon +++ b/toolchain/check/testdata/builtins/float/sub.carbon @@ -67,24 +67,27 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] { // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%.loc2_11.1) [template = f64] @@ -182,32 +185,24 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.11: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.12: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.13: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.14: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.15: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.16: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.17: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.18: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.19: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.20: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -217,7 +212,6 @@ fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%Float(%.loc8_14.1) [template = f64] diff --git a/toolchain/check/testdata/builtins/int/and.carbon b/toolchain/check/testdata/builtins/int/and.carbon index 00dcee1fe13ea..1329e43f1f748 100644 --- a/toolchain/check/testdata/builtins/int/and.carbon +++ b/toolchain/check/testdata/builtins/int/and.carbon @@ -37,26 +37,28 @@ fn RuntimeCall(a: i32, b: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .And = %And.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %And.decl: %And.type = fn_decl @And [template = constants.%And] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/complement.carbon b/toolchain/check/testdata/builtins/int/complement.carbon index 2cd5d6b9368e4..e36cce8fa38e6 100644 --- a/toolchain/check/testdata/builtins/int/complement.carbon +++ b/toolchain/check/testdata/builtins/int/complement.carbon @@ -41,20 +41,22 @@ fn RuntimeCall(a: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Complement = %Complement.decl // CHECK:STDOUT: .And = %And.decl // CHECK:STDOUT: .arr = %arr @@ -62,7 +64,6 @@ fn RuntimeCall(a: i32) -> i32 { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Complement.decl: %Complement.type = fn_decl @Complement [template = constants.%Complement] { // CHECK:STDOUT: %int.make_type_32.loc2_18: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_18.1: type = value_of_initializer %int.make_type_32.loc2_18 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/eq.carbon b/toolchain/check/testdata/builtins/int/eq.carbon index ed77843494cf2..c0a25cc208f1e 100644 --- a/toolchain/check/testdata/builtins/int/eq.carbon +++ b/toolchain/check/testdata/builtins/int/eq.carbon @@ -58,17 +58,24 @@ fn WrongResult(a: i32, b: i32) -> i32 = "int.eq"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Eq = %Eq.decl // CHECK:STDOUT: .True = %True.decl // CHECK:STDOUT: .False = %False.decl @@ -76,7 +83,6 @@ fn WrongResult(a: i32, b: i32) -> i32 = "int.eq"; // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Eq.decl: %Eq.type = fn_decl @Eq [template = constants.%Eq] { // CHECK:STDOUT: %int.make_type_32.loc2_10: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_10.1: type = value_of_initializer %int.make_type_32.loc2_10 [template = i32] @@ -202,18 +208,25 @@ fn WrongResult(a: i32, b: i32) -> i32 = "int.eq"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .WrongResult = %WrongResult.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %WrongResult.decl: %WrongResult.type = fn_decl @WrongResult [template = constants.%WrongResult] { // CHECK:STDOUT: %int.make_type_32.loc7_19: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc7_19.1: type = value_of_initializer %int.make_type_32.loc7_19 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/greater.carbon b/toolchain/check/testdata/builtins/int/greater.carbon index 538939ac1f765..2e2428b75ac00 100644 --- a/toolchain/check/testdata/builtins/int/greater.carbon +++ b/toolchain/check/testdata/builtins/int/greater.carbon @@ -57,19 +57,24 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Greater = %Greater.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -78,7 +83,6 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Greater.decl: %Greater.type = fn_decl @Greater [template = constants.%Greater] { // CHECK:STDOUT: %int.make_type_32.loc2_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_15.1: type = value_of_initializer %int.make_type_32.loc2_15 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/greater_eq.carbon b/toolchain/check/testdata/builtins/int/greater_eq.carbon index 76cb1d098d049..286f36805f3ff 100644 --- a/toolchain/check/testdata/builtins/int/greater_eq.carbon +++ b/toolchain/check/testdata/builtins/int/greater_eq.carbon @@ -57,19 +57,24 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .GreaterEq = %GreaterEq.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -78,7 +83,6 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %GreaterEq.decl: %GreaterEq.type = fn_decl @GreaterEq [template = constants.%GreaterEq] { // CHECK:STDOUT: %int.make_type_32.loc2_17: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_17.1: type = value_of_initializer %int.make_type_32.loc2_17 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/left_shift.carbon b/toolchain/check/testdata/builtins/int/left_shift.carbon index dbf2682c4f83e..9491b72a70345 100644 --- a/toolchain/check/testdata/builtins/int/left_shift.carbon +++ b/toolchain/check/testdata/builtins/int/left_shift.carbon @@ -81,26 +81,28 @@ let negative: i32 = LeftShift(1, Negate(1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .LeftShift = %LeftShift.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %LeftShift.decl: %LeftShift.type = fn_decl @LeftShift [template = constants.%LeftShift] { // CHECK:STDOUT: %int.make_type_32.loc2_17: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_17.1: type = value_of_initializer %int.make_type_32.loc2_17 [template = i32] @@ -195,24 +197,22 @@ let negative: i32 = LeftShift(1, Negate(1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .LeftShift = %LeftShift.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .size_1 = @__global_init.%size_1 @@ -225,7 +225,6 @@ let negative: i32 = LeftShift(1, Negate(1)); // CHECK:STDOUT: .negative = @__global_init.%negative // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %LeftShift.decl: %LeftShift.type = fn_decl @LeftShift [template = constants.%LeftShift] { // CHECK:STDOUT: %int.make_type_32.loc4_17: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_17.1: type = value_of_initializer %int.make_type_32.loc4_17 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/less.carbon b/toolchain/check/testdata/builtins/int/less.carbon index 38dcb94a28017..19c7fafb8be43 100644 --- a/toolchain/check/testdata/builtins/int/less.carbon +++ b/toolchain/check/testdata/builtins/int/less.carbon @@ -57,19 +57,24 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Less = %Less.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -78,7 +83,6 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Less.decl: %Less.type = fn_decl @Less [template = constants.%Less] { // CHECK:STDOUT: %int.make_type_32.loc2_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_12.1: type = value_of_initializer %int.make_type_32.loc2_12 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/less_eq.carbon b/toolchain/check/testdata/builtins/int/less_eq.carbon index 54b4e187f8c8a..849fe02f9f8b6 100644 --- a/toolchain/check/testdata/builtins/int/less_eq.carbon +++ b/toolchain/check/testdata/builtins/int/less_eq.carbon @@ -57,19 +57,24 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .LessEq = %LessEq.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .True = %True.decl @@ -78,7 +83,6 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %LessEq.decl: %LessEq.type = fn_decl @LessEq [template = constants.%LessEq] { // CHECK:STDOUT: %int.make_type_32.loc2_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_14.1: type = value_of_initializer %int.make_type_32.loc2_14 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/make_type_32.carbon b/toolchain/check/testdata/builtins/int/make_type_32.carbon index 5bac897566ade..66442138fea43 100644 --- a/toolchain/check/testdata/builtins/int/make_type_32.carbon +++ b/toolchain/check/testdata/builtins/int/make_type_32.carbon @@ -30,13 +30,24 @@ var i: Int() = 0; // CHECK:STDOUT: %Int: %Int.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Int = %Int.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Int.decl: %Int.type = fn_decl @Int [template = constants.%Int] { // CHECK:STDOUT: @Int.%return: ref type = var // CHECK:STDOUT: } @@ -54,18 +65,26 @@ var i: Int() = 0; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int.type = import_ref ir1, inst+4, loaded [template = constants.%Int] +// CHECK:STDOUT: %import_ref: %Int.type = import_ref Main//types, inst+4, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Int = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .i = %i // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, imports.%import_ref [template = constants.%Int] // CHECK:STDOUT: %int.make_type_32: init type = call %Int.ref() [template = i32] // CHECK:STDOUT: %.loc6_12.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/make_type_signed.carbon b/toolchain/check/testdata/builtins/int/make_type_signed.carbon index 6b86137c0f54a..6e87379407cc5 100644 --- a/toolchain/check/testdata/builtins/int/make_type_signed.carbon +++ b/toolchain/check/testdata/builtins/int/make_type_signed.carbon @@ -80,16 +80,25 @@ var m: Int(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Int = %Int.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Int.decl: %Int.type = fn_decl @Int [template = constants.%Int] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -127,21 +136,30 @@ var m: Int(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int.type = import_ref ir1, inst+15, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %Int.type = import_ref Main//types, inst+15, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Int = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .Symbolic = %Symbolic.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Int.ref.loc6_9: %Int.type = name_ref Int, imports.%import_ref.1 [template = constants.%Int] // CHECK:STDOUT: %.loc6_13: i32 = int_literal 64 [template = constants.%.2] @@ -177,20 +195,20 @@ var m: Int(1000000000); // CHECK:STDOUT: %.loc14_17.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_17.2: type = converted %int.make_type_32, %.loc14_17.1 [template = i32] // CHECK:STDOUT: %N.loc14_13.1: i32 = param N -// CHECK:STDOUT: @Symbolic.%N: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = @Symbolic.%N (constants.%N)] +// CHECK:STDOUT: @Symbolic.%N.loc14: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = @Symbolic.%N.1 (constants.%N)] // CHECK:STDOUT: %Int.ref.loc14_25: %Int.type = name_ref Int, imports.%import_ref.1 [template = constants.%Int] -// CHECK:STDOUT: %N.ref.loc14_29: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] -// CHECK:STDOUT: %int.make_type_signed.loc14_28: init type = call %Int.ref.loc14_25(%N.ref.loc14_29) [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] -// CHECK:STDOUT: %.loc14_30.1: type = value_of_initializer %int.make_type_signed.loc14_28 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] -// CHECK:STDOUT: %.loc14_30.2: type = converted %int.make_type_signed.loc14_28, %.loc14_30.1 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] -// CHECK:STDOUT: %x.loc14_22.1: file.%int.make_type_signed.loc14_28 (%.6) = param x -// CHECK:STDOUT: @Symbolic.%x: file.%int.make_type_signed.loc14_28 (%.6) = bind_name x, %x.loc14_22.1 +// CHECK:STDOUT: %N.ref.loc14_29: i32 = name_ref N, @Symbolic.%N.loc14 [symbolic = @Symbolic.%N.1 (constants.%N)] +// CHECK:STDOUT: %int.make_type_signed.loc14_28: init type = call %Int.ref.loc14_25(%N.ref.loc14_29) [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_30.1: type = value_of_initializer %int.make_type_signed.loc14_28 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_30.2: type = converted %int.make_type_signed.loc14_28, %.loc14_30.1 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %x.loc14_22.1: @Symbolic.%.1 (%.6) = param x +// CHECK:STDOUT: @Symbolic.%x: @Symbolic.%.1 (%.6) = bind_name x, %x.loc14_22.1 // CHECK:STDOUT: %Int.ref.loc14_36: %Int.type = name_ref Int, imports.%import_ref.1 [template = constants.%Int] -// CHECK:STDOUT: %N.ref.loc14_40: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] -// CHECK:STDOUT: %int.make_type_signed.loc14_39: init type = call %Int.ref.loc14_36(%N.ref.loc14_40) [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] -// CHECK:STDOUT: %.loc14_41.1: type = value_of_initializer %int.make_type_signed.loc14_39 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] -// CHECK:STDOUT: %.loc14_41.2: type = converted %int.make_type_signed.loc14_39, %.loc14_41.1 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] -// CHECK:STDOUT: @Symbolic.%return: ref %.6 = var +// CHECK:STDOUT: %N.ref.loc14_40: i32 = name_ref N, @Symbolic.%N.loc14 [symbolic = @Symbolic.%N.1 (constants.%N)] +// CHECK:STDOUT: %int.make_type_signed.loc14_39: init type = call %Int.ref.loc14_36(%N.ref.loc14_40) [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_41.1: type = value_of_initializer %int.make_type_signed.loc14_39 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_41.2: type = converted %int.make_type_signed.loc14_39, %.loc14_41.1 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: @Symbolic.%return: ref @Symbolic.%.1 (%.6) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -210,11 +228,22 @@ var m: Int(1000000000); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Symbolic(%N: i32, %x: file.%int.make_type_signed.loc14_28 (%.6)) -> %.6 -// CHECK:STDOUT: generic [%N: i32] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.ref: %.6 = name_ref x, %x -// CHECK:STDOUT: return %x.ref +// CHECK:STDOUT: generic fn @Symbolic(%N.loc14: i32) { +// CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic = %N.1 (constants.%N)] +// CHECK:STDOUT: %.1: type = int_type signed, %N.1 [symbolic = %.1 (constants.%.6)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%N.loc14: i32, %x: @Symbolic.%.1 (%.6)) -> @Symbolic.%.1 (%.6) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: @Symbolic.%.1 (%.6) = name_ref x, %x +// CHECK:STDOUT: return %x.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Symbolic(constants.%N) { +// CHECK:STDOUT: %N.1 => constants.%N +// CHECK:STDOUT: %.1 => constants.%.6 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_zero_size.carbon @@ -227,18 +256,26 @@ var m: Int(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int.type = import_ref ir1, inst+15, loaded [template = constants.%Int] +// CHECK:STDOUT: %import_ref: %Int.type = import_ref Main//types, inst+15, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Int = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, imports.%import_ref [template = constants.%Int] // CHECK:STDOUT: %.loc10_12: i32 = int_literal 0 [template = constants.%.2] // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%.loc10_12) [template = ] @@ -265,21 +302,29 @@ var m: Int(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int.type = import_ref ir1, inst+15, loaded [template = constants.%Int] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %Int.type = import_ref Main//types, inst+15, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Int = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .n = %n.loc12 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc6_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_14.1: type = value_of_initializer %int.make_type_32.loc6_14 [template = i32] @@ -320,18 +365,26 @@ var m: Int(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int.type = import_ref ir1, inst+15, loaded [template = constants.%Int] +// CHECK:STDOUT: %import_ref: %Int.type = import_ref Main//types, inst+15, loaded [template = constants.%Int] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Int = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .m = %m // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, imports.%import_ref [template = constants.%Int] // CHECK:STDOUT: %.loc9_12: i32 = int_literal 1000000000 [template = constants.%.2] // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%.loc9_12) [template = ] diff --git a/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon b/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon index 1779bda7b027f..9fc1692843674 100644 --- a/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon +++ b/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon @@ -80,16 +80,25 @@ var m: UInt(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .UInt = %UInt.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %UInt.decl: %UInt.type = fn_decl @UInt [template = constants.%UInt] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_12.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -127,21 +136,30 @@ var m: UInt(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %UInt.type = import_ref ir1, inst+15, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %UInt.type = import_ref Main//types, inst+15, loaded [template = constants.%UInt] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .UInt = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .Symbolic = %Symbolic.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %UInt.ref.loc6_9: %UInt.type = name_ref UInt, imports.%import_ref.1 [template = constants.%UInt] // CHECK:STDOUT: %.loc6_14: i32 = int_literal 64 [template = constants.%.2] @@ -177,20 +195,20 @@ var m: UInt(1000000000); // CHECK:STDOUT: %.loc14_17.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_17.2: type = converted %int.make_type_32, %.loc14_17.1 [template = i32] // CHECK:STDOUT: %N.loc14_13.1: i32 = param N -// CHECK:STDOUT: @Symbolic.%N: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = @Symbolic.%N (constants.%N)] +// CHECK:STDOUT: @Symbolic.%N.loc14: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = @Symbolic.%N.1 (constants.%N)] // CHECK:STDOUT: %UInt.ref.loc14_25: %UInt.type = name_ref UInt, imports.%import_ref.1 [template = constants.%UInt] -// CHECK:STDOUT: %N.ref.loc14_30: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] -// CHECK:STDOUT: %int.make_type_unsigned.loc14_29: init type = call %UInt.ref.loc14_25(%N.ref.loc14_30) [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] -// CHECK:STDOUT: %.loc14_31.1: type = value_of_initializer %int.make_type_unsigned.loc14_29 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] -// CHECK:STDOUT: %.loc14_31.2: type = converted %int.make_type_unsigned.loc14_29, %.loc14_31.1 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] -// CHECK:STDOUT: %x.loc14_22.1: file.%int.make_type_unsigned.loc14_29 (%.6) = param x -// CHECK:STDOUT: @Symbolic.%x: file.%int.make_type_unsigned.loc14_29 (%.6) = bind_name x, %x.loc14_22.1 +// CHECK:STDOUT: %N.ref.loc14_30: i32 = name_ref N, @Symbolic.%N.loc14 [symbolic = @Symbolic.%N.1 (constants.%N)] +// CHECK:STDOUT: %int.make_type_unsigned.loc14_29: init type = call %UInt.ref.loc14_25(%N.ref.loc14_30) [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_31.1: type = value_of_initializer %int.make_type_unsigned.loc14_29 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_31.2: type = converted %int.make_type_unsigned.loc14_29, %.loc14_31.1 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %x.loc14_22.1: @Symbolic.%.1 (%.6) = param x +// CHECK:STDOUT: @Symbolic.%x: @Symbolic.%.1 (%.6) = bind_name x, %x.loc14_22.1 // CHECK:STDOUT: %UInt.ref.loc14_37: %UInt.type = name_ref UInt, imports.%import_ref.1 [template = constants.%UInt] -// CHECK:STDOUT: %N.ref.loc14_42: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] -// CHECK:STDOUT: %int.make_type_unsigned.loc14_41: init type = call %UInt.ref.loc14_37(%N.ref.loc14_42) [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] -// CHECK:STDOUT: %.loc14_43.1: type = value_of_initializer %int.make_type_unsigned.loc14_41 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] -// CHECK:STDOUT: %.loc14_43.2: type = converted %int.make_type_unsigned.loc14_41, %.loc14_43.1 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] -// CHECK:STDOUT: @Symbolic.%return: ref %.6 = var +// CHECK:STDOUT: %N.ref.loc14_42: i32 = name_ref N, @Symbolic.%N.loc14 [symbolic = @Symbolic.%N.1 (constants.%N)] +// CHECK:STDOUT: %int.make_type_unsigned.loc14_41: init type = call %UInt.ref.loc14_37(%N.ref.loc14_42) [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_43.1: type = value_of_initializer %int.make_type_unsigned.loc14_41 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: %.loc14_43.2: type = converted %int.make_type_unsigned.loc14_41, %.loc14_43.1 [symbolic = @Symbolic.%.1 (constants.%.6)] +// CHECK:STDOUT: @Symbolic.%return: ref @Symbolic.%.1 (%.6) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -210,11 +228,22 @@ var m: UInt(1000000000); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Symbolic(%N: i32, %x: file.%int.make_type_unsigned.loc14_29 (%.6)) -> %.6 -// CHECK:STDOUT: generic [%N: i32] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.ref: %.6 = name_ref x, %x -// CHECK:STDOUT: return %x.ref +// CHECK:STDOUT: generic fn @Symbolic(%N.loc14: i32) { +// CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic = %N.1 (constants.%N)] +// CHECK:STDOUT: %.1: type = int_type unsigned, %N.1 [symbolic = %.1 (constants.%.6)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%N.loc14: i32, %x: @Symbolic.%.1 (%.6)) -> @Symbolic.%.1 (%.6) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: @Symbolic.%.1 (%.6) = name_ref x, %x +// CHECK:STDOUT: return %x.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Symbolic(constants.%N) { +// CHECK:STDOUT: %N.1 => constants.%N +// CHECK:STDOUT: %.1 => constants.%.6 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_zero_size.carbon @@ -227,18 +256,26 @@ var m: UInt(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %UInt.type = import_ref ir1, inst+15, loaded [template = constants.%UInt] +// CHECK:STDOUT: %import_ref: %UInt.type = import_ref Main//types, inst+15, loaded [template = constants.%UInt] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .UInt = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %UInt.ref: %UInt.type = name_ref UInt, imports.%import_ref [template = constants.%UInt] // CHECK:STDOUT: %.loc10_13: i32 = int_literal 0 [template = constants.%.2] // CHECK:STDOUT: %int.make_type_unsigned: init type = call %UInt.ref(%.loc10_13) [template = ] @@ -265,21 +302,29 @@ var m: UInt(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %UInt.type = import_ref ir1, inst+15, loaded [template = constants.%UInt] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %UInt.type = import_ref Main//types, inst+15, loaded [template = constants.%UInt] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .UInt = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .n = %n.loc12 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc6_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_14.1: type = value_of_initializer %int.make_type_32.loc6_14 [template = i32] @@ -320,18 +365,26 @@ var m: UInt(1000000000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %UInt.type = import_ref ir1, inst+15, loaded [template = constants.%UInt] +// CHECK:STDOUT: %import_ref: %UInt.type = import_ref Main//types, inst+15, loaded [template = constants.%UInt] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .UInt = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .m = %m // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %UInt.ref: %UInt.type = name_ref UInt, imports.%import_ref [template = constants.%UInt] // CHECK:STDOUT: %.loc9_13: i32 = int_literal 1000000000 [template = constants.%.2] // CHECK:STDOUT: %int.make_type_unsigned: init type = call %UInt.ref(%.loc9_13) [template = ] diff --git a/toolchain/check/testdata/builtins/int/neq.carbon b/toolchain/check/testdata/builtins/int/neq.carbon index a554f93928536..139851962b4b8 100644 --- a/toolchain/check/testdata/builtins/int/neq.carbon +++ b/toolchain/check/testdata/builtins/int/neq.carbon @@ -49,17 +49,24 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Neq = %Neq.decl // CHECK:STDOUT: .True = %True.decl // CHECK:STDOUT: .False = %False.decl @@ -67,7 +74,6 @@ fn RuntimeCall(a: i32, b: i32) -> bool { // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Neq.decl: %Neq.type = fn_decl @Neq [template = constants.%Neq] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/or.carbon b/toolchain/check/testdata/builtins/int/or.carbon index 00ff3d00f71ec..2513ef39c29ae 100644 --- a/toolchain/check/testdata/builtins/int/or.carbon +++ b/toolchain/check/testdata/builtins/int/or.carbon @@ -37,26 +37,28 @@ fn RuntimeCall(a: i32, b: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Or = %Or.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Or.decl: %Or.type = fn_decl @Or [template = constants.%Or] { // CHECK:STDOUT: %int.make_type_32.loc2_10: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_10.1: type = value_of_initializer %int.make_type_32.loc2_10 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/right_shift.carbon b/toolchain/check/testdata/builtins/int/right_shift.carbon index f7a70abb85bb4..bfdad0bb1ff4e 100644 --- a/toolchain/check/testdata/builtins/int/right_shift.carbon +++ b/toolchain/check/testdata/builtins/int/right_shift.carbon @@ -82,26 +82,28 @@ let negative: i32 = RightShift(1, Negate(1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .RightShift = %RightShift.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %RightShift.decl: %RightShift.type = fn_decl @RightShift [template = constants.%RightShift] { // CHECK:STDOUT: %int.make_type_32.loc2_18: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_18.1: type = value_of_initializer %int.make_type_32.loc2_18 [template = i32] @@ -199,20 +201,22 @@ let negative: i32 = RightShift(1, Negate(1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .RightShift = %RightShift.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .arr1 = %arr1 @@ -221,7 +225,6 @@ let negative: i32 = RightShift(1, Negate(1)); // CHECK:STDOUT: .arr2_p = @__global_init.%arr2_p // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %RightShift.decl: %RightShift.type = fn_decl @RightShift [template = constants.%RightShift] { // CHECK:STDOUT: %int.make_type_32.loc6_18: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_18.1: type = value_of_initializer %int.make_type_32.loc6_18 [template = i32] @@ -335,20 +338,22 @@ let negative: i32 = RightShift(1, Negate(1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .RightShift = %RightShift.decl // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .size_1 = @__global_init.%size_1 @@ -357,7 +362,6 @@ let negative: i32 = RightShift(1, Negate(1)); // CHECK:STDOUT: .negative = @__global_init.%negative // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %RightShift.decl: %RightShift.type = fn_decl @RightShift [template = constants.%RightShift] { // CHECK:STDOUT: %int.make_type_32.loc4_18: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_18.1: type = value_of_initializer %int.make_type_32.loc4_18 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/sadd.carbon b/toolchain/check/testdata/builtins/int/sadd.carbon index 14358a49b2f6d..e538ef5737a8f 100644 --- a/toolchain/check/testdata/builtins/int/sadd.carbon +++ b/toolchain/check/testdata/builtins/int/sadd.carbon @@ -107,26 +107,28 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -228,36 +230,24 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.19: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.20: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.21: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.22: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.23: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.24: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.25: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -271,7 +261,6 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %int.make_type_32.loc8_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_14.1: type = value_of_initializer %int.make_type_32.loc8_14 [template = i32] @@ -478,22 +467,27 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/sdiv.carbon b/toolchain/check/testdata/builtins/int/sdiv.carbon index 594c5b3fbd289..8bb4a8331a3e4 100644 --- a/toolchain/check/testdata/builtins/int/sdiv.carbon +++ b/toolchain/check/testdata/builtins/int/sdiv.carbon @@ -75,26 +75,28 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -188,22 +190,22 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .Negate = %Negate.decl @@ -212,7 +214,6 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] @@ -344,22 +345,27 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/smod.carbon b/toolchain/check/testdata/builtins/int/smod.carbon index 40a315b8b953c..3e3658c405ec2 100644 --- a/toolchain/check/testdata/builtins/int/smod.carbon +++ b/toolchain/check/testdata/builtins/int/smod.carbon @@ -78,26 +78,28 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mod = %Mod.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mod.decl: %Mod.type = fn_decl @Mod [template = constants.%Mod] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -192,22 +194,22 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mod = %Mod.decl // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .Negate = %Negate.decl @@ -216,7 +218,6 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mod.decl: %Mod.type = fn_decl @Mod [template = constants.%Mod] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] @@ -348,22 +349,27 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mod = %Mod.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mod.decl: %Mod.type = fn_decl @Mod [template = constants.%Mod] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/smul.carbon b/toolchain/check/testdata/builtins/int/smul.carbon index bbba63348a19c..a319768b9cce7 100644 --- a/toolchain/check/testdata/builtins/int/smul.carbon +++ b/toolchain/check/testdata/builtins/int/smul.carbon @@ -49,26 +49,28 @@ let b: i32 = Mul(0x8000, 0x10000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mul = %Mul.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mul.decl: %Mul.type = fn_decl @Mul [template = constants.%Mul] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -158,22 +160,27 @@ let b: i32 = Mul(0x8000, 0x10000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mul = %Mul.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mul.decl: %Mul.type = fn_decl @Mul [template = constants.%Mul] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/snegate.carbon b/toolchain/check/testdata/builtins/int/snegate.carbon index 1704024e5ac34..5b8c0d64cb195 100644 --- a/toolchain/check/testdata/builtins/int/snegate.carbon +++ b/toolchain/check/testdata/builtins/int/snegate.carbon @@ -135,19 +135,22 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p @@ -155,7 +158,6 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc2_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_14.1: type = value_of_initializer %int.make_type_32.loc2_14 [template = i32] @@ -262,32 +264,24 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.19: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.20: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -301,7 +295,6 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_16.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32] @@ -486,25 +479,28 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc4_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_14.1: type = value_of_initializer %int.make_type_32.loc4_14 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/ssub.carbon b/toolchain/check/testdata/builtins/int/ssub.carbon index 8b761758dd357..fa3d025e599e0 100644 --- a/toolchain/check/testdata/builtins/int/ssub.carbon +++ b/toolchain/check/testdata/builtins/int/ssub.carbon @@ -50,26 +50,28 @@ let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -160,24 +162,28 @@ let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/uadd.carbon b/toolchain/check/testdata/builtins/int/uadd.carbon index 281fa79b74855..b1cca2ac97449 100644 --- a/toolchain/check/testdata/builtins/int/uadd.carbon +++ b/toolchain/check/testdata/builtins/int/uadd.carbon @@ -104,26 +104,28 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -225,36 +227,24 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.19: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.20: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.21: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.22: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.23: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.24: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.25: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -268,7 +258,6 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %int.make_type_32.loc8_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_14.1: type = value_of_initializer %int.make_type_32.loc8_14 [template = i32] @@ -475,22 +464,27 @@ let b: i32 = Add(0x7FFFFFFF, 1); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/udiv.carbon b/toolchain/check/testdata/builtins/int/udiv.carbon index ff6dfdb0fa7ff..0b1b9357d8a8b 100644 --- a/toolchain/check/testdata/builtins/int/udiv.carbon +++ b/toolchain/check/testdata/builtins/int/udiv.carbon @@ -71,26 +71,28 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -185,22 +187,22 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .Negate = %Negate.decl @@ -209,7 +211,6 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] @@ -341,22 +342,27 @@ let b: i32 = Div(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/umod.carbon b/toolchain/check/testdata/builtins/int/umod.carbon index a74b44c2902ba..9ec86e9b4f809 100644 --- a/toolchain/check/testdata/builtins/int/umod.carbon +++ b/toolchain/check/testdata/builtins/int/umod.carbon @@ -73,26 +73,28 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mod = %Mod.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mod.decl: %Mod.type = fn_decl @Mod [template = constants.%Mod] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -187,22 +189,22 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mod = %Mod.decl // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .Negate = %Negate.decl @@ -211,7 +213,6 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mod.decl: %Mod.type = fn_decl @Mod [template = constants.%Mod] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] @@ -343,22 +344,27 @@ let b: i32 = Mod(0, 0); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mod = %Mod.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mod.decl: %Mod.type = fn_decl @Mod [template = constants.%Mod] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/umul.carbon b/toolchain/check/testdata/builtins/int/umul.carbon index 6e61dbcbdc760..219a40a3c4795 100644 --- a/toolchain/check/testdata/builtins/int/umul.carbon +++ b/toolchain/check/testdata/builtins/int/umul.carbon @@ -46,26 +46,28 @@ let b: i32 = Mul(0x8000, 0x10000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mul = %Mul.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mul.decl: %Mul.type = fn_decl @Mul [template = constants.%Mul] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -155,22 +157,27 @@ let b: i32 = Mul(0x8000, 0x10000); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mul = %Mul.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mul.decl: %Mul.type = fn_decl @Mul [template = constants.%Mul] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/unegate.carbon b/toolchain/check/testdata/builtins/int/unegate.carbon index 5ccdc604dbdf0..4ed7f168394eb 100644 --- a/toolchain/check/testdata/builtins/int/unegate.carbon +++ b/toolchain/check/testdata/builtins/int/unegate.carbon @@ -131,19 +131,22 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p @@ -151,7 +154,6 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc2_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_14.1: type = value_of_initializer %int.make_type_32.loc2_14 [template = i32] @@ -258,32 +260,24 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.19: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.20: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .TooFew = %TooFew.decl // CHECK:STDOUT: .TooMany = %TooMany.decl // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl @@ -297,7 +291,6 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] { // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_16.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32] @@ -482,25 +475,28 @@ let b: i32 = Negate(Sub(Negate(0x7FFFFFFF), 1)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { // CHECK:STDOUT: %int.make_type_32.loc4_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_14.1: type = value_of_initializer %int.make_type_32.loc4_14 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/usub.carbon b/toolchain/check/testdata/builtins/int/usub.carbon index d348215164974..5d20bb25721e2 100644 --- a/toolchain/check/testdata/builtins/int/usub.carbon +++ b/toolchain/check/testdata/builtins/int/usub.carbon @@ -47,26 +47,28 @@ let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] @@ -157,24 +159,28 @@ let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Sub = %Sub.decl // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] { // CHECK:STDOUT: %int.make_type_32.loc4_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/int/xor.carbon b/toolchain/check/testdata/builtins/int/xor.carbon index 1daa2071cc51e..88838ffe9724f 100644 --- a/toolchain/check/testdata/builtins/int/xor.carbon +++ b/toolchain/check/testdata/builtins/int/xor.carbon @@ -37,26 +37,28 @@ fn RuntimeCall(a: i32, b: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Xor = %Xor.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: .arr_p = @__global_init.%arr_p // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Xor.decl: %Xor.type = fn_decl @Xor [template = constants.%Xor] { // CHECK:STDOUT: %int.make_type_32.loc2_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc2_11.1: type = value_of_initializer %int.make_type_32.loc2_11 [template = i32] diff --git a/toolchain/check/testdata/builtins/print.carbon b/toolchain/check/testdata/builtins/print.carbon index 2798a56e50cbd..f021aad051150 100644 --- a/toolchain/check/testdata/builtins/print.carbon +++ b/toolchain/check/testdata/builtins/print.carbon @@ -33,18 +33,28 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Print.type.2 = import_ref ir1, inst+43, loaded [template = constants.%Print.2] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Print = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Print.type.2 = import_ref Core//prelude, inst+43, loaded [template = constants.%Print.2] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Print = %Print.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Print.decl: %Print.type.1 = fn_decl @Print.1 [template = constants.%Print.1] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -64,7 +74,7 @@ fn Main() { // CHECK:STDOUT: %Print.ref.loc14: %Print.type.1 = name_ref Print, file.%Print.decl [template = constants.%Print.1] // CHECK:STDOUT: %.loc14: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %print.int.loc14: init %.1 = call %Print.ref.loc14(%.loc14) -// CHECK:STDOUT: %Core.ref: = name_ref Core, file.%Core [template = file.%Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Print.ref.loc16: %Print.type.2 = name_ref Print, imports.%import_ref.2 [template = constants.%Print.2] // CHECK:STDOUT: %.loc16: i32 = int_literal 2 [template = constants.%.3] // CHECK:STDOUT: %print.int.loc16: init %.1 = call %Print.ref.loc16(%.loc16) diff --git a/toolchain/check/testdata/class/adapt.carbon b/toolchain/check/testdata/class/adapt.carbon index 8bb636b5f8d3c..83a53dd8c07b2 100644 --- a/toolchain/check/testdata/class/adapt.carbon +++ b/toolchain/check/testdata/class/adapt.carbon @@ -60,21 +60,27 @@ fn F(a: AdaptNotExtend) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .SomeClass = %SomeClass.decl // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl // CHECK:STDOUT: .StructAdapter = %StructAdapter.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} // CHECK:STDOUT: %StructAdapter.decl: type = class_decl @StructAdapter [template = constants.%StructAdapter] {} @@ -134,15 +140,26 @@ fn F(a: AdaptNotExtend) { // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Adapted = %Adapted.decl // CHECK:STDOUT: .AdaptNotExtend = %AdaptNotExtend.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Adapted.decl: type = class_decl @Adapted [template = constants.%Adapted] {} // CHECK:STDOUT: %AdaptNotExtend.decl: type = class_decl @AdaptNotExtend [template = constants.%AdaptNotExtend] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { diff --git a/toolchain/check/testdata/class/base.carbon b/toolchain/check/testdata/class/base.carbon index 8120668dc5e09..ec02ce127f411 100644 --- a/toolchain/check/testdata/class/base.carbon +++ b/toolchain/check/testdata/class/base.carbon @@ -58,22 +58,28 @@ fn Access(d: Derived) -> (i32, i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: .Make = %Make.decl // CHECK:STDOUT: .Access = %Access.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] { diff --git a/toolchain/check/testdata/class/base_field.carbon b/toolchain/check/testdata/class/base_field.carbon index eb47a09e0bfe2..cbd36c7cd58b5 100644 --- a/toolchain/check/testdata/class/base_field.carbon +++ b/toolchain/check/testdata/class/base_field.carbon @@ -49,23 +49,27 @@ fn Access(p: Derived*) -> i32* { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: .Access = %Access.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %Access.decl: %Access.type = fn_decl @Access [template = constants.%Access] { diff --git a/toolchain/check/testdata/class/base_function_unqualified.carbon b/toolchain/check/testdata/class/base_function_unqualified.carbon index cfdafa018cce6..d7f6b4d20850d 100644 --- a/toolchain/check/testdata/class/base_function_unqualified.carbon +++ b/toolchain/check/testdata/class/base_function_unqualified.carbon @@ -41,14 +41,25 @@ fn Derived.H() { // CHECK:STDOUT: %.5: type = struct_type {.base: %Base} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} diff --git a/toolchain/check/testdata/class/base_method.carbon b/toolchain/check/testdata/class/base_method.carbon index 098814d236d19..816ff9af01257 100644 --- a/toolchain/check/testdata/class/base_method.carbon +++ b/toolchain/check/testdata/class/base_method.carbon @@ -14,7 +14,7 @@ base class Base { fn F[addr self: Self*](); } -fn Base.F[addr self: Base*]() { +fn Base.F[addr self: Self*]() { (*self).a = 1; } @@ -51,21 +51,30 @@ fn Call(p: Derived*) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: .Call = %Call.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Base.ref: type = name_ref Base, %Base.decl [template = constants.%Base] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [template = constants.%Base] // CHECK:STDOUT: %.loc17_26: type = ptr_type %Base [template = constants.%.3] // CHECK:STDOUT: %self.loc17_16.1: %.3 = param self // CHECK:STDOUT: @F.%self: %.3 = bind_name self, %self.loc17_16.1 diff --git a/toolchain/check/testdata/class/base_method_qualified.carbon b/toolchain/check/testdata/class/base_method_qualified.carbon index 65a8f4cbee197..e2ac1744f5d1e 100644 --- a/toolchain/check/testdata/class/base_method_qualified.carbon +++ b/toolchain/check/testdata/class/base_method_qualified.carbon @@ -72,17 +72,22 @@ fn PassDerivedToBaseIndirect(p: Derived*) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Derived = %Derived.decl.loc11 // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Call = %Call.decl @@ -91,7 +96,6 @@ fn PassDerivedToBaseIndirect(p: Derived*) -> i32 { // CHECK:STDOUT: .PassDerivedToBaseIndirect = %PassDerivedToBaseIndirect.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Derived.decl.loc11: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Derived.decl.loc18: type = class_decl @Derived [template = constants.%Derived] {} diff --git a/toolchain/check/testdata/class/base_method_shadow.carbon b/toolchain/check/testdata/class/base_method_shadow.carbon index 6733237ed9035..172ec56cc07df 100644 --- a/toolchain/check/testdata/class/base_method_shadow.carbon +++ b/toolchain/check/testdata/class/base_method_shadow.carbon @@ -66,9 +66,21 @@ fn Call(a: A*, b: B*, c: C*, d: D*) { // CHECK:STDOUT: %.16: type = ptr_type %.12 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl @@ -76,7 +88,6 @@ fn Call(a: A*, b: B*, c: C*, d: D*) { // CHECK:STDOUT: .Call = %Call.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} diff --git a/toolchain/check/testdata/class/basic.carbon b/toolchain/check/testdata/class/basic.carbon index 7a7d250d349f7..aa86e2b5900af 100644 --- a/toolchain/check/testdata/class/basic.carbon +++ b/toolchain/check/testdata/class/basic.carbon @@ -46,24 +46,26 @@ fn Run() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32.loc21_15: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/complete_in_member_fn.carbon b/toolchain/check/testdata/class/complete_in_member_fn.carbon index 2ed7012dbe2f0..4b2e5f18ca654 100644 --- a/toolchain/check/testdata/class/complete_in_member_fn.carbon +++ b/toolchain/check/testdata/class/complete_in_member_fn.carbon @@ -29,17 +29,25 @@ class C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/compound_field.carbon b/toolchain/check/testdata/class/compound_field.carbon index 3d10a7c53105d..fd0b29280330e 100644 --- a/toolchain/check/testdata/class/compound_field.carbon +++ b/toolchain/check/testdata/class/compound_field.carbon @@ -67,20 +67,22 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: .AccessDerived = %AccessDerived.decl @@ -89,7 +91,6 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: .AccessBaseIndirect = %AccessBaseIndirect.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %AccessDerived.decl: %AccessDerived.type = fn_decl @AccessDerived [template = constants.%AccessDerived] { diff --git a/toolchain/check/testdata/class/cross_package_import.carbon b/toolchain/check/testdata/class/cross_package_import.carbon index e0fe1f654aab7..27d246381b8ee 100644 --- a/toolchain/check/testdata/class/cross_package_import.carbon +++ b/toolchain/check/testdata/class/cross_package_import.carbon @@ -116,13 +116,24 @@ var c: Other.C = {}; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -137,13 +148,24 @@ var c: Other.C = {}; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -157,13 +179,24 @@ var c: Other.C = {}; // CHECK:STDOUT: %C: %C.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -183,21 +216,32 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir8, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir8, inst+4, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//define +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//define, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//define, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -225,20 +269,31 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir8, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref +// CHECK:STDOUT: import Other//extern +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: type = import_ref Other//extern, inst+3, loaded [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref [template = constants.%C] // CHECK:STDOUT: %c.var: ref = var c // CHECK:STDOUT: %c: ref = bind_name c, %c.var @@ -264,22 +319,34 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir8, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir8, inst+4, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir9, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//define +// CHECK:STDOUT: import Other//extern +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//define, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//define, inst+4, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//extern, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -310,22 +377,34 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir8, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir8, inst+4, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir9, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//define +// CHECK:STDOUT: import Other//conflict +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//define, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//define, inst+4, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//conflict, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var diff --git a/toolchain/check/testdata/class/derived_to_base.carbon b/toolchain/check/testdata/class/derived_to_base.carbon index aac7c3195808e..dfa6906a812f3 100644 --- a/toolchain/check/testdata/class/derived_to_base.carbon +++ b/toolchain/check/testdata/class/derived_to_base.carbon @@ -88,14 +88,22 @@ fn ConvertInit() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl @@ -107,7 +115,6 @@ fn ConvertInit() { // CHECK:STDOUT: .ConvertInit = %ConvertInit.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} diff --git a/toolchain/check/testdata/class/extend_adapt.carbon b/toolchain/check/testdata/class/extend_adapt.carbon index ca20287b07cc4..9b9c4d94801e9 100644 --- a/toolchain/check/testdata/class/extend_adapt.carbon +++ b/toolchain/check/testdata/class/extend_adapt.carbon @@ -112,20 +112,28 @@ class StructAdapter { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl.loc4 // CHECK:STDOUT: .SomeClass = %SomeClass.decl // CHECK:STDOUT: .TestStaticMemberFunction = %TestStaticMemberFunction.decl // CHECK:STDOUT: .TestAdapterMethod = %TestAdapterMethod.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %SomeClassAdapter.decl.loc4: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} // CHECK:STDOUT: %SomeClassAdapter.decl.loc15: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} @@ -211,15 +219,26 @@ class StructAdapter { // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .SomeClass = %SomeClass.decl // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { @@ -277,20 +296,27 @@ class StructAdapter { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .SomeClass = %SomeClass.decl // CHECK:STDOUT: .SomeClassAdapter = %SomeClassAdapter.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %SomeClass.decl: type = class_decl @SomeClass [template = constants.%SomeClass] {} // CHECK:STDOUT: %SomeClassAdapter.decl: type = class_decl @SomeClassAdapter [template = constants.%SomeClassAdapter] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { @@ -351,17 +377,25 @@ class StructAdapter { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .StructAdapter = %StructAdapter.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %StructAdapter.decl: type = class_decl @StructAdapter [template = constants.%StructAdapter] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/extern.carbon b/toolchain/check/testdata/class/extern.carbon index c4a3ede862e72..7dfc8a5511d38 100644 --- a/toolchain/check/testdata/class/extern.carbon +++ b/toolchain/check/testdata/class/extern.carbon @@ -276,13 +276,24 @@ extern class C; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -294,13 +305,24 @@ extern class C; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -312,13 +334,24 @@ extern class C; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -331,13 +364,24 @@ extern class C; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -355,13 +399,24 @@ extern class C; // CHECK:STDOUT: %.2: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {} // CHECK:STDOUT: } @@ -377,13 +432,24 @@ extern class C; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -398,13 +464,24 @@ extern class C; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl.loc4: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.decl.loc12: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -417,13 +494,24 @@ extern class C; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl.loc4: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.decl.loc12: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -438,13 +526,24 @@ extern class C; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -465,13 +564,24 @@ extern class C; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl.loc4: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.decl.loc5: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -487,13 +597,24 @@ extern class C; // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl.loc4: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.decl.loc12: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -503,87 +624,127 @@ extern class C; // CHECK:STDOUT: --- fail_todo_import_extern_decl_then_decl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_decl, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//decl, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_todo_import_decl_then_extern_decl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//decl, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_decl, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_todo_import_extern_decl_then_def.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_decl, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//def, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_import_ownership_conflict.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir3, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_decl, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//decl, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//def, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_todo_import_extern_decl_copy.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_decl, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_decl_copy, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- extern_decl_after_import_extern_decl.carbon @@ -593,17 +754,25 @@ extern class C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir1, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref: type = import_ref Main//extern_decl, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -616,17 +785,25 @@ extern class C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir1, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref: type = import_ref Main//decl, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -640,18 +817,26 @@ extern class C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//def, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Main//def, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -668,18 +853,26 @@ extern class C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//def, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Main//def, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_abstract.carbon b/toolchain/check/testdata/class/fail_abstract.carbon index 18e9dc2de1b20..2ce28ef8469d5 100644 --- a/toolchain/check/testdata/class/fail_abstract.carbon +++ b/toolchain/check/testdata/class/fail_abstract.carbon @@ -60,22 +60,28 @@ fn Access(d: Derived) -> (i32, i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Abstract = %Abstract.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: .Make = %Make.decl // CHECK:STDOUT: .Access = %Access.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {} // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] { diff --git a/toolchain/check/testdata/class/fail_adapt_bad_decl.carbon b/toolchain/check/testdata/class/fail_adapt_bad_decl.carbon index 28e2a0eb65215..631c69a8205b3 100644 --- a/toolchain/check/testdata/class/fail_adapt_bad_decl.carbon +++ b/toolchain/check/testdata/class/fail_adapt_bad_decl.carbon @@ -106,14 +106,25 @@ class C { // CHECK:STDOUT: %Use: %Use.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Bad = %Bad.decl // CHECK:STDOUT: .Use = %Use.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {} // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] { // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, %Bad.decl [template = constants.%Bad] @@ -147,14 +158,25 @@ class C { // CHECK:STDOUT: %Use: %Use.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Bad = %Bad.decl // CHECK:STDOUT: .Use = %Use.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {} // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] { // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, %Bad.decl [template = constants.%Bad] @@ -188,14 +210,25 @@ class C { // CHECK:STDOUT: %MultipleAdaptsSameType: type = class_type @MultipleAdaptsSameType [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .MultipleAdapts = %MultipleAdapts.decl // CHECK:STDOUT: .MultipleAdaptsSameType = %MultipleAdaptsSameType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %MultipleAdapts.decl: type = class_decl @MultipleAdapts [template = constants.%MultipleAdapts] {} // CHECK:STDOUT: %MultipleAdaptsSameType.decl: type = class_decl @MultipleAdaptsSameType [template = constants.%MultipleAdaptsSameType] {} // CHECK:STDOUT: } @@ -231,14 +264,25 @@ class C { // CHECK:STDOUT: %Self.2: %.3 = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc8: %.1 = struct_literal () // CHECK:STDOUT: %I.decl: type = interface_decl @I.1 [template = constants.%.2] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} diff --git a/toolchain/check/testdata/class/fail_adapt_bad_type.carbon b/toolchain/check/testdata/class/fail_adapt_bad_type.carbon index 3a0170a1cf70d..1d9badbf82fa1 100644 --- a/toolchain/check/testdata/class/fail_adapt_bad_type.carbon +++ b/toolchain/check/testdata/class/fail_adapt_bad_type.carbon @@ -31,14 +31,25 @@ class AdaptIncomplete { // CHECK:STDOUT: %AdaptIncomplete: type = class_type @AdaptIncomplete [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Incomplete = %Incomplete.decl // CHECK:STDOUT: .AdaptIncomplete = %AdaptIncomplete.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} // CHECK:STDOUT: %AdaptIncomplete.decl: type = class_decl @AdaptIncomplete [template = constants.%AdaptIncomplete] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_adapt_modifiers.carbon b/toolchain/check/testdata/class/fail_adapt_modifiers.carbon index ad81c8d1be5a7..b20a4292563b0 100644 --- a/toolchain/check/testdata/class/fail_adapt_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_adapt_modifiers.carbon @@ -69,9 +69,21 @@ class C5 { // CHECK:STDOUT: %C5: type = class_type @C5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C1 = %C1.decl // CHECK:STDOUT: .C2 = %C2.decl @@ -80,7 +92,6 @@ class C5 { // CHECK:STDOUT: .C5 = %C5.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C1.decl: type = class_decl @C1 [template = constants.%C1] {} // CHECK:STDOUT: %C2.decl: type = class_decl @C2 [template = constants.%C2] {} diff --git a/toolchain/check/testdata/class/fail_adapt_with_subobjects.carbon b/toolchain/check/testdata/class/fail_adapt_with_subobjects.carbon index 52af9607260ff..5791597494a24 100644 --- a/toolchain/check/testdata/class/fail_adapt_with_subobjects.carbon +++ b/toolchain/check/testdata/class/fail_adapt_with_subobjects.carbon @@ -88,17 +88,26 @@ class AdaptWithBaseAndFields { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .AdaptWithBase = %AdaptWithBase.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %AdaptWithBase.decl: type = class_decl @AdaptWithBase [template = constants.%AdaptWithBase] {} // CHECK:STDOUT: } @@ -137,22 +146,26 @@ class AdaptWithBaseAndFields { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .AdaptWithField = %AdaptWithField.decl // CHECK:STDOUT: .AdaptWithFields = %AdaptWithFields.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %AdaptWithField.decl: type = class_decl @AdaptWithField [template = constants.%AdaptWithField] {} // CHECK:STDOUT: %AdaptWithFields.decl: type = class_decl @AdaptWithFields [template = constants.%AdaptWithFields] {} // CHECK:STDOUT: } @@ -214,17 +227,26 @@ class AdaptWithBaseAndFields { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .AdaptWithBaseAndFields = %AdaptWithBaseAndFields.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %AdaptWithBaseAndFields.decl: type = class_decl @AdaptWithBaseAndFields [template = constants.%AdaptWithBaseAndFields] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_addr_not_self.carbon b/toolchain/check/testdata/class/fail_addr_not_self.carbon index d9607ed4b90dd..036ed7cddeafc 100644 --- a/toolchain/check/testdata/class/fail_addr_not_self.carbon +++ b/toolchain/check/testdata/class/fail_addr_not_self.carbon @@ -34,13 +34,24 @@ class Class { // CHECK:STDOUT: %.3: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_addr_self.carbon b/toolchain/check/testdata/class/fail_addr_self.carbon index ff983fd086ef8..b064765a39f08 100644 --- a/toolchain/check/testdata/class/fail_addr_self.carbon +++ b/toolchain/check/testdata/class/fail_addr_self.carbon @@ -60,14 +60,25 @@ fn F(c: Class, p: Class*) { // CHECK:STDOUT: %.4: type = ptr_type %.3 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %Class.ref.loc16_9: type = name_ref Class, %Class.decl [template = constants.%Class] diff --git a/toolchain/check/testdata/class/fail_base_bad_type.carbon b/toolchain/check/testdata/class/fail_base_bad_type.carbon index fa29247d83b83..8df97e0fca5b7 100644 --- a/toolchain/check/testdata/class/fail_base_bad_type.carbon +++ b/toolchain/check/testdata/class/fail_base_bad_type.carbon @@ -203,26 +203,22 @@ fn AccessMemberWithInvalidBaseFinal_NoMember(p: DeriveFromFinal*) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Final = %Final.decl // CHECK:STDOUT: .DeriveFromError = %DeriveFromError.decl @@ -248,7 +244,6 @@ fn AccessMemberWithInvalidBaseFinal_NoMember(p: DeriveFromFinal*) -> i32 { // CHECK:STDOUT: .AccessMemberWithInvalidBaseFinal_NoMember = %AccessMemberWithInvalidBaseFinal_NoMember.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Final.decl: type = class_decl @Final [template = constants.%Final] {} // CHECK:STDOUT: %DeriveFromError.decl: type = class_decl @DeriveFromError [template = constants.%DeriveFromError] {} diff --git a/toolchain/check/testdata/class/fail_base_method_define.carbon b/toolchain/check/testdata/class/fail_base_method_define.carbon index f9e1268ee147d..3495921af1f74 100644 --- a/toolchain/check/testdata/class/fail_base_method_define.carbon +++ b/toolchain/check/testdata/class/fail_base_method_define.carbon @@ -52,14 +52,25 @@ fn D.C.F() {} // CHECK:STDOUT: %.6: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.3 [template = constants.%F.3] {} diff --git a/toolchain/check/testdata/class/fail_base_modifiers.carbon b/toolchain/check/testdata/class/fail_base_modifiers.carbon index a8e7b356a0198..6aa98311fc153 100644 --- a/toolchain/check/testdata/class/fail_base_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_base_modifiers.carbon @@ -69,9 +69,21 @@ class C4 { // CHECK:STDOUT: %.8: type = unbound_element_type %C4, %B [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C1 = %C1.decl // CHECK:STDOUT: .C2 = %C2.decl @@ -79,7 +91,6 @@ class C4 { // CHECK:STDOUT: .C4 = %C4.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C1.decl: type = class_decl @C1 [template = constants.%C1] {} // CHECK:STDOUT: %C2.decl: type = class_decl @C2 [template = constants.%C2] {} diff --git a/toolchain/check/testdata/class/fail_base_no_extend.carbon b/toolchain/check/testdata/class/fail_base_no_extend.carbon index dfdfcf3e5ad3e..d75a752da445c 100644 --- a/toolchain/check/testdata/class/fail_base_no_extend.carbon +++ b/toolchain/check/testdata/class/fail_base_no_extend.carbon @@ -29,14 +29,25 @@ class C { // CHECK:STDOUT: %.5: type = struct_type {.base: %B} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_base_repeated.carbon b/toolchain/check/testdata/class/fail_base_repeated.carbon index 2cbd454f64ba1..99ddcef07981c 100644 --- a/toolchain/check/testdata/class/fail_base_repeated.carbon +++ b/toolchain/check/testdata/class/fail_base_repeated.carbon @@ -50,16 +50,27 @@ class D { // CHECK:STDOUT: %.6: type = unbound_element_type %D, %B1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B1 = %B1.decl // CHECK:STDOUT: .B2 = %B2.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B1.decl: type = class_decl @B1 [template = constants.%B1] {} // CHECK:STDOUT: %B2.decl: type = class_decl @B2 [template = constants.%B2] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} diff --git a/toolchain/check/testdata/class/fail_base_unbound.carbon b/toolchain/check/testdata/class/fail_base_unbound.carbon index d2688bd21bdb6..d4cbad3f8e0ef 100644 --- a/toolchain/check/testdata/class/fail_base_unbound.carbon +++ b/toolchain/check/testdata/class/fail_base_unbound.carbon @@ -33,15 +33,26 @@ let b: B = C.base; // CHECK:STDOUT: %.7: type = ptr_type %.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B] diff --git a/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon b/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon index 813dbd561bd77..b01146065ffc5 100644 --- a/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon +++ b/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon @@ -42,20 +42,27 @@ fn AccessBInA(a: A) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .AccessBInA = %AccessBInA.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %AccessBInA.decl: %AccessBInA.type = fn_decl @AccessBInA [template = constants.%AccessBInA] { diff --git a/toolchain/check/testdata/class/fail_convert_to_invalid.carbon b/toolchain/check/testdata/class/fail_convert_to_invalid.carbon index cb022533432dc..b146d5a9a4436 100644 --- a/toolchain/check/testdata/class/fail_convert_to_invalid.carbon +++ b/toolchain/check/testdata/class/fail_convert_to_invalid.carbon @@ -30,14 +30,25 @@ fn Make() -> C { // CHECK:STDOUT: %.3: type = struct_type {.a: i32} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .Make = %Make.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] { // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] diff --git a/toolchain/check/testdata/class/fail_derived_to_base.carbon b/toolchain/check/testdata/class/fail_derived_to_base.carbon index 08a981617579a..c12c076ee17d5 100644 --- a/toolchain/check/testdata/class/fail_derived_to_base.carbon +++ b/toolchain/check/testdata/class/fail_derived_to_base.carbon @@ -65,14 +65,22 @@ fn ConvertIncomplete(p: Incomplete*) -> A2* { return p; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A1 = %A1.decl // CHECK:STDOUT: .A2 = %A2.decl // CHECK:STDOUT: .B2 = %B2.decl @@ -81,7 +89,6 @@ fn ConvertIncomplete(p: Incomplete*) -> A2* { return p; } // CHECK:STDOUT: .ConvertIncomplete = %ConvertIncomplete.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A1.decl: type = class_decl @A1 [template = constants.%A1] {} // CHECK:STDOUT: %A2.decl: type = class_decl @A2 [template = constants.%A2] {} // CHECK:STDOUT: %B2.decl: type = class_decl @B2 [template = constants.%B2] {} diff --git a/toolchain/check/testdata/class/fail_extend_cycle.carbon b/toolchain/check/testdata/class/fail_extend_cycle.carbon index 205ce7147bffa..4b9fe9c77a2c4 100644 --- a/toolchain/check/testdata/class/fail_extend_cycle.carbon +++ b/toolchain/check/testdata/class/fail_extend_cycle.carbon @@ -45,14 +45,25 @@ base class A { // CHECK:STDOUT: %.7: type = unbound_element_type %.6, %A [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.6] {} diff --git a/toolchain/check/testdata/class/fail_field_modifiers.carbon b/toolchain/check/testdata/class/fail_field_modifiers.carbon index f02b505544b03..9e3bef245c1df 100644 --- a/toolchain/check/testdata/class/fail_field_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_field_modifiers.carbon @@ -48,19 +48,25 @@ class Class { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_generic_method.carbon b/toolchain/check/testdata/class/fail_generic_method.carbon index ab0686f9e4a4b..33e094c26ed8b 100644 --- a/toolchain/check/testdata/class/fail_generic_method.carbon +++ b/toolchain/check/testdata/class/fail_generic_method.carbon @@ -38,10 +38,10 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic] +// CHECK:STDOUT: %F: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.a: %T} [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] @@ -51,26 +51,35 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc32_14.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc32_14.2: type = converted %int.make_type_32, %.loc32_14.1 [template = i32] // CHECK:STDOUT: %N.loc32_10.1: i32 = param N -// CHECK:STDOUT: %N.loc32_10.2: i32 = bind_symbolic_name N 0, %N.loc32_10.1 [symbolic = %N.loc32_10.2 (constants.%N)] +// CHECK:STDOUT: %N.loc32_10.2: i32 = bind_symbolic_name N 0, %N.loc32_10.1 [symbolic = @.1.%N (constants.%N)] // CHECK:STDOUT: %Self.ref: = name_ref Self, [template = ] // CHECK:STDOUT: %self.loc32_21.1: = param self // CHECK:STDOUT: @.1.%self: = bind_name self, %self.loc32_21.1 @@ -80,34 +89,73 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: %.2 = field_decl a, element0 [template] -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %.loc13: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = %.loc13 (constants.%Class.2)] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc13 [symbolic = %.loc13 (constants.%Class.2)] -// CHECK:STDOUT: %self.loc13_8.1: @Class.%.loc13 (%Class.2) = param self -// CHECK:STDOUT: %self.loc13_8.2: @Class.%.loc13 (%Class.2) = bind_name self, %self.loc13_8.1 -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc13 (constants.%T)] -// CHECK:STDOUT: %n.loc13_20.1: @Class.%T.ref.loc13 (%T) = param n -// CHECK:STDOUT: %n.loc13_20.2: @Class.%T.ref.loc13 (%T) = bind_name n, %n.loc13_20.1 -// CHECK:STDOUT: } +// CHECK:STDOUT: generic class @Class(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @Class.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .a = %.loc12 -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc12: @Class.%.1 (%.2) = field_decl a, element0 [template] +// CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F)] { +// CHECK:STDOUT: %.loc13: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @F.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc13 [symbolic = @F.%Class (constants.%Class.2)] +// CHECK:STDOUT: %self.loc13_8.1: @F.%Class (%Class.2) = param self +// CHECK:STDOUT: %self.loc13_8.2: @F.%Class (%Class.2) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %n.loc13_20.1: @F.%T (%T) = param n +// CHECK:STDOUT: %n.loc13_20.2: @F.%T (%T) = bind_name n, %n.loc13_20.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .a = %.loc12 +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[@Class.%self.loc13_8.2: @Class.%.loc13 (%Class.2)](@Class.%n.loc13_20.2: @Class.%T.ref.loc13 (%T)) -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type]; +// CHECK:STDOUT: generic fn @F(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Class.%self.loc13_8.2: @F.%Class (%Class.2)](@Class.%n.loc13_20.2: @F.%T (%T)); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1[%self: ](%n: ) -// CHECK:STDOUT: generic [file.%N.loc32_10.2: i32] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @.1(file.%N.loc32_10.2: i32) { +// CHECK:STDOUT: %N: i32 = bind_symbolic_name N 0 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: ](%n: ) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@F.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%N) { +// CHECK:STDOUT: %N => constants.%N // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_import_misuses.carbon b/toolchain/check/testdata/class/fail_import_misuses.carbon index 8e124d57ad7f9..04ee287d48d42 100644 --- a/toolchain/check/testdata/class/fail_import_misuses.carbon +++ b/toolchain/check/testdata/class/fail_import_misuses.carbon @@ -55,14 +55,25 @@ var a: Incomplete; // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: .Incomplete = %Incomplete.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Empty.decl: type = class_decl @Empty [template = constants.%Empty] {} // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} // CHECK:STDOUT: } @@ -84,21 +95,29 @@ var a: Incomplete; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%Empty] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loaded [template = constants.%Incomplete] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%Empty] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//a, inst+6, loaded [template = constants.%Incomplete] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Empty = imports.%import_ref.1 // CHECK:STDOUT: .Incomplete = imports.%import_ref.2 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.2] {} // CHECK:STDOUT: %Incomplete.ref: type = name_ref Incomplete, imports.%import_ref.2 [template = constants.%Incomplete] // CHECK:STDOUT: %a.var: ref = var a diff --git a/toolchain/check/testdata/class/fail_incomplete.carbon b/toolchain/check/testdata/class/fail_incomplete.carbon index 5e52700e55516..016600b7d9bfa 100644 --- a/toolchain/check/testdata/class/fail_incomplete.carbon +++ b/toolchain/check/testdata/class/fail_incomplete.carbon @@ -169,13 +169,22 @@ fn CallReturnIncomplete() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .CallClassFunction = %CallClassFunction.decl // CHECK:STDOUT: .global_var = %global_var @@ -190,7 +199,6 @@ fn CallReturnIncomplete() { // CHECK:STDOUT: .CallReturnIncomplete = %CallReturnIncomplete.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {} // CHECK:STDOUT: %CallClassFunction.decl: %CallClassFunction.type = fn_decl @CallClassFunction [template = constants.%CallClassFunction] {} diff --git a/toolchain/check/testdata/class/fail_init.carbon b/toolchain/check/testdata/class/fail_init.carbon index 019d1347b33d3..75a37433fd02f 100644 --- a/toolchain/check/testdata/class/fail_init.carbon +++ b/toolchain/check/testdata/class/fail_init.carbon @@ -51,18 +51,26 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_init_as_inplace.carbon b/toolchain/check/testdata/class/fail_init_as_inplace.carbon index 30e297da45ecd..a7f8786e139a4 100644 --- a/toolchain/check/testdata/class/fail_init_as_inplace.carbon +++ b/toolchain/check/testdata/class/fail_init_as_inplace.carbon @@ -47,19 +47,27 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class] diff --git a/toolchain/check/testdata/class/fail_memaccess_category.carbon b/toolchain/check/testdata/class/fail_memaccess_category.carbon index 3c8d66eff8851..43a8a2172f52a 100644 --- a/toolchain/check/testdata/class/fail_memaccess_category.carbon +++ b/toolchain/check/testdata/class/fail_memaccess_category.carbon @@ -57,15 +57,26 @@ fn F(s: {.a: A}, b: B) { // CHECK:STDOUT: %.8: type = ptr_type %.6 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { diff --git a/toolchain/check/testdata/class/fail_member_of_let.carbon b/toolchain/check/testdata/class/fail_member_of_let.carbon index ba32dd68df564..c30a09e70c7b4 100644 --- a/toolchain/check/testdata/class/fail_member_of_let.carbon +++ b/toolchain/check/testdata/class/fail_member_of_let.carbon @@ -40,17 +40,26 @@ fn T.F() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .T = @__global_init.%T // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_method.carbon b/toolchain/check/testdata/class/fail_method.carbon index e5ed9bae46727..52a4fdfa0b7af 100644 --- a/toolchain/check/testdata/class/fail_method.carbon +++ b/toolchain/check/testdata/class/fail_method.carbon @@ -61,15 +61,26 @@ fn F(c: Class) { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Class.ref.loc16: type = name_ref Class, %Class.decl [template = constants.%Class] // CHECK:STDOUT: %WithSelf.ref: %WithSelf.type = name_ref WithSelf, @Class.%WithSelf.decl [template = constants.%WithSelf] diff --git a/toolchain/check/testdata/class/fail_method_modifiers.carbon b/toolchain/check/testdata/class/fail_method_modifiers.carbon index 31f2a5bbb0ea7..b773fbff2ae5a 100644 --- a/toolchain/check/testdata/class/fail_method_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_method_modifiers.carbon @@ -75,15 +75,26 @@ base class BaseClass { // CHECK:STDOUT: %Abstract.2: %Abstract.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .FinalClass = %FinalClass.decl // CHECK:STDOUT: .AbstractClass = %AbstractClass.decl // CHECK:STDOUT: .BaseClass = %BaseClass.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %FinalClass.decl: type = class_decl @FinalClass [template = constants.%FinalClass] {} // CHECK:STDOUT: %AbstractClass.decl: type = class_decl @AbstractClass [template = constants.%AbstractClass] {} // CHECK:STDOUT: %BaseClass.decl: type = class_decl @BaseClass [template = constants.%BaseClass] {} diff --git a/toolchain/check/testdata/class/fail_method_redefinition.carbon b/toolchain/check/testdata/class/fail_method_redefinition.carbon index 592960990e4f6..2433267984225 100644 --- a/toolchain/check/testdata/class/fail_method_redefinition.carbon +++ b/toolchain/check/testdata/class/fail_method_redefinition.carbon @@ -29,13 +29,24 @@ class Class { // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_modifiers.carbon b/toolchain/check/testdata/class/fail_modifiers.carbon index e6cf8ade13a7f..d90888257d320 100644 --- a/toolchain/check/testdata/class/fail_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_modifiers.carbon @@ -88,9 +88,21 @@ extern class ExternDefined {} // CHECK:STDOUT: %ExternDefined: type = class_type @ExternDefined [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .DuplicatePrivate [private] = %DuplicatePrivate.decl // CHECK:STDOUT: .TwoAccess [private] = %TwoAccess.decl // CHECK:STDOUT: .TwoAbstract = %TwoAbstract.decl @@ -100,7 +112,6 @@ extern class ExternDefined {} // CHECK:STDOUT: .ExternDefined = %ExternDefined.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %DuplicatePrivate.decl: type = class_decl @DuplicatePrivate [template = constants.%DuplicatePrivate] {} // CHECK:STDOUT: %TwoAccess.decl: type = class_decl @TwoAccess [template = constants.%TwoAccess] {} // CHECK:STDOUT: %TwoAbstract.decl: type = class_decl @TwoAbstract [template = constants.%TwoAbstract] {} diff --git a/toolchain/check/testdata/class/fail_out_of_line_decl.carbon b/toolchain/check/testdata/class/fail_out_of_line_decl.carbon index bfaefccde8349..d35f5477e81eb 100644 --- a/toolchain/check/testdata/class/fail_out_of_line_decl.carbon +++ b/toolchain/check/testdata/class/fail_out_of_line_decl.carbon @@ -25,13 +25,24 @@ fn C.F() {} // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_redeclaration_introducer.carbon b/toolchain/check/testdata/class/fail_redeclaration_introducer.carbon index 06fb20066ce25..660a18d5f00aa 100644 --- a/toolchain/check/testdata/class/fail_redeclaration_introducer.carbon +++ b/toolchain/check/testdata/class/fail_redeclaration_introducer.carbon @@ -98,13 +98,24 @@ base class F {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl.loc4: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %A.decl.loc12: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: } @@ -121,13 +132,24 @@ base class F {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl.loc4: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %B.decl.loc12: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: } @@ -144,13 +166,24 @@ base class F {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl.loc4: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %C.decl.loc12: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -167,13 +200,24 @@ base class F {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .D = %D.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.decl.loc4: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: %D.decl.loc12: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: } @@ -190,13 +234,24 @@ base class F {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .E = %E.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %E.decl.loc4: type = class_decl @E [template = constants.%E] {} // CHECK:STDOUT: %E.decl.loc12: type = class_decl @E [template = constants.%E] {} // CHECK:STDOUT: } @@ -213,13 +268,24 @@ base class F {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl.loc4: type = class_decl @F [template = constants.%F] {} // CHECK:STDOUT: %F.decl.loc11: type = class_decl @F [template = constants.%F] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_redeclaration_scope.carbon b/toolchain/check/testdata/class/fail_redeclaration_scope.carbon index 8010148eb471c..808305c16d71d 100644 --- a/toolchain/check/testdata/class/fail_redeclaration_scope.carbon +++ b/toolchain/check/testdata/class/fail_redeclaration_scope.carbon @@ -38,15 +38,26 @@ class Y { // CHECK:STDOUT: %.2: type = class_type @.1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl.loc11 // CHECK:STDOUT: .X = %X.decl // CHECK:STDOUT: .Y = %Y.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl.loc11: type = class_decl @A.1 [template = constants.%A.1] {} // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} // CHECK:STDOUT: %A.decl.loc19: type = class_decl @A.1 [template = constants.%A.1] {} diff --git a/toolchain/check/testdata/class/fail_redefinition.carbon b/toolchain/check/testdata/class/fail_redefinition.carbon index 251ec9436f9f4..75490c659c11f 100644 --- a/toolchain/check/testdata/class/fail_redefinition.carbon +++ b/toolchain/check/testdata/class/fail_redefinition.carbon @@ -65,13 +65,24 @@ fn Class.I() {} // CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.3] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} diff --git a/toolchain/check/testdata/class/fail_scope.carbon b/toolchain/check/testdata/class/fail_scope.carbon index b98ab4c088dc8..720f9d4a61074 100644 --- a/toolchain/check/testdata/class/fail_scope.carbon +++ b/toolchain/check/testdata/class/fail_scope.carbon @@ -37,18 +37,26 @@ fn G() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/fail_self.carbon b/toolchain/check/testdata/class/fail_self.carbon index b1c65dfc82838..06bb84206b50e 100644 --- a/toolchain/check/testdata/class/fail_self.carbon +++ b/toolchain/check/testdata/class/fail_self.carbon @@ -70,15 +70,26 @@ fn CallWrongSelf(ws: WrongSelf) { // CHECK:STDOUT: %CallWrongSelf: %CallWrongSelf.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .WrongSelf = %WrongSelf.decl // CHECK:STDOUT: .CallWrongSelf = %CallWrongSelf.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { // CHECK:STDOUT: %Self.ref.loc25: type = name_ref Self, constants.%Class [template = constants.%Class] diff --git a/toolchain/check/testdata/class/fail_todo_modifiers.carbon b/toolchain/check/testdata/class/fail_todo_modifiers.carbon index aeb970659d6a2..95a4bbc6ed7e3 100644 --- a/toolchain/check/testdata/class/fail_todo_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_todo_modifiers.carbon @@ -83,19 +83,27 @@ abstract class Abstract { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Access = %Access.decl // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Abstract = %Abstract.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Access.decl: type = class_decl @Access [template = constants.%Access] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {} diff --git a/toolchain/check/testdata/class/fail_unbound_field.carbon b/toolchain/check/testdata/class/fail_unbound_field.carbon index a05e208ff2c2a..29c48404bd17d 100644 --- a/toolchain/check/testdata/class/fail_unbound_field.carbon +++ b/toolchain/check/testdata/class/fail_unbound_field.carbon @@ -43,19 +43,26 @@ fn G() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/fail_unknown_member.carbon b/toolchain/check/testdata/class/fail_unknown_member.carbon index 0381e5e0de06f..67882ea07b38a 100644 --- a/toolchain/check/testdata/class/fail_unknown_member.carbon +++ b/toolchain/check/testdata/class/fail_unknown_member.carbon @@ -35,18 +35,26 @@ fn G(c: Class) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class] diff --git a/toolchain/check/testdata/class/field_access.carbon b/toolchain/check/testdata/class/field_access.carbon index 0b55477035add..b65c2882d5a0f 100644 --- a/toolchain/check/testdata/class/field_access.carbon +++ b/toolchain/check/testdata/class/field_access.carbon @@ -38,20 +38,26 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/field_access_in_value.carbon b/toolchain/check/testdata/class/field_access_in_value.carbon index 9faae685ef132..81570be7b6243 100644 --- a/toolchain/check/testdata/class/field_access_in_value.carbon +++ b/toolchain/check/testdata/class/field_access_in_value.carbon @@ -39,20 +39,26 @@ fn Test() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Test = %Test.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [template = constants.%Test] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/forward_declared.carbon b/toolchain/check/testdata/class/forward_declared.carbon index bdb4540eae0af..82d285afd953b 100644 --- a/toolchain/check/testdata/class/forward_declared.carbon +++ b/toolchain/check/testdata/class/forward_declared.carbon @@ -22,14 +22,25 @@ fn F(p: Class*) -> Class* { return p; } // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Class.ref.loc13_9: type = name_ref Class, %Class.decl [template = constants.%Class] diff --git a/toolchain/check/testdata/class/generic.carbon b/toolchain/check/testdata/class/generic.carbon index 91e6c22ce7f33..52b77b34ead31 100644 --- a/toolchain/check/testdata/class/generic.carbon +++ b/toolchain/check/testdata/class/generic.carbon @@ -19,13 +19,24 @@ class C[](); // CHECK:STDOUT: %C.2: type = class_type @C [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/basic.carbon b/toolchain/check/testdata/class/generic/basic.carbon index df253041af6a2..38963fc0eee8d 100644 --- a/toolchain/check/testdata/class/generic/basic.carbon +++ b/toolchain/check/testdata/class/generic/basic.carbon @@ -21,6 +21,7 @@ class Class(T:! type) { var k: T; } +class Declaration(T:! type); // CHECK:STDOUT: --- basic.carbon // CHECK:STDOUT: @@ -29,80 +30,174 @@ class Class(T:! type) { // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %.2: type = ptr_type %Class.2 [symbolic] // CHECK:STDOUT: %.3: type = ptr_type %T [symbolic] -// CHECK:STDOUT: %GetAddr.type: type = fn_type @GetAddr [template] -// CHECK:STDOUT: %GetAddr: %GetAddr.type = struct_value () [template] -// CHECK:STDOUT: %GetValue.type: type = fn_type @GetValue [template] -// CHECK:STDOUT: %GetValue: %GetValue.type = struct_value () [template] +// CHECK:STDOUT: %GetAddr.type: type = fn_type @GetAddr, @Class(%T) [symbolic] +// CHECK:STDOUT: %GetAddr.1: %GetAddr.type = struct_value () [symbolic] +// CHECK:STDOUT: %GetValue.type: type = fn_type @GetValue, @Class(%T) [symbolic] +// CHECK:STDOUT: %GetValue.1: %GetValue.type = struct_value () [symbolic] // CHECK:STDOUT: %.4: type = unbound_element_type %Class.2, %T [symbolic] // CHECK:STDOUT: %.5: type = struct_type {.k: %T} [symbolic] +// CHECK:STDOUT: %GetAddr.2: %GetAddr.type = struct_value () [symbolic] +// CHECK:STDOUT: %GetValue.2: %GetValue.type = struct_value () [symbolic] // CHECK:STDOUT: %.6: type = ptr_type %.5 [symbolic] +// CHECK:STDOUT: %Declaration.type: type = generic_class_type @Declaration [template] +// CHECK:STDOUT: %Declaration.1: %Declaration.type = struct_value () [template] +// CHECK:STDOUT: %Declaration.2: type = class_type @Declaration, @Declaration(%T) [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl +// CHECK:STDOUT: .Declaration = %Declaration.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Declaration.decl: %Declaration.type = class_decl @Declaration [template = constants.%Declaration.1] { +// CHECK:STDOUT: %T.loc24_19.1: type = param T +// CHECK:STDOUT: %T.loc24_19.2: type = bind_symbolic_name T 0, %T.loc24_19.1 [symbolic = @Declaration.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %GetAddr.decl: %GetAddr.type = fn_decl @GetAddr [template = constants.%GetAddr] { -// CHECK:STDOUT: %.loc12_25: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = %.loc12_25 (constants.%Class.2)] -// CHECK:STDOUT: %Self.ref.loc12: type = name_ref Self, %.loc12_25 [symbolic = %.loc12_25 (constants.%Class.2)] -// CHECK:STDOUT: %.loc12_29: type = ptr_type %Class.2 [symbolic = %.loc12_29 (constants.%.2)] -// CHECK:STDOUT: %self.loc12_19.1: @Class.%.loc12_29 (%.2) = param self -// CHECK:STDOUT: %self.loc12_19.3: @Class.%.loc12_29 (%.2) = bind_name self, %self.loc12_19.1 -// CHECK:STDOUT: %.loc12_14: @Class.%.loc12_29 (%.2) = addr_pattern %self.loc12_19.3 -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12 (constants.%T)] -// CHECK:STDOUT: %.loc12_38: type = ptr_type %T [symbolic = %.loc12_38 (constants.%.3)] -// CHECK:STDOUT: %return.var.loc12: ref %.3 = var +// CHECK:STDOUT: generic class @Class(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %GetAddr.type: type = fn_type @GetAddr, @Class(%T) [symbolic = %GetAddr.type (constants.%GetAddr.type)] +// CHECK:STDOUT: %GetAddr: @Class.%GetAddr.type (%GetAddr.type) = struct_value () [symbolic = %GetAddr (constants.%GetAddr.1)] +// CHECK:STDOUT: %GetValue.type: type = fn_type @GetValue, @Class(%T) [symbolic = %GetValue.type (constants.%GetValue.type)] +// CHECK:STDOUT: %GetValue: @Class.%GetValue.type (%GetValue.type) = struct_value () [symbolic = %GetValue (constants.%GetValue.1)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %GetAddr.decl: @Class.%GetAddr.type (%GetAddr.type) = fn_decl @GetAddr [symbolic = %GetAddr (constants.%GetAddr.1)] { +// CHECK:STDOUT: %.loc12_25: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @GetAddr.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref.loc12: type = name_ref Self, %.loc12_25 [symbolic = @GetAddr.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc12_29: type = ptr_type %Class.2 [symbolic = @GetAddr.%.1 (constants.%.2)] +// CHECK:STDOUT: %self.loc12_19.1: @GetAddr.%.1 (%.2) = param self +// CHECK:STDOUT: %self.loc12_19.3: @GetAddr.%.1 (%.2) = bind_name self, %self.loc12_19.1 +// CHECK:STDOUT: %.loc12_14: @GetAddr.%.1 (%.2) = addr_pattern %self.loc12_19.3 +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = @GetAddr.%T (constants.%T)] +// CHECK:STDOUT: %.loc12_38: type = ptr_type %T [symbolic = @GetAddr.%.2 (constants.%.3)] +// CHECK:STDOUT: %return.var.loc12: ref @GetAddr.%.2 (%.3) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %GetValue.decl: @Class.%GetValue.type (%GetValue.type) = fn_decl @GetValue [symbolic = %GetValue (constants.%GetValue.1)] { +// CHECK:STDOUT: %.loc17: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @GetValue.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, %.loc17 [symbolic = @GetValue.%Class (constants.%Class.2)] +// CHECK:STDOUT: %self.loc17_15.1: @GetValue.%Class (%Class.2) = param self +// CHECK:STDOUT: %self.loc17_15.2: @GetValue.%Class (%Class.2) = bind_name self, %self.loc17_15.1 +// CHECK:STDOUT: %T.ref.loc17: type = name_ref T, file.%T.loc11_13.2 [symbolic = @GetValue.%T (constants.%T)] +// CHECK:STDOUT: %return.var.loc17: ref @GetValue.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %T.ref.loc21: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc21: @Class.%.1 (%.4) = field_decl k, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .GetAddr = %GetAddr.decl +// CHECK:STDOUT: .GetValue = %GetValue.decl +// CHECK:STDOUT: .k = %.loc21 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Declaration(file.%T.loc24_19.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @GetAddr(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = ptr_type @GetAddr.%Class (%Class.2) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %.2: type = ptr_type @GetAddr.%T (%T) [symbolic = %.2 (constants.%.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.3: type = unbound_element_type @GetAddr.%Class (%Class.2), @GetAddr.%T (%T) [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr @Class.%self.loc12_19.3: @GetAddr.%.1 (%.2)]() -> @GetAddr.%.2 (%.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @GetAddr.%.1 (%.2) = name_ref self, @Class.%self.loc12_19.3 +// CHECK:STDOUT: %.loc13_17.1: ref @GetAddr.%Class (%Class.2) = deref %self.ref +// CHECK:STDOUT: %k.ref: @GetAddr.%.3 (%.4) = name_ref k, @Class.%.loc21 [template = @Class.%.loc21] +// CHECK:STDOUT: %.loc13_17.2: ref @GetAddr.%T (%T) = class_element_access %.loc13_17.1, element0 +// CHECK:STDOUT: %.loc13_12: @GetAddr.%.2 (%.3) = addr_of %.loc13_17.2 +// CHECK:STDOUT: return %.loc13_12 // CHECK:STDOUT: } -// CHECK:STDOUT: %GetValue.decl: %GetValue.type = fn_decl @GetValue [template = constants.%GetValue] { -// CHECK:STDOUT: %.loc17: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = %.loc17 (constants.%Class.2)] -// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, %.loc17 [symbolic = %.loc17 (constants.%Class.2)] -// CHECK:STDOUT: %self.loc17_15.1: @Class.%.loc17 (%Class.2) = param self -// CHECK:STDOUT: %self.loc17_15.2: @Class.%.loc17 (%Class.2) = bind_name self, %self.loc17_15.1 -// CHECK:STDOUT: %T.ref.loc17: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc17 (constants.%T)] -// CHECK:STDOUT: %return.var.loc17: ref %T = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @GetValue(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = unbound_element_type @GetValue.%Class (%Class.2), @GetValue.%T (%T) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Class.%self.loc17_15.2: @GetValue.%Class (%Class.2)]() -> @GetValue.%T (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @GetValue.%Class (%Class.2) = name_ref self, @Class.%self.loc17_15.2 +// CHECK:STDOUT: %k.ref: @GetValue.%.1 (%.4) = name_ref k, @Class.%.loc21 [template = @Class.%.loc21] +// CHECK:STDOUT: %.loc18_16.1: ref @GetValue.%T (%T) = class_element_access %self.ref, element0 +// CHECK:STDOUT: %.loc18_16.2: @GetValue.%T (%T) = bind_value %.loc18_16.1 +// CHECK:STDOUT: return %.loc18_16.2 // CHECK:STDOUT: } -// CHECK:STDOUT: %T.ref.loc21: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc21: %.4 = field_decl k, element0 [template] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .GetAddr = %GetAddr.decl -// CHECK:STDOUT: .GetValue = %GetValue.decl -// CHECK:STDOUT: .k = %.loc21 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @GetAddr[addr @Class.%self.loc12_19.3: @Class.%.loc12_29 (%.2)]() -> %.3 -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %self.ref: %.2 = name_ref self, @Class.%self.loc12_19.3 -// CHECK:STDOUT: %.loc13_17.1: ref %Class.2 = deref %self.ref -// CHECK:STDOUT: %k.ref: %.4 = name_ref k, @Class.%.loc21 [template = @Class.%.loc21] -// CHECK:STDOUT: %.loc13_17.2: ref %T = class_element_access %.loc13_17.1, element0 -// CHECK:STDOUT: %.loc13_12: %.3 = addr_of %.loc13_17.2 -// CHECK:STDOUT: return %.loc13_12 +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %GetAddr.type => constants.%GetAddr.type +// CHECK:STDOUT: %GetAddr => constants.%GetAddr.2 +// CHECK:STDOUT: %GetValue.type => constants.%GetValue.type +// CHECK:STDOUT: %GetValue => constants.%GetValue.2 +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@GetAddr.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GetAddr(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: %.2 => constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@GetValue.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GetValue(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @GetValue[@Class.%self.loc17_15.2: @Class.%.loc17 (%Class.2)]() -> %T -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %self.ref: %Class.2 = name_ref self, @Class.%self.loc17_15.2 -// CHECK:STDOUT: %k.ref: %.4 = name_ref k, @Class.%.loc21 [template = @Class.%.loc21] -// CHECK:STDOUT: %.loc18_16.1: ref %T = class_element_access %self.ref, element0 -// CHECK:STDOUT: %.loc18_16.2: %T = bind_value %.loc18_16.1 -// CHECK:STDOUT: return %.loc18_16.2 +// CHECK:STDOUT: specific @Declaration(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/call.carbon b/toolchain/check/testdata/class/generic/call.carbon index f05eacabb732e..76d7459f7dd44 100644 --- a/toolchain/check/testdata/class/generic/call.carbon +++ b/toolchain/check/testdata/class/generic/call.carbon @@ -63,6 +63,25 @@ class Class(T:! type, N:! i32) {} // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var a: Class(5, i32*); +// --- call_in_nested_return_type.carbon + +class Outer(T:! type) { + class Inner(U:! type) { + fn A() -> Outer(T) { + return {}; + } + fn B() -> Outer(U) { + return {}; + } + fn C() -> Inner(T) { + return {}; + } + fn D() -> Inner(U) { + return {}; + } + } +} + // CHECK:STDOUT: --- call.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -73,38 +92,46 @@ var a: Class(5, i32*); // CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T, %N) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T, %N) [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = ptr_type i32 [template] // CHECK:STDOUT: %.4: i32 = int_literal 5 [template] -// CHECK:STDOUT: %Class.3: type = class_type @Class, (%.3, %.4) [template] +// CHECK:STDOUT: %Class.3: type = class_type @Class, @Class(%.3, %.4) [template] // CHECK:STDOUT: %.5: type = ptr_type %.2 [template] // CHECK:STDOUT: %.6: i32 = int_literal 0 [template] -// CHECK:STDOUT: %Class.4: type = class_type @Class, (%.1, %.6) [template] +// CHECK:STDOUT: %Class.4: type = class_type @Class, @Class(%.1, %.6) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = @Class.%N (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref.loc6: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32] @@ -128,14 +155,39 @@ var a: Class(5, i32*); // CHECK:STDOUT: %b: ref %Class.4 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T, constants.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%.3, constants.%.4) { +// CHECK:STDOUT: %T => constants.%.3 +// CHECK:STDOUT: %N => constants.%.4 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%.1, constants.%.6) { +// CHECK:STDOUT: %T => constants.%.1 +// CHECK:STDOUT: %N => constants.%.6 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_too_few.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -146,32 +198,40 @@ var a: Class(5, i32*); // CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T, %N) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T, %N) [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = ptr_type i32 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = @Class.%N (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32] @@ -185,14 +245,25 @@ var a: Class(5, i32*); // CHECK:STDOUT: %a: ref = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T, constants.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_too_many.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -203,7 +274,7 @@ var a: Class(5, i32*); // CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T, %N) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T, %N) [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = ptr_type i32 [template] // CHECK:STDOUT: %.4: i32 = int_literal 1 [template] @@ -211,26 +282,34 @@ var a: Class(5, i32*); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = @Class.%N (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32] @@ -246,14 +325,25 @@ var a: Class(5, i32*); // CHECK:STDOUT: %a: ref = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T, constants.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_no_conversion.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -264,33 +354,41 @@ var a: Class(5, i32*); // CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T, %N) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T, %N) [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: i32 = int_literal 5 [template] // CHECK:STDOUT: %.4: type = ptr_type i32 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = @Class.%N (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %.loc12_14: i32 = int_literal 5 [template = constants.%.3] @@ -305,11 +403,317 @@ var a: Class(5, i32*); // CHECK:STDOUT: %a: ref = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type, file.%N.loc4_23.2: i32) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: i32 = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T, constants.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- call_in_nested_return_type.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Outer.type: type = generic_class_type @Outer [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Outer.1: %Outer.type = struct_value () [template] +// CHECK:STDOUT: %Outer.2: type = class_type @Outer, @Outer(%T) [symbolic] +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic] +// CHECK:STDOUT: %Inner.type: type = generic_class_type @Inner [template] +// CHECK:STDOUT: %Inner.1: %Inner.type = struct_value () [template] +// CHECK:STDOUT: %Inner.2: type = class_type @Inner, @Inner(%T, %U) [symbolic] +// CHECK:STDOUT: %A.type.1: type = fn_type @A, @Inner(%T, %U) [symbolic] +// CHECK:STDOUT: %A.1: %A.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %Outer.3: type = class_type @Outer, @Outer(%U) [symbolic] +// CHECK:STDOUT: %B.type.1: type = fn_type @B, @Inner(%T, %U) [symbolic] +// CHECK:STDOUT: %B.1: %B.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %Inner.3: type = class_type @Inner, @Inner(%T) [symbolic] +// CHECK:STDOUT: %C.type.1: type = fn_type @C, @Inner(%T, %U) [symbolic] +// CHECK:STDOUT: %C.1: %C.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %Inner.4: type = class_type @Inner, @Inner(%U) [symbolic] +// CHECK:STDOUT: %D.type.1: type = fn_type @D, @Inner(%T, %U) [symbolic] +// CHECK:STDOUT: %D.1: %D.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %.3: type = ptr_type %.2 [template] +// CHECK:STDOUT: %struct.1: %Outer.2 = struct_value () [symbolic] +// CHECK:STDOUT: %struct.2: %Outer.3 = struct_value () [symbolic] +// CHECK:STDOUT: %A.2: %A.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %B.2: %B.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %C.2: %C.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %D.2: %D.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %struct.3: %Inner.3 = struct_value () [symbolic] +// CHECK:STDOUT: %A.type.2: type = fn_type @A, @Inner(%U, %U) [symbolic] +// CHECK:STDOUT: %A.3: %A.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %B.type.2: type = fn_type @B, @Inner(%U, %U) [symbolic] +// CHECK:STDOUT: %B.3: %B.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %C.type.2: type = fn_type @C, @Inner(%U, %U) [symbolic] +// CHECK:STDOUT: %C.3: %C.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %D.type.2: type = fn_type @D, @Inner(%U, %U) [symbolic] +// CHECK:STDOUT: %D.3: %D.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %struct.4: %Inner.4 = struct_value () [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Outer = %Outer.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Outer.decl: %Outer.type = class_decl @Outer [template = constants.%Outer.1] { +// CHECK:STDOUT: %T.loc2_13.1: type = param T +// CHECK:STDOUT: %T.loc2_13.2: type = bind_symbolic_name T 0, %T.loc2_13.1 [symbolic = @Outer.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Outer(file.%T.loc2_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %Inner.decl: %Inner.type = class_decl @Inner [template = constants.%Inner.1] { +// CHECK:STDOUT: %U.loc3_15.1: type = param U +// CHECK:STDOUT: %U.loc3_15.2: type = bind_symbolic_name U 1, %U.loc3_15.1 [symbolic = @Inner.%U (constants.%U)] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Outer.2 +// CHECK:STDOUT: .Inner = %Inner.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Inner(file.%T.loc2_13.2: type, @Outer.%U.loc3_15.2: type) { +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %A.type: type = fn_type @A, @Inner(%T, %U) [symbolic = %A.type (constants.%A.type.1)] +// CHECK:STDOUT: %A: @Inner.%A.type (%A.type.1) = struct_value () [symbolic = %A (constants.%A.1)] +// CHECK:STDOUT: %B.type: type = fn_type @B, @Inner(%T, %U) [symbolic = %B.type (constants.%B.type.1)] +// CHECK:STDOUT: %B: @Inner.%B.type (%B.type.1) = struct_value () [symbolic = %B (constants.%B.1)] +// CHECK:STDOUT: %C.type: type = fn_type @C, @Inner(%T, %U) [symbolic = %C.type (constants.%C.type.1)] +// CHECK:STDOUT: %C: @Inner.%C.type (%C.type.1) = struct_value () [symbolic = %C (constants.%C.1)] +// CHECK:STDOUT: %D.type: type = fn_type @D, @Inner(%T, %U) [symbolic = %D.type (constants.%D.type.1)] +// CHECK:STDOUT: %D: @Inner.%D.type (%D.type.1) = struct_value () [symbolic = %D (constants.%D.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %A.decl: @Inner.%A.type (%A.type.1) = fn_decl @A [symbolic = %A (constants.%A.1)] { +// CHECK:STDOUT: %Outer.ref.loc4: %Outer.type = name_ref Outer, file.%Outer.decl [template = constants.%Outer.1] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, file.%T.loc2_13.2 [symbolic = @A.%T (constants.%T)] +// CHECK:STDOUT: %.loc4_20: init type = call %Outer.ref.loc4(%T.ref.loc4) [symbolic = @A.%Outer (constants.%Outer.2)] +// CHECK:STDOUT: %.loc4_22.1: type = value_of_initializer %.loc4_20 [symbolic = @A.%Outer (constants.%Outer.2)] +// CHECK:STDOUT: %.loc4_22.2: type = converted %.loc4_20, %.loc4_22.1 [symbolic = @A.%Outer (constants.%Outer.2)] +// CHECK:STDOUT: %return.var.loc4: ref @A.%Outer (%Outer.2) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %B.decl: @Inner.%B.type (%B.type.1) = fn_decl @B [symbolic = %B (constants.%B.1)] { +// CHECK:STDOUT: %Outer.ref.loc7: %Outer.type = name_ref Outer, file.%Outer.decl [template = constants.%Outer.1] +// CHECK:STDOUT: %U.ref.loc7: type = name_ref U, @Outer.%U.loc3_15.2 [symbolic = @B.%U (constants.%U)] +// CHECK:STDOUT: %.loc7_20: init type = call %Outer.ref.loc7(%U.ref.loc7) [symbolic = @B.%Outer (constants.%Outer.3)] +// CHECK:STDOUT: %.loc7_22.1: type = value_of_initializer %.loc7_20 [symbolic = @B.%Outer (constants.%Outer.3)] +// CHECK:STDOUT: %.loc7_22.2: type = converted %.loc7_20, %.loc7_22.1 [symbolic = @B.%Outer (constants.%Outer.3)] +// CHECK:STDOUT: %return.var.loc7: ref @B.%Outer (%Outer.3) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: @Inner.%C.type (%C.type.1) = fn_decl @C [symbolic = %C (constants.%C.1)] { +// CHECK:STDOUT: %Inner.ref.loc10: %Inner.type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner.1] +// CHECK:STDOUT: %T.ref.loc10: type = name_ref T, file.%T.loc2_13.2 [symbolic = @C.%T (constants.%T)] +// CHECK:STDOUT: %.loc10_20: init type = call %Inner.ref.loc10(%T.ref.loc10) [symbolic = @C.%Inner (constants.%Inner.3)] +// CHECK:STDOUT: %.loc10_22.1: type = value_of_initializer %.loc10_20 [symbolic = @C.%Inner (constants.%Inner.3)] +// CHECK:STDOUT: %.loc10_22.2: type = converted %.loc10_20, %.loc10_22.1 [symbolic = @C.%Inner (constants.%Inner.3)] +// CHECK:STDOUT: %return.var.loc10: ref @C.%Inner (%Inner.3) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %D.decl: @Inner.%D.type (%D.type.1) = fn_decl @D [symbolic = %D (constants.%D.1)] { +// CHECK:STDOUT: %Inner.ref.loc13: %Inner.type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner.1] +// CHECK:STDOUT: %U.ref.loc13: type = name_ref U, @Outer.%U.loc3_15.2 [symbolic = @D.%U (constants.%U)] +// CHECK:STDOUT: %.loc13_20: init type = call %Inner.ref.loc13(%U.ref.loc13) [symbolic = @D.%Inner (constants.%Inner.4)] +// CHECK:STDOUT: %.loc13_22.1: type = value_of_initializer %.loc13_20 [symbolic = @D.%Inner (constants.%Inner.4)] +// CHECK:STDOUT: %.loc13_22.2: type = converted %.loc13_20, %.loc13_22.1 [symbolic = @D.%Inner (constants.%Inner.4)] +// CHECK:STDOUT: %return.var.loc13: ref @D.%Inner (%Inner.4) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Inner.2 +// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: .B = %B.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @A(file.%T.loc2_13.2: type, @Outer.%U.loc3_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Outer: type = class_type @Outer, @Outer(%T) [symbolic = %Outer (constants.%Outer.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %struct: @A.%Outer (%Outer.2) = struct_value () [symbolic = %struct (constants.%struct.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Inner.%return.var.loc4: @A.%Outer (%Outer.2) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc5_15.1: %.2 = struct_literal () +// CHECK:STDOUT: %.loc5_15.2: init @A.%Outer (%Outer.2) = class_init (), @Inner.%return.var.loc4 [symbolic = %struct (constants.%struct.1)] +// CHECK:STDOUT: %.loc5_16: init @A.%Outer (%Outer.2) = converted %.loc5_15.1, %.loc5_15.2 [symbolic = %struct (constants.%struct.1)] +// CHECK:STDOUT: return %.loc5_16 to @Inner.%return.var.loc4 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @B(file.%T.loc2_13.2: type, @Outer.%U.loc3_15.2: type) { +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: %Outer: type = class_type @Outer, @Outer(%U) [symbolic = %Outer (constants.%Outer.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %struct: @B.%Outer (%Outer.3) = struct_value () [symbolic = %struct (constants.%struct.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Inner.%return.var.loc7: @B.%Outer (%Outer.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8_15.1: %.2 = struct_literal () +// CHECK:STDOUT: %.loc8_15.2: init @B.%Outer (%Outer.3) = class_init (), @Inner.%return.var.loc7 [symbolic = %struct (constants.%struct.2)] +// CHECK:STDOUT: %.loc8_16: init @B.%Outer (%Outer.3) = converted %.loc8_15.1, %.loc8_15.2 [symbolic = %struct (constants.%struct.2)] +// CHECK:STDOUT: return %.loc8_16 to @Inner.%return.var.loc7 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @C(file.%T.loc2_13.2: type, @Outer.%U.loc3_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Inner: type = class_type @Inner, @Inner(%T) [symbolic = %Inner (constants.%Inner.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %struct: @C.%Inner (%Inner.3) = struct_value () [symbolic = %struct (constants.%struct.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Inner.%return.var.loc10: @C.%Inner (%Inner.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc11_15.1: %.2 = struct_literal () +// CHECK:STDOUT: %.loc11_15.2: init @C.%Inner (%Inner.3) = class_init (), @Inner.%return.var.loc10 [symbolic = %struct (constants.%struct.3)] +// CHECK:STDOUT: %.loc11_16: init @C.%Inner (%Inner.3) = converted %.loc11_15.1, %.loc11_15.2 [symbolic = %struct (constants.%struct.3)] +// CHECK:STDOUT: return %.loc11_16 to @Inner.%return.var.loc10 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @D(file.%T.loc2_13.2: type, @Outer.%U.loc3_15.2: type) { +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: %Inner: type = class_type @Inner, @Inner(%U) [symbolic = %Inner (constants.%Inner.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %struct: @D.%Inner (%Inner.4) = struct_value () [symbolic = %struct (constants.%struct.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Inner.%return.var.loc13: @D.%Inner (%Inner.4) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc14_15.1: %.2 = struct_literal () +// CHECK:STDOUT: %.loc14_15.2: init @D.%Inner (%Inner.4) = class_init (), @Inner.%return.var.loc13 [symbolic = %struct (constants.%struct.4)] +// CHECK:STDOUT: %.loc14_16: init @D.%Inner (%Inner.4) = converted %.loc14_15.1, %.loc14_15.2 [symbolic = %struct (constants.%struct.4)] +// CHECK:STDOUT: return %.loc14_16 to @Inner.%return.var.loc13 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Outer(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(constants.%T, constants.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Outer(@A.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @A(constants.%T, constants.%U) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Outer => constants.%Outer.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Outer(constants.%U) { +// CHECK:STDOUT: %T => constants.%U +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Outer(@B.%U) { +// CHECK:STDOUT: %T => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @B(constants.%T, constants.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: %Outer => constants.%Outer.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(constants.%T) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %A.type => constants.%A.type.1 +// CHECK:STDOUT: %A => constants.%A.2 +// CHECK:STDOUT: %B.type => constants.%B.type.1 +// CHECK:STDOUT: %B => constants.%B.2 +// CHECK:STDOUT: %C.type => constants.%C.type.1 +// CHECK:STDOUT: %C => constants.%C.2 +// CHECK:STDOUT: %D.type => constants.%D.type.1 +// CHECK:STDOUT: %D => constants.%D.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(@C.%T) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%T, constants.%U) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Inner => constants.%Inner.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(constants.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %T => constants.%U +// CHECK:STDOUT: %A.type => constants.%A.type.2 +// CHECK:STDOUT: %A => constants.%A.3 +// CHECK:STDOUT: %B.type => constants.%B.type.2 +// CHECK:STDOUT: %B => constants.%B.3 +// CHECK:STDOUT: %C.type => constants.%C.type.2 +// CHECK:STDOUT: %C => constants.%C.3 +// CHECK:STDOUT: %D.type => constants.%D.type.2 +// CHECK:STDOUT: %D => constants.%D.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(@D.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @D(constants.%T, constants.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: %Inner => constants.%Inner.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(@Inner.%T, @Inner.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(constants.%U, constants.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/fail_todo_use.carbon b/toolchain/check/testdata/class/generic/fail_todo_use.carbon deleted file mode 100644 index a5522e5215f3c..0000000000000 --- a/toolchain/check/testdata/class/generic/fail_todo_use.carbon +++ /dev/null @@ -1,145 +0,0 @@ -// 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 -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/fail_todo_use.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/fail_todo_use.carbon - -class Class(T:! type) { - fn Get[addr self: Self*]() -> T* { - return &self->k; - } - - var k: T; -} - -// TODO: The following should work. -fn Run() -> i32 { - // CHECK:STDERR: fail_todo_use.carbon:[[@LINE+4]]:23: ERROR: Cannot implicitly convert from `i32` to `T`. - // CHECK:STDERR: var v: Class(i32) = {.k = 0}; - // CHECK:STDERR: ^~~~~~~~ - // CHECK:STDERR: - var v: Class(i32) = {.k = 0}; - // CHECK:STDERR: fail_todo_use.carbon:[[@LINE+10]]:3: ERROR: Cannot implicitly convert from `T*` to `i32`. - // CHECK:STDERR: return v.Get(); - // CHECK:STDERR: ^~~~~~~~~~~~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_todo_use.carbon:[[@LINE+6]]:10: ERROR: Cannot implicitly convert from `Class*` to `Class*`. - // CHECK:STDERR: return v.Get(); - // CHECK:STDERR: ^~~~~~ - // CHECK:STDERR: fail_todo_use.carbon:[[@LINE-21]]:15: Initializing `addr self` parameter of method declared here. - // CHECK:STDERR: fn Get[addr self: Self*]() -> T* { - // CHECK:STDERR: ^~~~ - return v.Get(); -} - -// CHECK:STDOUT: --- fail_todo_use.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] -// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] -// CHECK:STDOUT: %.1: type = tuple_type () [template] -// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] -// CHECK:STDOUT: %.2: type = ptr_type %Class.2 [symbolic] -// CHECK:STDOUT: %.3: type = ptr_type %T [symbolic] -// CHECK:STDOUT: %Get.type: type = fn_type @Get [template] -// CHECK:STDOUT: %Get: %Get.type = struct_value () [template] -// CHECK:STDOUT: %.4: type = unbound_element_type %Class.2, %T [symbolic] -// CHECK:STDOUT: %.5: type = struct_type {.k: %T} [symbolic] -// CHECK:STDOUT: %.6: type = ptr_type %.5 [symbolic] -// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] -// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %Run.type: type = fn_type @Run [template] -// CHECK:STDOUT: %Run: %Run.type = struct_value () [template] -// CHECK:STDOUT: %Class.3: type = class_type @Class, (i32) [template] -// CHECK:STDOUT: %.7: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.8: type = struct_type {.k: i32} [template] -// CHECK:STDOUT: %.9: type = ptr_type %Class.3 [template] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Class = %Class.decl -// CHECK:STDOUT: .Run = %Run.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { -// CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] { -// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc20_13.1: type = value_of_initializer %int.make_type_32 [template = i32] -// CHECK:STDOUT: %.loc20_13.2: type = converted %int.make_type_32, %.loc20_13.1 [template = i32] -// CHECK:STDOUT: @Run.%return: ref i32 = var -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %Get.decl: %Get.type = fn_decl @Get [template = constants.%Get] { -// CHECK:STDOUT: %.loc12_21: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = %.loc12_21 (constants.%Class.2)] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc12_21 [symbolic = %.loc12_21 (constants.%Class.2)] -// CHECK:STDOUT: %.loc12_25: type = ptr_type %Class.2 [symbolic = %.loc12_25 (constants.%.2)] -// CHECK:STDOUT: %self.loc12_15.1: @Class.%.loc12_25 (%.2) = param self -// CHECK:STDOUT: %self.loc12_15.3: @Class.%.loc12_25 (%.2) = bind_name self, %self.loc12_15.1 -// CHECK:STDOUT: %.loc12_10: @Class.%.loc12_25 (%.2) = addr_pattern %self.loc12_15.3 -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12 (constants.%T)] -// CHECK:STDOUT: %.loc12_34: type = ptr_type %T [symbolic = %.loc12_34 (constants.%.3)] -// CHECK:STDOUT: %return.var: ref %.3 = var -// CHECK:STDOUT: } -// CHECK:STDOUT: %T.ref.loc16: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc16: %.4 = field_decl k, element0 [template] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .Get = %Get.decl -// CHECK:STDOUT: .k = %.loc16 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Get[addr @Class.%self.loc12_15.3: @Class.%.loc12_25 (%.2)]() -> %.3 -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %self.ref: %.2 = name_ref self, @Class.%self.loc12_15.3 -// CHECK:STDOUT: %.loc13_17.1: ref %Class.2 = deref %self.ref -// CHECK:STDOUT: %k.ref: %.4 = name_ref k, @Class.%.loc16 [template = @Class.%.loc16] -// CHECK:STDOUT: %.loc13_17.2: ref %T = class_element_access %.loc13_17.1, element0 -// CHECK:STDOUT: %.loc13_12: %.3 = addr_of %.loc13_17.2 -// CHECK:STDOUT: return %.loc13_12 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Run() -> i32 { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc25_15.1: type = value_of_initializer %int.make_type_32 [template = i32] -// CHECK:STDOUT: %.loc25_15.2: type = converted %int.make_type_32, %.loc25_15.1 [template = i32] -// CHECK:STDOUT: %.loc25_15.3: init type = call %Class.ref(%.loc25_15.2) [template = constants.%Class.3] -// CHECK:STDOUT: %.loc25_19.1: type = value_of_initializer %.loc25_15.3 [template = constants.%Class.3] -// CHECK:STDOUT: %.loc25_19.2: type = converted %.loc25_15.3, %.loc25_19.1 [template = constants.%Class.3] -// CHECK:STDOUT: %v.var: ref %Class.3 = var v -// CHECK:STDOUT: %v: ref %Class.3 = bind_name v, %v.var -// CHECK:STDOUT: %.loc25_29: i32 = int_literal 0 [template = constants.%.7] -// CHECK:STDOUT: %.loc25_30: %.8 = struct_literal (%.loc25_29) -// CHECK:STDOUT: assign %v.var, -// CHECK:STDOUT: %v.ref: ref %Class.3 = name_ref v, %v -// CHECK:STDOUT: %Get.ref: %Get.type = name_ref Get, @Class.%Get.decl [template = constants.%Get] -// CHECK:STDOUT: %.loc36_11: = bound_method %v.ref, %Get.ref -// CHECK:STDOUT: %.loc36_10: %.9 = addr_of %v.ref -// CHECK:STDOUT: %Get.call: init %.3 = call %.loc36_11() [template = ] -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/field.carbon b/toolchain/check/testdata/class/generic/field.carbon index 77694354aba7d..51a8eb2a8d5d1 100644 --- a/toolchain/check/testdata/class/generic/field.carbon +++ b/toolchain/check/testdata/class/generic/field.carbon @@ -7,47 +7,20 @@ // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/field.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/field.carbon -// CHECK:STDERR: fail_todo_field.carbon: ERROR: Main//default previously provided by `field.carbon`. -// CHECK:STDERR: - -// --- field.carbon class Class(T:! type) { var x: T; } -// TODO: This case only works because the parameters of Class and G have the -// same name and index, so canonicalize to the same type. -fn G(T:! type, c: Class(T)) -> T { +fn F(c: Class(i32)) -> i32 { return c.x; } -// --- fail_todo_field.carbon - -class Class(T:! type) { - var x: T; -} - -fn F(c: Class(i32)) -> i32 { - // CHECK:STDERR: fail_todo_field.carbon:[[@LINE+8]]:3: ERROR: Cannot implicitly convert from `T` to `i32`. - // CHECK:STDERR: return c.x; - // CHECK:STDERR: ^~~~~~~~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_todo_field.carbon:[[@LINE+4]]:10: ERROR: Cannot implicitly convert from `Class` to `Class`. - // CHECK:STDERR: return c.x; - // CHECK:STDERR: ^~~ - // CHECK:STDERR: +fn G(T:! type, c: Class(T)) -> T { return c.x; } fn H(U:! type, c: Class(U)) -> U { - // CHECK:STDERR: fail_todo_field.carbon:[[@LINE+7]]:3: ERROR: Cannot implicitly convert from `T` to `U`. - // CHECK:STDERR: return c.x; - // CHECK:STDERR: ^~~~~~~~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_todo_field.carbon:[[@LINE+3]]:10: ERROR: Cannot implicitly convert from `Class` to `Class`. - // CHECK:STDERR: return c.x; - // CHECK:STDERR: ^~~ return c.x; } @@ -58,139 +31,110 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] -// CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] -// CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic] -// CHECK:STDOUT: %G.type: type = fn_type @G [template] -// CHECK:STDOUT: %G: %G.type = struct_value () [template] -// CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Class = %Class.decl -// CHECK:STDOUT: .G = %G.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { -// CHECK:STDOUT: %T.loc2_13.1: type = param T -// CHECK:STDOUT: %T.loc2_13.2: type = bind_symbolic_name T 0, %T.loc2_13.1 [symbolic = %T.loc2_13.2 (constants.%T)] -// CHECK:STDOUT: } -// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { -// CHECK:STDOUT: %T.loc8_6.1: type = param T -// CHECK:STDOUT: @G.%T: type = bind_symbolic_name T 0, %T.loc8_6.1 [symbolic = @G.%T (constants.%T)] -// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %T.ref.loc8_25: type = name_ref T, @G.%T [symbolic = @G.%T (constants.%T)] -// CHECK:STDOUT: %.loc8_24: init type = call %Class.ref(%T.ref.loc8_25) [symbolic = %.loc8_24 (constants.%Class.2)] -// CHECK:STDOUT: %.loc8_26.1: type = value_of_initializer %.loc8_24 [symbolic = %.loc8_24 (constants.%Class.2)] -// CHECK:STDOUT: %.loc8_26.2: type = converted %.loc8_24, %.loc8_26.1 [symbolic = %.loc8_24 (constants.%Class.2)] -// CHECK:STDOUT: %c.loc8_16.1: file.%.loc8_24 (%Class.2) = param c -// CHECK:STDOUT: @G.%c: file.%.loc8_24 (%Class.2) = bind_name c, %c.loc8_16.1 -// CHECK:STDOUT: %T.ref.loc8_32: type = name_ref T, @G.%T [symbolic = @G.%T (constants.%T)] -// CHECK:STDOUT: @G.%return: ref %T = var -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc2_13.2: type] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc3: %.2 = field_decl x, element0 [template] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .x = %.loc3 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%T: type, %c: file.%.loc8_24 (%Class.2)) -> %T -// CHECK:STDOUT: generic [%T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %c.ref: %Class.2 = name_ref c, %c -// CHECK:STDOUT: %x.ref: %.2 = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] -// CHECK:STDOUT: %.loc9_11.1: ref %T = class_element_access %c.ref, element0 -// CHECK:STDOUT: %.loc9_11.2: %T = bind_value %.loc9_11.1 -// CHECK:STDOUT: return %.loc9_11.2 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_field.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] -// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] -// CHECK:STDOUT: %.1: type = tuple_type () [template] -// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %Class.3: type = class_type @Class, (i32) [template] +// CHECK:STDOUT: %Class.3: type = class_type @Class, @Class(i32) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] +// CHECK:STDOUT: %.4: type = unbound_element_type %Class.3, i32 [template] +// CHECK:STDOUT: %.5: type = ptr_type %.3 [symbolic] +// CHECK:STDOUT: %G.type: type = fn_type @G [template] +// CHECK:STDOUT: %G: %G.type = struct_value () [template] // CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic] -// CHECK:STDOUT: %Class.4: type = class_type @Class, (%U) [symbolic] +// CHECK:STDOUT: %Class.4: type = class_type @Class, @Class(%U) [symbolic] // CHECK:STDOUT: %H.type: type = fn_type @H [template] // CHECK:STDOUT: %H: %H.type = struct_value () [template] +// CHECK:STDOUT: %.6: type = unbound_element_type %Class.4, %U [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .H = %H.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { -// CHECK:STDOUT: %T.loc2_13.1: type = param T -// CHECK:STDOUT: %T.loc2_13.2: type = bind_symbolic_name T 0, %T.loc2_13.1 [symbolic = %T.loc2_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.1: type = param T +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Class.ref.loc6: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %int.make_type_32.loc6_15: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc6_14.1: type = value_of_initializer %int.make_type_32.loc6_15 [template = i32] -// CHECK:STDOUT: %.loc6_14.2: type = converted %int.make_type_32.loc6_15, %.loc6_14.1 [template = i32] -// CHECK:STDOUT: %.loc6_14.3: init type = call %Class.ref.loc6(%.loc6_14.2) [template = constants.%Class.3] -// CHECK:STDOUT: %.loc6_18.1: type = value_of_initializer %.loc6_14.3 [template = constants.%Class.3] -// CHECK:STDOUT: %.loc6_18.2: type = converted %.loc6_14.3, %.loc6_18.1 [template = constants.%Class.3] -// CHECK:STDOUT: %c.loc6_6.1: %Class.3 = param c -// CHECK:STDOUT: @F.%c: %Class.3 = bind_name c, %c.loc6_6.1 -// CHECK:STDOUT: %int.make_type_32.loc6_24: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc6_24.1: type = value_of_initializer %int.make_type_32.loc6_24 [template = i32] -// CHECK:STDOUT: %.loc6_24.2: type = converted %int.make_type_32.loc6_24, %.loc6_24.1 [template = i32] +// CHECK:STDOUT: %Class.ref.loc15: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %int.make_type_32.loc15_15: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc15_14.1: type = value_of_initializer %int.make_type_32.loc15_15 [template = i32] +// CHECK:STDOUT: %.loc15_14.2: type = converted %int.make_type_32.loc15_15, %.loc15_14.1 [template = i32] +// CHECK:STDOUT: %.loc15_14.3: init type = call %Class.ref.loc15(%.loc15_14.2) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc15_18.1: type = value_of_initializer %.loc15_14.3 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc15_18.2: type = converted %.loc15_14.3, %.loc15_18.1 [template = constants.%Class.3] +// CHECK:STDOUT: %c.loc15_6.1: %Class.3 = param c +// CHECK:STDOUT: @F.%c: %Class.3 = bind_name c, %c.loc15_6.1 +// CHECK:STDOUT: %int.make_type_32.loc15_24: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc15_24.1: type = value_of_initializer %int.make_type_32.loc15_24 [template = i32] +// CHECK:STDOUT: %.loc15_24.2: type = converted %int.make_type_32.loc15_24, %.loc15_24.1 [template = i32] // CHECK:STDOUT: @F.%return: ref i32 = var // CHECK:STDOUT: } +// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { +// CHECK:STDOUT: %T.loc19_6.1: type = param T +// CHECK:STDOUT: @G.%T.loc19: type = bind_symbolic_name T 0, %T.loc19_6.1 [symbolic = @G.%T.1 (constants.%T)] +// CHECK:STDOUT: %Class.ref.loc19: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %T.ref.loc19_25: type = name_ref T, @G.%T.loc19 [symbolic = @G.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc19_24: init type = call %Class.ref.loc19(%T.ref.loc19_25) [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc19_26.1: type = value_of_initializer %.loc19_24 [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc19_26.2: type = converted %.loc19_24, %.loc19_26.1 [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %c.loc19_16.1: @G.%Class (%Class.2) = param c +// CHECK:STDOUT: @G.%c: @G.%Class (%Class.2) = bind_name c, %c.loc19_16.1 +// CHECK:STDOUT: %T.ref.loc19_32: type = name_ref T, @G.%T.loc19 [symbolic = @G.%T.1 (constants.%T)] +// CHECK:STDOUT: @G.%return: ref @G.%T.1 (%T) = var +// CHECK:STDOUT: } // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] { -// CHECK:STDOUT: %U.loc18_6.1: type = param U -// CHECK:STDOUT: @H.%U: type = bind_symbolic_name U 0, %U.loc18_6.1 [symbolic = @H.%U (constants.%U)] -// CHECK:STDOUT: %Class.ref.loc18: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %U.ref.loc18_25: type = name_ref U, @H.%U [symbolic = @H.%U (constants.%U)] -// CHECK:STDOUT: %.loc18_24: init type = call %Class.ref.loc18(%U.ref.loc18_25) [symbolic = %.loc18_24 (constants.%Class.4)] -// CHECK:STDOUT: %.loc18_26.1: type = value_of_initializer %.loc18_24 [symbolic = %.loc18_24 (constants.%Class.4)] -// CHECK:STDOUT: %.loc18_26.2: type = converted %.loc18_24, %.loc18_26.1 [symbolic = %.loc18_24 (constants.%Class.4)] -// CHECK:STDOUT: %c.loc18_16.1: file.%.loc18_24 (%Class.4) = param c -// CHECK:STDOUT: @H.%c: file.%.loc18_24 (%Class.4) = bind_name c, %c.loc18_16.1 -// CHECK:STDOUT: %U.ref.loc18_32: type = name_ref U, @H.%U [symbolic = @H.%U (constants.%U)] -// CHECK:STDOUT: @H.%return: ref %U = var +// CHECK:STDOUT: %U.loc23_6.1: type = param U +// CHECK:STDOUT: @H.%U.loc23: type = bind_symbolic_name U 0, %U.loc23_6.1 [symbolic = @H.%U.1 (constants.%U)] +// CHECK:STDOUT: %Class.ref.loc23: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %U.ref.loc23_25: type = name_ref U, @H.%U.loc23 [symbolic = @H.%U.1 (constants.%U)] +// CHECK:STDOUT: %.loc23_24: init type = call %Class.ref.loc23(%U.ref.loc23_25) [symbolic = @H.%Class (constants.%Class.4)] +// CHECK:STDOUT: %.loc23_26.1: type = value_of_initializer %.loc23_24 [symbolic = @H.%Class (constants.%Class.4)] +// CHECK:STDOUT: %.loc23_26.2: type = converted %.loc23_24, %.loc23_26.1 [symbolic = @H.%Class (constants.%Class.4)] +// CHECK:STDOUT: %c.loc23_16.1: @H.%Class (%Class.4) = param c +// CHECK:STDOUT: @H.%c: @H.%Class (%Class.4) = bind_name c, %c.loc23_16.1 +// CHECK:STDOUT: %U.ref.loc23_32: type = name_ref U, @H.%U.loc23 [symbolic = @H.%U.1 (constants.%U)] +// CHECK:STDOUT: @H.%return: ref @H.%U.1 (%U) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc2_13.2: type] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc3: %.2 = field_decl x, element0 [template] +// CHECK:STDOUT: generic class @Class(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .x = %.loc3 +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc12: @Class.%.1 (%.2) = field_decl x, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .x = %.loc12 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -198,17 +142,89 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: fn @F(%c: %Class.3) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %Class.3 = name_ref c, %c -// CHECK:STDOUT: %x.ref: %.2 = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] -// CHECK:STDOUT: %.loc15: %T = class_element_access , element0 [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: %x.ref: %.4 = name_ref x, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %.loc16_11.1: ref i32 = class_element_access %c.ref, element0 +// CHECK:STDOUT: %.loc16_11.2: i32 = bind_value %.loc16_11.1 +// CHECK:STDOUT: return %.loc16_11.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @H(%U: type, %c: file.%.loc18_24 (%Class.4)) -> %U -// CHECK:STDOUT: generic [%U: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %c.ref: %Class.4 = name_ref c, %c -// CHECK:STDOUT: %x.ref: %.2 = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] -// CHECK:STDOUT: %.loc26: %T = class_element_access , element0 [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @G(%T.loc19: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.1) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = unbound_element_type @G.%Class (%Class.2), @G.%T.1 (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc19: type, %c: @G.%Class (%Class.2)) -> @G.%T.1 (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: @G.%Class (%Class.2) = name_ref c, %c +// CHECK:STDOUT: %x.ref: @G.%.1 (%.2) = name_ref x, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %.loc20_11.1: ref @G.%T.1 (%T) = class_element_access %c.ref, element0 +// CHECK:STDOUT: %.loc20_11.2: @G.%T.1 (%T) = bind_value %.loc20_11.1 +// CHECK:STDOUT: return %.loc20_11.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @H(%U.loc23: type) { +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 0 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%U.1) [symbolic = %Class (constants.%Class.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = unbound_element_type @H.%Class (%Class.4), @H.%U.1 (%U) [symbolic = %.1 (constants.%.6)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%U.loc23: type, %c: @H.%Class (%Class.4)) -> @H.%U.1 (%U) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: @H.%Class (%Class.4) = name_ref c, %c +// CHECK:STDOUT: %x.ref: @H.%.1 (%.6) = name_ref x, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %.loc24_11.1: ref @H.%U.1 (%U) = class_element_access %c.ref, element0 +// CHECK:STDOUT: %.loc24_11.2: @H.%U.1 (%U) = bind_value %.loc24_11.1 +// CHECK:STDOUT: return %.loc24_11.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.3 +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@G.%T.1) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%U) { +// CHECK:STDOUT: %T => constants.%U +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.4 +// CHECK:STDOUT: %.1 => constants.%.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@H.%U.1) { +// CHECK:STDOUT: %T => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @H(constants.%U) { +// CHECK:STDOUT: %U.1 => constants.%U +// CHECK:STDOUT: %Class => constants.%Class.4 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/import.carbon b/toolchain/check/testdata/class/generic/import.carbon index 15359f02b5266..afd1eb3e4484e 100644 --- a/toolchain/check/testdata/class/generic/import.carbon +++ b/toolchain/check/testdata/class/generic/import.carbon @@ -38,23 +38,13 @@ fn F() -> CompleteClass(i32) { library "use_foo"; import library "foo"; -fn Use() -> i32 { +fn UseMethod() -> i32 { var v: CompleteClass(i32) = F(); return v.F(); } -// --- fail_todo_use_foo.carbon - -library "fail_todo_use_foo"; -import library "foo"; - -fn Use() -> i32 { +fn UseField() -> i32 { var v: CompleteClass(i32) = F(); - // TODO: This should be accepted. - // CHECK:STDERR: fail_todo_use_foo.carbon:[[@LINE+4]]:10: ERROR: Cannot implicitly convert from `CompleteClass` to `CompleteClass`. - // CHECK:STDERR: return v.n; - // CHECK:STDERR: ^~~ - // CHECK:STDERR: return v.n; } @@ -76,10 +66,15 @@ fn Use() { impl library "foo"; -// CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+5]]:13: ERROR: Redeclaration differs at parameter 1. +// CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+10]]:13: ERROR: Redeclaration differs at parameter 1. // CHECK:STDERR: class Class(U:! type) { // CHECK:STDERR: ^ -// CHECK:STDERR: fail_bad_foo.impl.carbon: Previous declaration's corresponding parameter here. +// CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE-5]]:6: In import. +// CHECK:STDERR: impl library "foo"; +// CHECK:STDERR: ^~~~~~~ +// CHECK:STDERR: foo.carbon:4:13: Previous declaration's corresponding parameter here. +// CHECK:STDERR: class Class(T:! type); +// CHECK:STDERR: ^ // CHECK:STDERR: class Class(U:! type) { // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+3]]:10: ERROR: Name `T` not found. @@ -95,44 +90,51 @@ class Class(U:! type) { // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] -// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, (%T) [symbolic] +// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %.2: type = unbound_element_type %CompleteClass.2, i32 [symbolic] -// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] -// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.n: i32} [template] // CHECK:STDOUT: %.4: i32 = int_literal 0 [template] -// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (i32) [template] +// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .CompleteClass = %CompleteClass.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %CompleteClass.decl: %CompleteClass.type = class_decl @CompleteClass [template = constants.%CompleteClass.1] { // CHECK:STDOUT: %T.loc6_21.1: type = param T -// CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T 0, %T.loc6_21.1 [symbolic = %T.loc6_21.2 (constants.%T)] +// CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T 0, %T.loc6_21.1 [symbolic = @CompleteClass.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, %CompleteClass.decl [template = constants.%CompleteClass.1] @@ -146,71 +148,122 @@ class Class(U:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type]; -// CHECK:STDOUT: -// CHECK:STDOUT: class @CompleteClass -// CHECK:STDOUT: generic [file.%T.loc6_21.2: type] { -// CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32] -// CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32.loc7, %.loc7_10.1 [template = i32] -// CHECK:STDOUT: %.loc7_8: %.2 = field_decl n, element0 [template] -// CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32] -// CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32] -// CHECK:STDOUT: %return.var: ref i32 = var -// CHECK:STDOUT: } +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%CompleteClass.2 -// CHECK:STDOUT: .n = %.loc7_8 -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @CompleteClass(file.%T.loc6_21.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32] +// CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32.loc7, %.loc7_10.1 [template = i32] +// CHECK:STDOUT: %.loc7_8: @CompleteClass.%.1 (%.2) = field_decl n, element0 [template] +// CHECK:STDOUT: %F.decl: @CompleteClass.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32] +// CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32] +// CHECK:STDOUT: %return.var: ref i32 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%CompleteClass.2 +// CHECK:STDOUT: .n = %.loc7_8 +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -> i32 -// CHECK:STDOUT: generic [file.%T.loc6_21.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.4] -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: generic fn @F.1(file.%T.loc6_21.2: type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> i32 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.4] +// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() -> %CompleteClass.3; // CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- foo.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %.4: type = struct_type {.n: i32} [template] -// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, (%T) [symbolic] +// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(%T) [symbolic] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %.5: type = unbound_element_type %CompleteClass.2, i32 [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (i32) [template] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.5: type = ptr_type %.4 [template] -// CHECK:STDOUT: %.6: i32 = int_literal 1 [template] -// CHECK:STDOUT: %struct: %CompleteClass.3 = struct_value (%.6) [template] +// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.6: type = unbound_element_type %CompleteClass.3, i32 [template] +// CHECK:STDOUT: %F.type.4: type = fn_type @F.1, @CompleteClass(i32) [template] +// CHECK:STDOUT: %F.4: %F.type.4 = struct_value () [template] +// CHECK:STDOUT: %.7: type = ptr_type %.4 [template] +// CHECK:STDOUT: %.8: i32 = int_literal 1 [template] +// CHECK:STDOUT: %struct: %CompleteClass.3 = struct_value (%.8) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Class.type = import_ref ir0, inst+6, loaded [template = constants.%Class.1] -// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir0, inst+13, loaded [template = constants.%CompleteClass.1] -// CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir0, inst+51, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.4 = import_ref ir0, inst+16, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+26, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir0, inst+34, unloaded -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %Class.type = import_ref Main//foo, inst+6, loaded [template = constants.%Class.1] +// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+14, loaded [template = constants.%CompleteClass.1] +// CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+55, loaded [template = constants.%F.3] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+18, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+28, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+35, unloaded +// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -218,17 +271,16 @@ class Class(U:! type) { // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = %F.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] // CHECK:STDOUT: } -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.2 [template = constants.%F.3] { // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_24.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -236,69 +288,136 @@ class Class(U:! type) { // CHECK:STDOUT: %.loc8_24.3: init type = call %CompleteClass.ref(%.loc8_24.2) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %.loc8_28.1: type = value_of_initializer %.loc8_24.3 [template = constants.%CompleteClass.3] // CHECK:STDOUT: %.loc8_28.2: type = converted %.loc8_24.3, %.loc8_28.1 [template = constants.%CompleteClass.3] -// CHECK:STDOUT: @F.%return: ref %CompleteClass.3 = var +// CHECK:STDOUT: @F.2.%return: ref %CompleteClass.3 = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc5: %.2 = field_decl x, element0 [template] +// CHECK:STDOUT: generic class @Class(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .x = %.loc5 +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc5: @Class.%.1 (%.2) = field_decl x, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .x = %.loc5 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @CompleteClass { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.4 -// CHECK:STDOUT: .n = imports.%import_ref.5 -// CHECK:STDOUT: .F = imports.%import_ref.6 +// CHECK:STDOUT: generic class @CompleteClass(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.5)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.2)] +// CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.2) = struct_value () [symbolic = %F (constants.%F.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .n = imports.%import_ref.5 +// CHECK:STDOUT: .F = imports.%import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%T: type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: %CompleteClass.3 { +// CHECK:STDOUT: fn @F.2() -> %return: %CompleteClass.3 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc9_16: i32 = int_literal 1 [template = constants.%.6] +// CHECK:STDOUT: %.loc9_16: i32 = int_literal 1 [template = constants.%.8] // CHECK:STDOUT: %.loc9_17.1: %.4 = struct_literal (%.loc9_16) // CHECK:STDOUT: %.loc9_17.2: ref i32 = class_element_access %return, element0 -// CHECK:STDOUT: %.loc9_17.3: init i32 = initialize_from %.loc9_16 to %.loc9_17.2 [template = constants.%.6] +// CHECK:STDOUT: %.loc9_17.3: init i32 = initialize_from %.loc9_16 to %.loc9_17.2 [template = constants.%.8] // CHECK:STDOUT: %.loc9_17.4: init %CompleteClass.3 = class_init (%.loc9_17.3), %return [template = constants.%struct] // CHECK:STDOUT: %.loc9_18: init %CompleteClass.3 = converted %.loc9_17.1, %.loc9_17.4 [template = constants.%struct] // CHECK:STDOUT: return %.loc9_18 to %return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3 +// CHECK:STDOUT: %.1 => constants.%.6 +// CHECK:STDOUT: %F.type => constants.%F.type.4 +// CHECK:STDOUT: %F => constants.%F.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- use_foo.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %Use.type: type = fn_type @Use [template] -// CHECK:STDOUT: %Use: %Use.type = struct_value () [template] +// CHECK:STDOUT: %UseMethod.type: type = fn_type @UseMethod [template] +// CHECK:STDOUT: %UseMethod: %UseMethod.type = struct_value () [template] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] -// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, (%T) [symbolic] -// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (i32) [template] -// CHECK:STDOUT: %.3: type = ptr_type %.2 [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] -// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] -// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(%T) [symbolic] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = unbound_element_type %CompleteClass.2, i32 [symbolic] +// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template] +// CHECK:STDOUT: %.4: type = unbound_element_type %CompleteClass.3, i32 [template] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @CompleteClass(i32) [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.5: type = ptr_type %.2 [template] +// CHECK:STDOUT: %F.type.4: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.4: %F.type.4 = struct_value () [template] +// CHECK:STDOUT: %UseField.type: type = fn_type @UseField [template] +// CHECK:STDOUT: %UseField: %UseField.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+6, unloaded -// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir1, inst+13, loaded [template = constants.%CompleteClass.1] -// CHECK:STDOUT: %import_ref.3: %F.type.1 = import_ref ir1, inst+51, loaded [template = constants.%F.1] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+16, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+26, unloaded -// CHECK:STDOUT: %import_ref.7: %F.type.2 = import_ref ir1, inst+34, loaded [template = constants.%F.2] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//foo, inst+6, unloaded +// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+14, loaded [template = constants.%CompleteClass.1] +// CHECK:STDOUT: %import_ref.3: %F.type.4 = import_ref Main//foo, inst+55, loaded [template = constants.%F.4] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.4 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+18, unloaded +// CHECK:STDOUT: %import_ref.6: @CompleteClass.%.1 (%.3) = import_ref Main//foo, inst+28, loaded [template = %.1] +// CHECK:STDOUT: %import_ref.7: @CompleteClass.%F.type (%F.type.2) = import_ref Main//foo, inst+35, loaded [symbolic = @CompleteClass.%F (constants.%F.1)] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -306,30 +425,46 @@ class Class(U:! type) { // CHECK:STDOUT: .Class = imports.%import_ref.1 // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = imports.%import_ref.3 -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Use = %Use.decl +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .UseMethod = %UseMethod.decl +// CHECK:STDOUT: .UseField = %UseField.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] { -// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc5_13.1: type = value_of_initializer %int.make_type_32 [template = i32] -// CHECK:STDOUT: %.loc5_13.2: type = converted %int.make_type_32, %.loc5_13.1 [template = i32] -// CHECK:STDOUT: @Use.%return: ref i32 = var +// CHECK:STDOUT: %UseMethod.decl: %UseMethod.type = fn_decl @UseMethod [template = constants.%UseMethod] { +// CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc5_19.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32] +// CHECK:STDOUT: %.loc5_19.2: type = converted %int.make_type_32.loc5, %.loc5_19.1 [template = i32] +// CHECK:STDOUT: @UseMethod.%return: ref i32 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %UseField.decl: %UseField.type = fn_decl @UseField [template = constants.%UseField] { +// CHECK:STDOUT: %int.make_type_32.loc10: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc10_18.1: type = value_of_initializer %int.make_type_32.loc10 [template = i32] +// CHECK:STDOUT: %.loc10_18.2: type = converted %int.make_type_32.loc10, %.loc10_18.1 [template = i32] +// CHECK:STDOUT: @UseField.%return: ref i32 = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @CompleteClass { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .n = imports.%import_ref.6 -// CHECK:STDOUT: .F = imports.%import_ref.7 +// CHECK:STDOUT: generic class @CompleteClass(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.2)] +// CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.2) = struct_value () [symbolic = %F (constants.%F.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: .n = imports.%import_ref.6 +// CHECK:STDOUT: .F = imports.%import_ref.7 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Use() -> i32 { +// CHECK:STDOUT: fn @UseMethod() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] @@ -340,103 +475,68 @@ class Class(U:! type) { // CHECK:STDOUT: %.loc6_27.2: type = converted %.loc6_23.3, %.loc6_27.1 [template = constants.%CompleteClass.3] // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var -// CHECK:STDOUT: %F.ref.loc6: %F.type.1 = name_ref F, imports.%import_ref.3 [template = constants.%F.1] +// CHECK:STDOUT: %F.ref.loc6: %F.type.4 = name_ref F, imports.%import_ref.3 [template = constants.%F.4] // CHECK:STDOUT: %.loc6_7: ref %CompleteClass.3 = splice_block %v.var {} // CHECK:STDOUT: %F.call.loc6: init %CompleteClass.3 = call %F.ref.loc6() to %.loc6_7 // CHECK:STDOUT: assign %v.var, %F.call.loc6 // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v -// CHECK:STDOUT: %F.ref.loc7: %F.type.2 = name_ref F, imports.%import_ref.7 [template = constants.%F.2] +// CHECK:STDOUT: %.loc7_11: %F.type.3 = specific_constant imports.%import_ref.7, @CompleteClass(i32) [template = constants.%F.3] +// CHECK:STDOUT: %F.ref.loc7: %F.type.3 = name_ref F, %.loc7_11 [template = constants.%F.3] // CHECK:STDOUT: %F.call.loc7: init i32 = call %F.ref.loc7() // CHECK:STDOUT: %.loc7_15.1: i32 = value_of_initializer %F.call.loc7 // CHECK:STDOUT: %.loc7_15.2: i32 = converted %F.call.loc7, %.loc7_15.1 // CHECK:STDOUT: return %.loc7_15.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -> %CompleteClass.3; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2() -> i32; +// CHECK:STDOUT: generic fn @F.1(constants.%T: type) { +// CHECK:STDOUT: !definition: // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_use_foo.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] -// CHECK:STDOUT: %.1: type = tuple_type () [template] -// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %Use.type: type = fn_type @Use [template] -// CHECK:STDOUT: %Use: %Use.type = struct_value () [template] -// CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] -// CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] -// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, (%T) [symbolic] -// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (i32) [template] -// CHECK:STDOUT: %.3: type = ptr_type %.2 [template] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.4: type = unbound_element_type %CompleteClass.2, i32 [symbolic] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+6, unloaded -// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir1, inst+13, loaded [template = constants.%CompleteClass.1] -// CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir1, inst+51, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+16, unloaded -// CHECK:STDOUT: %import_ref.6: %.4 = import_ref ir1, inst+26, loaded [template = %.1] -// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+34, unloaded -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Class = imports.%import_ref.1 -// CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 -// CHECK:STDOUT: .F = imports.%import_ref.3 -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Use = %Use.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] { -// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc5_13.1: type = value_of_initializer %int.make_type_32 [template = i32] -// CHECK:STDOUT: %.loc5_13.2: type = converted %int.make_type_32, %.loc5_13.1 [template = i32] -// CHECK:STDOUT: @Use.%return: ref i32 = var -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @CompleteClass { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .n = imports.%import_ref.6 -// CHECK:STDOUT: .F = imports.%import_ref.7 +// CHECK:STDOUT: fn() -> i32; // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: fn @F.2() -> %CompleteClass.3; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Use() -> i32 { +// CHECK:STDOUT: fn @UseField() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc6_23.1: type = value_of_initializer %int.make_type_32 [template = i32] -// CHECK:STDOUT: %.loc6_23.2: type = converted %int.make_type_32, %.loc6_23.1 [template = i32] -// CHECK:STDOUT: %.loc6_23.3: init type = call %CompleteClass.ref(%.loc6_23.2) [template = constants.%CompleteClass.3] -// CHECK:STDOUT: %.loc6_27.1: type = value_of_initializer %.loc6_23.3 [template = constants.%CompleteClass.3] -// CHECK:STDOUT: %.loc6_27.2: type = converted %.loc6_23.3, %.loc6_27.1 [template = constants.%CompleteClass.3] +// CHECK:STDOUT: %.loc11_23.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc11_23.2: type = converted %int.make_type_32, %.loc11_23.1 [template = i32] +// CHECK:STDOUT: %.loc11_23.3: init type = call %CompleteClass.ref(%.loc11_23.2) [template = constants.%CompleteClass.3] +// CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %.loc11_23.3 [template = constants.%CompleteClass.3] +// CHECK:STDOUT: %.loc11_27.2: type = converted %.loc11_23.3, %.loc11_27.1 [template = constants.%CompleteClass.3] // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.3 [template = constants.%F] -// CHECK:STDOUT: %.loc6_7: ref %CompleteClass.3 = splice_block %v.var {} -// CHECK:STDOUT: %F.call: init %CompleteClass.3 = call %F.ref() to %.loc6_7 +// CHECK:STDOUT: %F.ref: %F.type.4 = name_ref F, imports.%import_ref.3 [template = constants.%F.4] +// CHECK:STDOUT: %.loc11_7: ref %CompleteClass.3 = splice_block %v.var {} +// CHECK:STDOUT: %F.call: init %CompleteClass.3 = call %F.ref() to %.loc11_7 // CHECK:STDOUT: assign %v.var, %F.call // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v // CHECK:STDOUT: %n.ref: %.4 = name_ref n, imports.%import_ref.6 [template = imports.%.1] -// CHECK:STDOUT: %.loc12: i32 = class_element_access , element0 [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: %.loc12_11.1: ref i32 = class_element_access %v.ref, element0 +// CHECK:STDOUT: %.loc12_11.2: i32 = bind_value %.loc12_11.1 +// CHECK:STDOUT: return %.loc12_11.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %CompleteClass.3; +// CHECK:STDOUT: specific @CompleteClass(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3 +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: %F.type => constants.%F.type.3 +// CHECK:STDOUT: %F => constants.%F.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(i32) {} // CHECK:STDOUT: // CHECK:STDOUT: --- fail_generic_arg_mismatch.carbon // CHECK:STDOUT: @@ -447,26 +547,47 @@ class Class(U:! type) { // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] -// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, (%T) [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(%T) [symbolic] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = unbound_element_type %CompleteClass.2, i32 [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = ptr_type i32 [template] -// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (%.3) [template] -// CHECK:STDOUT: %.4: type = ptr_type %.2 [template] -// CHECK:STDOUT: %CompleteClass.4: type = class_type @CompleteClass, (i32) [template] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type i32 [template] +// CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(%.4) [template] +// CHECK:STDOUT: %.5: type = unbound_element_type %CompleteClass.3, i32 [template] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @CompleteClass(%.4) [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.6: type = ptr_type %.2 [template] +// CHECK:STDOUT: %F.type.4: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.4: %F.type.4 = struct_value () [template] +// CHECK:STDOUT: %CompleteClass.4: type = class_type @CompleteClass, @CompleteClass(i32) [template] +// CHECK:STDOUT: %.7: type = unbound_element_type %CompleteClass.4, i32 [template] +// CHECK:STDOUT: %F.type.5: type = fn_type @F.1, @CompleteClass(i32) [template] +// CHECK:STDOUT: %F.5: %F.type.5 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+6, unloaded -// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir1, inst+13, loaded [template = constants.%CompleteClass.1] -// CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir1, inst+51, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+16, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+26, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+34, unloaded -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//foo, inst+6, unloaded +// CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+14, loaded [template = constants.%CompleteClass.1] +// CHECK:STDOUT: %import_ref.3: %F.type.4 = import_ref Main//foo, inst+55, loaded [template = constants.%F.4] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+18, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+28, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+35, unloaded +// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -474,20 +595,29 @@ class Class(U:! type) { // CHECK:STDOUT: .Class = imports.%import_ref.1 // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = imports.%import_ref.3 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Use = %Use.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @CompleteClass { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.4 -// CHECK:STDOUT: .n = imports.%import_ref.5 -// CHECK:STDOUT: .F = imports.%import_ref.6 +// CHECK:STDOUT: generic class @CompleteClass(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.2)] +// CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.2) = struct_value () [symbolic = %F (constants.%F.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .n = imports.%import_ref.5 +// CHECK:STDOUT: .F = imports.%import_ref.6 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Use() { @@ -496,22 +626,56 @@ class Class(U:! type) { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc11_27.2: type = converted %int.make_type_32, %.loc11_27.1 [template = i32] -// CHECK:STDOUT: %.loc11_27.3: type = ptr_type i32 [template = constants.%.3] +// CHECK:STDOUT: %.loc11_27.3: type = ptr_type i32 [template = constants.%.4] // CHECK:STDOUT: %.loc11_23: init type = call %CompleteClass.ref(%.loc11_27.3) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %.loc11_28.1: type = value_of_initializer %.loc11_23 [template = constants.%CompleteClass.3] // CHECK:STDOUT: %.loc11_28.2: type = converted %.loc11_23, %.loc11_28.1 [template = constants.%CompleteClass.3] // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.3 [template = constants.%F] +// CHECK:STDOUT: %F.ref: %F.type.4 = name_ref F, imports.%import_ref.3 [template = constants.%F.4] // CHECK:STDOUT: %.loc11_33: ref %CompleteClass.4 = temporary_storage // CHECK:STDOUT: %F.call: init %CompleteClass.4 = call %F.ref() to %.loc11_33 // CHECK:STDOUT: assign %v.var, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%T: type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> i32; +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %CompleteClass.4; +// CHECK:STDOUT: fn @F.2() -> %CompleteClass.4; +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(constants.%.4) { +// CHECK:STDOUT: %T => constants.%.4 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3 +// CHECK:STDOUT: %.1 => constants.%.5 +// CHECK:STDOUT: %F.type => constants.%F.type.3 +// CHECK:STDOUT: %F => constants.%F.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CompleteClass(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.4 +// CHECK:STDOUT: %.1 => constants.%.7 +// CHECK:STDOUT: %F.type => constants.%F.type.5 +// CHECK:STDOUT: %F => constants.%F.5 +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_bad_foo.impl.carbon // CHECK:STDOUT: @@ -520,17 +684,26 @@ class Class(U:! type) { // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = class_type @.1, (%U) [symbolic] +// CHECK:STDOUT: %.3: type = class_type @.1, @.1(%U) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Class.type = import_ref ir0, inst+6, loaded [template = constants.%Class.1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+13, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir0, inst+51, unloaded +// CHECK:STDOUT: %import_ref.1: %Class.type = import_ref Main//foo, inst+6, loaded [template = constants.%Class.1] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//foo, inst+14, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//foo, inst+55, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -538,27 +711,43 @@ class Class(U:! type) { // CHECK:STDOUT: .Class = imports.%import_ref.1 // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = imports.%import_ref.3 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { -// CHECK:STDOUT: %U.loc9_13.1: type = param U -// CHECK:STDOUT: %U.loc9_13.2: type = bind_symbolic_name U 0, %U.loc9_13.1 [symbolic = %U.loc9_13.2 (constants.%U)] +// CHECK:STDOUT: %U.loc14_13.1: type = param U +// CHECK:STDOUT: %U.loc14_13.2: type = bind_symbolic_name U 0, %U.loc14_13.1 [symbolic = @.1.%U (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class; +// CHECK:STDOUT: generic class @Class(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%U.loc9_13.2: type] { -// CHECK:STDOUT: %T.ref: = name_ref T, [template = ] -// CHECK:STDOUT: %.loc13: = field_decl x, element0 [template] +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @.1(file.%U.loc14_13.2: type) { +// CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref: = name_ref T, [template = ] +// CHECK:STDOUT: %.loc18: = field_decl x, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: .x = %.loc18 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%.3 -// CHECK:STDOUT: .x = %.loc13 +// CHECK:STDOUT: specific @.1(constants.%U) { +// CHECK:STDOUT: %U => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/init.carbon b/toolchain/check/testdata/class/generic/init.carbon new file mode 100644 index 0000000000000..7a3101c79e170 --- /dev/null +++ b/toolchain/check/testdata/class/generic/init.carbon @@ -0,0 +1,266 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/init.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/init.carbon + +// --- init.carbon + +class Class(T:! type) { + var k: T; +} + +fn InitFromStructGeneric(T:! type, x: T) -> T { + var v: Class(T) = {.k = x}; + return v.k; +} + +// --- fail_todo_init.carbon + +library "fail_todo_init"; + +class Class(T:! type) { + var k: T; +} + +// TODO: The following should work. +fn InitFromStructSpecific() -> i32 { + // CHECK:STDERR: fail_todo_init.carbon:[[@LINE+3]]:23: ERROR: Cannot implicitly convert from `i32` to `T`. + // CHECK:STDERR: var v: Class(i32) = {.k = 0}; + // CHECK:STDERR: ^~~~~~~~ + var v: Class(i32) = {.k = 0}; + return v.k; +} + +// CHECK:STDOUT: --- init.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] +// CHECK:STDOUT: %.3: type = struct_type {.k: %T} [symbolic] +// CHECK:STDOUT: %InitFromStructGeneric.type: type = fn_type @InitFromStructGeneric [template] +// CHECK:STDOUT: %InitFromStructGeneric: %InitFromStructGeneric.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Class = %Class.decl +// CHECK:STDOUT: .InitFromStructGeneric = %InitFromStructGeneric.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { +// CHECK:STDOUT: %T.loc2_13.1: type = param T +// CHECK:STDOUT: %T.loc2_13.2: type = bind_symbolic_name T 0, %T.loc2_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %InitFromStructGeneric.decl: %InitFromStructGeneric.type = fn_decl @InitFromStructGeneric [template = constants.%InitFromStructGeneric] { +// CHECK:STDOUT: %T.loc6_26.1: type = param T +// CHECK:STDOUT: @InitFromStructGeneric.%T.loc6: type = bind_symbolic_name T 0, %T.loc6_26.1 [symbolic = @InitFromStructGeneric.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc6_39: type = name_ref T, @InitFromStructGeneric.%T.loc6 [symbolic = @InitFromStructGeneric.%T.1 (constants.%T)] +// CHECK:STDOUT: %x.loc6_36.1: @InitFromStructGeneric.%T.1 (%T) = param x +// CHECK:STDOUT: @InitFromStructGeneric.%x: @InitFromStructGeneric.%T.1 (%T) = bind_name x, %x.loc6_36.1 +// CHECK:STDOUT: %T.ref.loc6_45: type = name_ref T, @InitFromStructGeneric.%T.loc6 [symbolic = @InitFromStructGeneric.%T.1 (constants.%T)] +// CHECK:STDOUT: @InitFromStructGeneric.%return: ref @InitFromStructGeneric.%T.1 (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Class(file.%T.loc2_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc3: @Class.%.1 (%.2) = field_decl k, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .k = %.loc3 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @InitFromStructGeneric(%T.loc6: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.1) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = struct_type {.k: @InitFromStructGeneric.%T.1 (%T)} [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %.2: type = unbound_element_type @InitFromStructGeneric.%Class (%Class.2), @InitFromStructGeneric.%T.1 (%T) [symbolic = %.2 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc6: type, %x: @InitFromStructGeneric.%T.1 (%T)) -> @InitFromStructGeneric.%T.1 (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc7_15: init type = call %Class.ref(%T.ref) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc7_17.1: type = value_of_initializer %.loc7_15 [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc7_17.2: type = converted %.loc7_15, %.loc7_17.1 [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %v.var: ref @InitFromStructGeneric.%Class (%Class.2) = var v +// CHECK:STDOUT: %v: ref @InitFromStructGeneric.%Class (%Class.2) = bind_name v, %v.var +// CHECK:STDOUT: %x.ref: @InitFromStructGeneric.%T.1 (%T) = name_ref x, %x +// CHECK:STDOUT: %.loc7_28.1: @InitFromStructGeneric.%.1 (%.3) = struct_literal (%x.ref) +// CHECK:STDOUT: %.loc7_28.2: ref @InitFromStructGeneric.%T.1 (%T) = class_element_access %v.var, element0 +// CHECK:STDOUT: %.loc7_28.3: init @InitFromStructGeneric.%T.1 (%T) = initialize_from %x.ref to %.loc7_28.2 +// CHECK:STDOUT: %.loc7_28.4: init @InitFromStructGeneric.%Class (%Class.2) = class_init (%.loc7_28.3), %v.var +// CHECK:STDOUT: %.loc7_29: init @InitFromStructGeneric.%Class (%Class.2) = converted %.loc7_28.1, %.loc7_28.4 +// CHECK:STDOUT: assign %v.var, %.loc7_29 +// CHECK:STDOUT: %v.ref: ref @InitFromStructGeneric.%Class (%Class.2) = name_ref v, %v +// CHECK:STDOUT: %k.ref: @InitFromStructGeneric.%.2 (%.2) = name_ref k, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %.loc8_11.1: ref @InitFromStructGeneric.%T.1 (%T) = class_element_access %v.ref, element0 +// CHECK:STDOUT: %.loc8_11.2: @InitFromStructGeneric.%T.1 (%T) = bind_value %.loc8_11.1 +// CHECK:STDOUT: return %.loc8_11.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @InitFromStructGeneric(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@InitFromStructGeneric.%T.1) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_init.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] +// CHECK:STDOUT: %.3: type = struct_type {.k: %T} [symbolic] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %InitFromStructSpecific.type: type = fn_type @InitFromStructSpecific [template] +// CHECK:STDOUT: %InitFromStructSpecific: %InitFromStructSpecific.type = struct_value () [template] +// CHECK:STDOUT: %Class.3: type = class_type @Class, @Class(i32) [template] +// CHECK:STDOUT: %.4: type = unbound_element_type %Class.3, i32 [template] +// CHECK:STDOUT: %.5: type = ptr_type %.3 [symbolic] +// CHECK:STDOUT: %.6: i32 = int_literal 0 [template] +// CHECK:STDOUT: %.7: type = struct_type {.k: i32} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Class = %Class.decl +// CHECK:STDOUT: .InitFromStructSpecific = %InitFromStructSpecific.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { +// CHECK:STDOUT: %T.loc4_13.1: type = param T +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %InitFromStructSpecific.decl: %InitFromStructSpecific.type = fn_decl @InitFromStructSpecific [template = constants.%InitFromStructSpecific] { +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc9_32.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc9_32.2: type = converted %int.make_type_32, %.loc9_32.1 [template = i32] +// CHECK:STDOUT: @InitFromStructSpecific.%return: ref i32 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc5: @Class.%.1 (%.2) = field_decl k, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .k = %.loc5 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @InitFromStructSpecific() -> i32 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc13_15.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc13_15.2: type = converted %int.make_type_32, %.loc13_15.1 [template = i32] +// CHECK:STDOUT: %.loc13_15.3: init type = call %Class.ref(%.loc13_15.2) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc13_19.1: type = value_of_initializer %.loc13_15.3 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc13_19.2: type = converted %.loc13_15.3, %.loc13_19.1 [template = constants.%Class.3] +// CHECK:STDOUT: %v.var: ref %Class.3 = var v +// CHECK:STDOUT: %v: ref %Class.3 = bind_name v, %v.var +// CHECK:STDOUT: %.loc13_29: i32 = int_literal 0 [template = constants.%.6] +// CHECK:STDOUT: %.loc13_30: %.7 = struct_literal (%.loc13_29) +// CHECK:STDOUT: assign %v.var, +// CHECK:STDOUT: %v.ref: ref %Class.3 = name_ref v, %v +// CHECK:STDOUT: %k.ref: %.4 = name_ref k, @Class.%.loc5 [template = @Class.%.loc5] +// CHECK:STDOUT: %.loc14_11.1: ref i32 = class_element_access %v.ref, element0 +// CHECK:STDOUT: %.loc14_11.2: i32 = bind_value %.loc14_11.1 +// CHECK:STDOUT: return %.loc14_11.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.3 +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/member_access.carbon b/toolchain/check/testdata/class/generic/member_access.carbon new file mode 100644 index 0000000000000..15cc22c7554dd --- /dev/null +++ b/toolchain/check/testdata/class/generic/member_access.carbon @@ -0,0 +1,480 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/member_access.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/member_access.carbon + +// --- member_access.carbon + +class Class(T:! type) { + var x: T; + + fn Get[self: Self]() -> T { return self.x; } + + fn GetAddr[addr self: Self*]() -> T* { return &self->x; } +} + +fn DirectFieldAccess(x: Class(i32)) -> i32 { + return x.x; +} + +fn MethodCall(x: Class(i32)) -> i32 { + return x.Get(); +} + +fn AddrMethodCall(p: Class(i32)*) -> i32 { + return *p->GetAddr(); +} + +// --- fail_todo_static_member_fn_call.carbon + +library "fail_todo_static_member_fn_call"; + +class Class(T:! type) { + fn Make() -> Class(T) { return {}; } +} + +fn StaticMemberFunctionCall(T:! type) -> Class(T) { + // CHECK:STDERR: fail_todo_static_member_fn_call.carbon:[[@LINE+3]]:3: ERROR: Cannot implicitly convert from `Class` to `Class`. + // CHECK:STDERR: return Class(T).Make(); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~ + return Class(T).Make(); +} + +// CHECK:STDOUT: --- member_access.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] +// CHECK:STDOUT: %Get.type.1: type = fn_type @Get, @Class(%T) [symbolic] +// CHECK:STDOUT: %Get.1: %Get.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = ptr_type %Class.2 [symbolic] +// CHECK:STDOUT: %.4: type = ptr_type %T [symbolic] +// CHECK:STDOUT: %GetAddr.type.1: type = fn_type @GetAddr, @Class(%T) [symbolic] +// CHECK:STDOUT: %GetAddr.1: %GetAddr.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.5: type = struct_type {.x: %T} [symbolic] +// CHECK:STDOUT: %Get.2: %Get.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %GetAddr.2: %GetAddr.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.6: type = ptr_type %.5 [symbolic] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %Class.3: type = class_type @Class, @Class(i32) [template] +// CHECK:STDOUT: %DirectFieldAccess.type: type = fn_type @DirectFieldAccess [template] +// CHECK:STDOUT: %DirectFieldAccess: %DirectFieldAccess.type = struct_value () [template] +// CHECK:STDOUT: %.7: type = unbound_element_type %Class.3, i32 [template] +// CHECK:STDOUT: %Get.type.2: type = fn_type @Get, @Class(i32) [template] +// CHECK:STDOUT: %Get.3: %Get.type.2 = struct_value () [template] +// CHECK:STDOUT: %GetAddr.type.2: type = fn_type @GetAddr, @Class(i32) [template] +// CHECK:STDOUT: %GetAddr.3: %GetAddr.type.2 = struct_value () [template] +// CHECK:STDOUT: %MethodCall.type: type = fn_type @MethodCall [template] +// CHECK:STDOUT: %MethodCall: %MethodCall.type = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Class.3 [template] +// CHECK:STDOUT: %AddrMethodCall.type: type = fn_type @AddrMethodCall [template] +// CHECK:STDOUT: %AddrMethodCall: %AddrMethodCall.type = struct_value () [template] +// CHECK:STDOUT: %.9: type = ptr_type i32 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Class = %Class.decl +// CHECK:STDOUT: .DirectFieldAccess = %DirectFieldAccess.decl +// CHECK:STDOUT: .MethodCall = %MethodCall.decl +// CHECK:STDOUT: .AddrMethodCall = %AddrMethodCall.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { +// CHECK:STDOUT: %T.loc2_13.1: type = param T +// CHECK:STDOUT: %T.loc2_13.2: type = bind_symbolic_name T 0, %T.loc2_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %DirectFieldAccess.decl: %DirectFieldAccess.type = fn_decl @DirectFieldAccess [template = constants.%DirectFieldAccess] { +// CHECK:STDOUT: %Class.ref.loc10: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %int.make_type_32.loc10_31: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc10_30.1: type = value_of_initializer %int.make_type_32.loc10_31 [template = i32] +// CHECK:STDOUT: %.loc10_30.2: type = converted %int.make_type_32.loc10_31, %.loc10_30.1 [template = i32] +// CHECK:STDOUT: %.loc10_30.3: init type = call %Class.ref.loc10(%.loc10_30.2) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc10_34.1: type = value_of_initializer %.loc10_30.3 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc10_34.2: type = converted %.loc10_30.3, %.loc10_34.1 [template = constants.%Class.3] +// CHECK:STDOUT: %x.loc10_22.1: %Class.3 = param x +// CHECK:STDOUT: @DirectFieldAccess.%x: %Class.3 = bind_name x, %x.loc10_22.1 +// CHECK:STDOUT: %int.make_type_32.loc10_40: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc10_40.1: type = value_of_initializer %int.make_type_32.loc10_40 [template = i32] +// CHECK:STDOUT: %.loc10_40.2: type = converted %int.make_type_32.loc10_40, %.loc10_40.1 [template = i32] +// CHECK:STDOUT: @DirectFieldAccess.%return: ref i32 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %MethodCall.decl: %MethodCall.type = fn_decl @MethodCall [template = constants.%MethodCall] { +// CHECK:STDOUT: %Class.ref.loc14: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %int.make_type_32.loc14_24: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc14_23.1: type = value_of_initializer %int.make_type_32.loc14_24 [template = i32] +// CHECK:STDOUT: %.loc14_23.2: type = converted %int.make_type_32.loc14_24, %.loc14_23.1 [template = i32] +// CHECK:STDOUT: %.loc14_23.3: init type = call %Class.ref.loc14(%.loc14_23.2) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc14_27.1: type = value_of_initializer %.loc14_23.3 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc14_27.2: type = converted %.loc14_23.3, %.loc14_27.1 [template = constants.%Class.3] +// CHECK:STDOUT: %x.loc14_15.1: %Class.3 = param x +// CHECK:STDOUT: @MethodCall.%x: %Class.3 = bind_name x, %x.loc14_15.1 +// CHECK:STDOUT: %int.make_type_32.loc14_33: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc14_33.1: type = value_of_initializer %int.make_type_32.loc14_33 [template = i32] +// CHECK:STDOUT: %.loc14_33.2: type = converted %int.make_type_32.loc14_33, %.loc14_33.1 [template = i32] +// CHECK:STDOUT: @MethodCall.%return: ref i32 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %AddrMethodCall.decl: %AddrMethodCall.type = fn_decl @AddrMethodCall [template = constants.%AddrMethodCall] { +// CHECK:STDOUT: %Class.ref.loc18: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %int.make_type_32.loc18_28: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc18_27.1: type = value_of_initializer %int.make_type_32.loc18_28 [template = i32] +// CHECK:STDOUT: %.loc18_27.2: type = converted %int.make_type_32.loc18_28, %.loc18_27.1 [template = i32] +// CHECK:STDOUT: %.loc18_27.3: init type = call %Class.ref.loc18(%.loc18_27.2) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc18_32.1: type = value_of_initializer %.loc18_27.3 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc18_32.2: type = converted %.loc18_27.3, %.loc18_32.1 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc18_32.3: type = ptr_type %Class.3 [template = constants.%.8] +// CHECK:STDOUT: %p.loc18_19.1: %.8 = param p +// CHECK:STDOUT: @AddrMethodCall.%p: %.8 = bind_name p, %p.loc18_19.1 +// CHECK:STDOUT: %int.make_type_32.loc18_38: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc18_38.1: type = value_of_initializer %int.make_type_32.loc18_38 [template = i32] +// CHECK:STDOUT: %.loc18_38.2: type = converted %int.make_type_32.loc18_38, %.loc18_38.1 [template = i32] +// CHECK:STDOUT: @AddrMethodCall.%return: ref i32 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Class(file.%T.loc2_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Get.type: type = fn_type @Get, @Class(%T) [symbolic = %Get.type (constants.%Get.type.1)] +// CHECK:STDOUT: %Get: @Class.%Get.type (%Get.type.1) = struct_value () [symbolic = %Get (constants.%Get.1)] +// CHECK:STDOUT: %GetAddr.type: type = fn_type @GetAddr, @Class(%T) [symbolic = %GetAddr.type (constants.%GetAddr.type.1)] +// CHECK:STDOUT: %GetAddr: @Class.%GetAddr.type (%GetAddr.type.1) = struct_value () [symbolic = %GetAddr (constants.%GetAddr.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref.loc3: type = name_ref T, file.%T.loc2_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc3: @Class.%.1 (%.2) = field_decl x, element0 [template] +// CHECK:STDOUT: %Get.decl: @Class.%Get.type (%Get.type.1) = fn_decl @Get [symbolic = %Get (constants.%Get.1)] { +// CHECK:STDOUT: %.loc5: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @Get.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref.loc5: type = name_ref Self, %.loc5 [symbolic = @Get.%Class (constants.%Class.2)] +// CHECK:STDOUT: %self.loc5_10.1: @Get.%Class (%Class.2) = param self +// CHECK:STDOUT: %self.loc5_10.2: @Get.%Class (%Class.2) = bind_name self, %self.loc5_10.1 +// CHECK:STDOUT: %T.ref.loc5: type = name_ref T, file.%T.loc2_13.2 [symbolic = @Get.%T (constants.%T)] +// CHECK:STDOUT: %return.var.loc5: ref @Get.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %GetAddr.decl: @Class.%GetAddr.type (%GetAddr.type.1) = fn_decl @GetAddr [symbolic = %GetAddr (constants.%GetAddr.1)] { +// CHECK:STDOUT: %.loc7_25: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @GetAddr.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref.loc7: type = name_ref Self, %.loc7_25 [symbolic = @GetAddr.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc7_29: type = ptr_type %Class.2 [symbolic = @GetAddr.%.1 (constants.%.3)] +// CHECK:STDOUT: %self.loc7_19.1: @GetAddr.%.1 (%.3) = param self +// CHECK:STDOUT: %self.loc7_19.3: @GetAddr.%.1 (%.3) = bind_name self, %self.loc7_19.1 +// CHECK:STDOUT: %.loc7_14: @GetAddr.%.1 (%.3) = addr_pattern %self.loc7_19.3 +// CHECK:STDOUT: %T.ref.loc7: type = name_ref T, file.%T.loc2_13.2 [symbolic = @GetAddr.%T (constants.%T)] +// CHECK:STDOUT: %.loc7_38: type = ptr_type %T [symbolic = @GetAddr.%.2 (constants.%.4)] +// CHECK:STDOUT: %return.var.loc7: ref @GetAddr.%.2 (%.4) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .x = %.loc3 +// CHECK:STDOUT: .Get = %Get.decl +// CHECK:STDOUT: .GetAddr = %GetAddr.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Get(file.%T.loc2_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = unbound_element_type @Get.%Class (%Class.2), @Get.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Class.%self.loc5_10.2: @Get.%Class (%Class.2)]() -> @Get.%T (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @Get.%Class (%Class.2) = name_ref self, @Class.%self.loc5_10.2 +// CHECK:STDOUT: %x.ref: @Get.%.1 (%.2) = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %.loc5_42.1: ref @Get.%T (%T) = class_element_access %self.ref, element0 +// CHECK:STDOUT: %.loc5_42.2: @Get.%T (%T) = bind_value %.loc5_42.1 +// CHECK:STDOUT: return %.loc5_42.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @GetAddr(file.%T.loc2_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = ptr_type @GetAddr.%Class (%Class.2) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %.2: type = ptr_type @GetAddr.%T (%T) [symbolic = %.2 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.3: type = unbound_element_type @GetAddr.%Class (%Class.2), @GetAddr.%T (%T) [symbolic = %.3 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr @Class.%self.loc7_19.3: @GetAddr.%.1 (%.3)]() -> @GetAddr.%.2 (%.4) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @GetAddr.%.1 (%.3) = name_ref self, @Class.%self.loc7_19.3 +// CHECK:STDOUT: %.loc7_54.1: ref @GetAddr.%Class (%Class.2) = deref %self.ref +// CHECK:STDOUT: %x.ref: @GetAddr.%.3 (%.2) = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %.loc7_54.2: ref @GetAddr.%T (%T) = class_element_access %.loc7_54.1, element0 +// CHECK:STDOUT: %.loc7_49: @GetAddr.%.2 (%.4) = addr_of %.loc7_54.2 +// CHECK:STDOUT: return %.loc7_49 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @DirectFieldAccess(%x: %Class.3) -> i32 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref.loc11_10: %Class.3 = name_ref x, %x +// CHECK:STDOUT: %x.ref.loc11_11: %.7 = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %.loc11_11.1: ref i32 = class_element_access %x.ref.loc11_10, element0 +// CHECK:STDOUT: %.loc11_11.2: i32 = bind_value %.loc11_11.1 +// CHECK:STDOUT: return %.loc11_11.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @MethodCall(%x: %Class.3) -> i32 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: %Class.3 = name_ref x, %x +// CHECK:STDOUT: %.loc15_11.1: %Get.type.2 = specific_constant @Class.%Get.decl, @Class(i32) [template = constants.%Get.3] +// CHECK:STDOUT: %Get.ref: %Get.type.2 = name_ref Get, %.loc15_11.1 [template = constants.%Get.3] +// CHECK:STDOUT: %.loc15_11.2: = bound_method %x.ref, %Get.ref +// CHECK:STDOUT: %Get.call: init i32 = call %.loc15_11.2(%x.ref) +// CHECK:STDOUT: %.loc15_17.1: i32 = value_of_initializer %Get.call +// CHECK:STDOUT: %.loc15_17.2: i32 = converted %Get.call, %.loc15_17.1 +// CHECK:STDOUT: return %.loc15_17.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @AddrMethodCall(%p: %.8) -> i32 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %p.ref: %.8 = name_ref p, %p +// CHECK:STDOUT: %.loc19_12.1: ref %Class.3 = deref %p.ref +// CHECK:STDOUT: %.loc19_12.2: %GetAddr.type.2 = specific_constant @Class.%GetAddr.decl, @Class(i32) [template = constants.%GetAddr.3] +// CHECK:STDOUT: %GetAddr.ref: %GetAddr.type.2 = name_ref GetAddr, %.loc19_12.2 [template = constants.%GetAddr.3] +// CHECK:STDOUT: %.loc19_12.3: = bound_method %.loc19_12.1, %GetAddr.ref +// CHECK:STDOUT: %.loc19_12.4: %.8 = addr_of %.loc19_12.1 +// CHECK:STDOUT: %GetAddr.call: init %.9 = call %.loc19_12.3(%.loc19_12.4) +// CHECK:STDOUT: %.loc19_21.1: %.9 = value_of_initializer %GetAddr.call +// CHECK:STDOUT: %.loc19_21.2: %.9 = converted %GetAddr.call, %.loc19_21.1 +// CHECK:STDOUT: %.loc19_10.1: ref i32 = deref %.loc19_21.2 +// CHECK:STDOUT: %.loc19_10.2: i32 = bind_value %.loc19_10.1 +// CHECK:STDOUT: return %.loc19_10.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: %Get.type => constants.%Get.type.1 +// CHECK:STDOUT: %Get => constants.%Get.2 +// CHECK:STDOUT: %GetAddr.type => constants.%GetAddr.type.1 +// CHECK:STDOUT: %GetAddr => constants.%GetAddr.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Get.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Get(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@GetAddr.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GetAddr(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.3 +// CHECK:STDOUT: %.2 => constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.3 +// CHECK:STDOUT: %.1 => constants.%.7 +// CHECK:STDOUT: %Get.type => constants.%Get.type.2 +// CHECK:STDOUT: %Get => constants.%Get.3 +// CHECK:STDOUT: %GetAddr.type => constants.%GetAddr.type.2 +// CHECK:STDOUT: %GetAddr => constants.%GetAddr.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Get(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: %Class => constants.%Class.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GetAddr(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: %Class => constants.%Class.3 +// CHECK:STDOUT: %.1 => constants.%.8 +// CHECK:STDOUT: %.2 => constants.%.9 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_static_member_fn_call.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %Make.type: type = fn_type @Make, @Class(%T) [symbolic] +// CHECK:STDOUT: %Make.1: %Make.type = struct_value () [symbolic] +// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %Make.2: %Make.type = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = ptr_type %.2 [template] +// CHECK:STDOUT: %struct: %Class.2 = struct_value () [symbolic] +// CHECK:STDOUT: %StaticMemberFunctionCall.type: type = fn_type @StaticMemberFunctionCall [template] +// CHECK:STDOUT: %StaticMemberFunctionCall: %StaticMemberFunctionCall.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Class = %Class.decl +// CHECK:STDOUT: .StaticMemberFunctionCall = %StaticMemberFunctionCall.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { +// CHECK:STDOUT: %T.loc4_13.1: type = param T +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %StaticMemberFunctionCall.decl: %StaticMemberFunctionCall.type = fn_decl @StaticMemberFunctionCall [template = constants.%StaticMemberFunctionCall] { +// CHECK:STDOUT: %T.loc8_29.1: type = param T +// CHECK:STDOUT: @StaticMemberFunctionCall.%T.loc8: type = bind_symbolic_name T 0, %T.loc8_29.1 [symbolic = @StaticMemberFunctionCall.%T.1 (constants.%T)] +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %T.ref: type = name_ref T, @StaticMemberFunctionCall.%T.loc8 [symbolic = @StaticMemberFunctionCall.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc8_47: init type = call %Class.ref(%T.ref) [symbolic = @StaticMemberFunctionCall.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc8_49.1: type = value_of_initializer %.loc8_47 [symbolic = @StaticMemberFunctionCall.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc8_49.2: type = converted %.loc8_47, %.loc8_49.1 [symbolic = @StaticMemberFunctionCall.%Class (constants.%Class.2)] +// CHECK:STDOUT: @StaticMemberFunctionCall.%return: ref @StaticMemberFunctionCall.%Class (%Class.2) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type: type = fn_type @Make, @Class(%T) [symbolic = %Make.type (constants.%Make.type)] +// CHECK:STDOUT: %Make: @Class.%Make.type (%Make.type) = struct_value () [symbolic = %Make (constants.%Make.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %Make.decl: @Class.%Make.type (%Make.type) = fn_decl @Make [symbolic = %Make (constants.%Make.1)] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = @Make.%T (constants.%T)] +// CHECK:STDOUT: %.loc5_21: init type = call %Class.ref(%T.ref) [symbolic = @Make.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc5_23.1: type = value_of_initializer %.loc5_21 [symbolic = @Make.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc5_23.2: type = converted %.loc5_21, %.loc5_23.1 [symbolic = @Make.%Class (constants.%Class.2)] +// CHECK:STDOUT: %return.var: ref @Make.%Class (%Class.2) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .Make = %Make.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Make(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %struct: @Make.%Class (%Class.2) = struct_value () [symbolic = %struct (constants.%struct)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Class.%return.var: @Make.%Class (%Class.2) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc5_35.1: %.2 = struct_literal () +// CHECK:STDOUT: %.loc5_35.2: init @Make.%Class (%Class.2) = class_init (), @Class.%return.var [symbolic = %struct (constants.%struct)] +// CHECK:STDOUT: %.loc5_36: init @Make.%Class (%Class.2) = converted %.loc5_35.1, %.loc5_35.2 [symbolic = %struct (constants.%struct)] +// CHECK:STDOUT: return %.loc5_36 to @Class.%return.var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @StaticMemberFunctionCall(%T.loc8: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.1) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type: type = fn_type @Make, @Class(%T.1) [symbolic = %Make.type (constants.%Make.type)] +// CHECK:STDOUT: %Make: @StaticMemberFunctionCall.%Make.type (%Make.type) = struct_value () [symbolic = %Make (constants.%Make.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc8: type) -> %return: @StaticMemberFunctionCall.%Class (%Class.2) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc8 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc12_15: init type = call %Class.ref(%T.ref) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc12_18: @StaticMemberFunctionCall.%Make.type (%Make.type) = specific_constant @Class.%Make.decl, @Class(constants.%T) [symbolic = %Make (constants.%Make.2)] +// CHECK:STDOUT: %Make.ref: @StaticMemberFunctionCall.%Make.type (%Make.type) = name_ref Make, %.loc12_18 [symbolic = %Make (constants.%Make.2)] +// CHECK:STDOUT: %.loc12_23: ref @StaticMemberFunctionCall.%Class (%Class.2) = temporary_storage +// CHECK:STDOUT: %Make.call: init @StaticMemberFunctionCall.%Class (%Class.2) = call %Make.ref() to %.loc12_23 +// CHECK:STDOUT: return to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type => constants.%Make.type +// CHECK:STDOUT: %Make => constants.%Make.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Make.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Make(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@StaticMemberFunctionCall.%T.1) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @StaticMemberFunctionCall(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/member_inline.carbon b/toolchain/check/testdata/class/generic/member_inline.carbon index 8c1cbe4088121..884ec8e427aa7 100644 --- a/toolchain/check/testdata/class/generic/member_inline.carbon +++ b/toolchain/check/testdata/class/generic/member_inline.carbon @@ -12,6 +12,12 @@ class Class(T:! type) { fn F(n: T) -> T { return n; } + + fn G[self: Self]() -> T { + return self.n; + } + + var n: T; } // CHECK:STDOUT: --- member_inline.carbon @@ -21,44 +27,135 @@ class Class(T:! type) { // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %G.type: type = fn_type @G, @Class(%T) [symbolic] +// CHECK:STDOUT: %G.1: %G.type = struct_value () [symbolic] +// CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] +// CHECK:STDOUT: %.3: type = struct_type {.n: %T} [symbolic] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %G.2: %G.type = struct_value () [symbolic] +// CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Class(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @Class.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %G.type: type = fn_type @G, @Class(%T) [symbolic = %G.type (constants.%G.type)] +// CHECK:STDOUT: %G: @Class.%G.type (%G.type) = struct_value () [symbolic = %G (constants.%G.1)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %T.ref.loc12_11: type = name_ref T, file.%T.loc11_13.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %n.loc12_8.1: @F.%T (%T) = param n +// CHECK:STDOUT: %n.loc12_8.2: @F.%T (%T) = bind_name n, %n.loc12_8.1 +// CHECK:STDOUT: %T.ref.loc12_17: type = name_ref T, file.%T.loc11_13.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %return.var.loc12: ref @F.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %G.decl: @Class.%G.type (%G.type) = fn_decl @G [symbolic = %G (constants.%G.1)] { +// CHECK:STDOUT: %.loc16: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc16 [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %self.loc16_8.1: @G.%Class (%Class.2) = param self +// CHECK:STDOUT: %self.loc16_8.2: @G.%Class (%Class.2) = bind_name self, %self.loc16_8.1 +// CHECK:STDOUT: %T.ref.loc16: type = name_ref T, file.%T.loc11_13.2 [symbolic = @G.%T (constants.%T)] +// CHECK:STDOUT: %return.var.loc16: ref @G.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %T.ref.loc20: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc20: @Class.%.1 (%.2) = field_decl n, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: .n = %.loc20 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %T.ref.loc12_11: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12_11 (constants.%T)] -// CHECK:STDOUT: %n.loc12_8.1: @Class.%T.ref.loc12_11 (%T) = param n -// CHECK:STDOUT: %n.loc12_8.2: @Class.%T.ref.loc12_11 (%T) = bind_name n, %n.loc12_8.1 -// CHECK:STDOUT: %T.ref.loc12_17: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12_11 (constants.%T)] -// CHECK:STDOUT: %return.var: ref %T = var +// CHECK:STDOUT: generic fn @F(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@Class.%n.loc12_8.2: @F.%T (%T)) -> @F.%T (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %n.ref: @F.%T (%T) = name_ref n, @Class.%n.loc12_8.2 +// CHECK:STDOUT: return %n.ref // CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = unbound_element_type @G.%Class (%Class.2), @G.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Class.%self.loc16_8.2: @G.%Class (%Class.2)]() -> @G.%T (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @G.%Class (%Class.2) = name_ref self, @Class.%self.loc16_8.2 +// CHECK:STDOUT: %n.ref: @G.%.1 (%.2) = name_ref n, @Class.%.loc20 [template = @Class.%.loc20] +// CHECK:STDOUT: %.loc17_16.1: ref @G.%T (%T) = class_element_access %self.ref, element0 +// CHECK:STDOUT: %.loc17_16.2: @G.%T (%T) = bind_value %.loc17_16.1 +// CHECK:STDOUT: return %.loc17_16.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: %G.type => constants.%G.type +// CHECK:STDOUT: %G => constants.%G.2 +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@G.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: specific @G(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(@Class.%n.loc12_8.2: @Class.%T.ref.loc12_11 (%T)) -> %T -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %n.ref: %T = name_ref n, @Class.%n.loc12_8.2 -// CHECK:STDOUT: return %n.ref +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/member_out_of_line.carbon b/toolchain/check/testdata/class/generic/member_out_of_line.carbon index 60626bdd51ea4..c7c5caabdf007 100644 --- a/toolchain/check/testdata/class/generic/member_out_of_line.carbon +++ b/toolchain/check/testdata/class/generic/member_out_of_line.carbon @@ -14,12 +14,18 @@ library "basic"; class Class(T:! type) { fn F(n: T) -> T; + fn G[self: Self]() -> T; + var n: T; } fn Class(T:! type).F(n: T) -> T { return n; } +fn Class(T:! type).G[self: Self]() -> T { + return self.n; +} + // --- nested.carbon library "nested"; @@ -106,54 +112,155 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %G.type: type = fn_type @G, @Class(%T) [symbolic] +// CHECK:STDOUT: %G.1: %G.type = struct_value () [symbolic] +// CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] +// CHECK:STDOUT: %.3: type = struct_type {.n: %T} [symbolic] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %G.2: %G.type = struct_value () [symbolic] +// CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] -// CHECK:STDOUT: } -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %T.loc8_10.1: type = param T -// CHECK:STDOUT: %T.loc8_10.2: type = bind_symbolic_name T 0, %T.loc8_10.1 [symbolic = constants.%T] -// CHECK:STDOUT: %T.ref.loc8_25: type = name_ref T, %T.loc8_10.2 [symbolic = constants.%T] -// CHECK:STDOUT: %n.loc8_22.1: %T = param n -// CHECK:STDOUT: @F.%n: %T = bind_name n, %n.loc8_22.1 -// CHECK:STDOUT: %T.ref.loc8_31: type = name_ref T, %T.loc8_10.2 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [symbolic = constants.%F.1] { +// CHECK:STDOUT: %T.loc10_10.1: type = param T +// CHECK:STDOUT: %T.loc10_10.2: type = bind_symbolic_name T 0, %T.loc10_10.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.ref.loc10_25: type = name_ref T, %T.loc10_10.2 [symbolic = constants.%T] +// CHECK:STDOUT: %n.loc10_22.1: %T = param n +// CHECK:STDOUT: @F.%n: %T = bind_name n, %n.loc10_22.1 +// CHECK:STDOUT: %T.ref.loc10_31: type = name_ref T, %T.loc10_10.2 [symbolic = constants.%T] // CHECK:STDOUT: @F.%return: ref %T = var // CHECK:STDOUT: } +// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [symbolic = constants.%G.1] { +// CHECK:STDOUT: %T.loc14_10.1: type = param T +// CHECK:STDOUT: %T.loc14_10.2: type = bind_symbolic_name T 0, %T.loc14_10.1 [symbolic = constants.%T] +// CHECK:STDOUT: %.loc14: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = constants.%Class.2] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc14 [symbolic = constants.%Class.2] +// CHECK:STDOUT: %self.loc14_22.1: %Class.2 = param self +// CHECK:STDOUT: @G.%self: %Class.2 = bind_name self, %self.loc14_22.1 +// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T.loc14_10.2 [symbolic = constants.%T] +// CHECK:STDOUT: @G.%return: ref %T = var +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type] { -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %T.ref.loc5_11: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T.ref.loc5_11 (constants.%T)] -// CHECK:STDOUT: %n.loc5_8.1: @Class.%T.ref.loc5_11 (%T) = param n -// CHECK:STDOUT: %n.loc5_8.2: @Class.%T.ref.loc5_11 (%T) = bind_name n, %n.loc5_8.1 -// CHECK:STDOUT: %T.ref.loc5_17: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T.ref.loc5_11 (constants.%T)] -// CHECK:STDOUT: %return.var: ref %T = var +// CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @Class.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %G.type: type = fn_type @G, @Class(%T) [symbolic = %G.type (constants.%G.type)] +// CHECK:STDOUT: %G: @Class.%G.type (%G.type) = struct_value () [symbolic = %G (constants.%G.1)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %T.ref.loc5_11: type = name_ref T, file.%T.loc4_13.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %n.loc5_8.1: @F.%T (%T) = param n +// CHECK:STDOUT: %n.loc5_8.2: @F.%T (%T) = bind_name n, %n.loc5_8.1 +// CHECK:STDOUT: %T.ref.loc5_17: type = name_ref T, file.%T.loc4_13.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %return.var.loc5: ref @F.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %G.decl: @Class.%G.type (%G.type) = fn_decl @G [symbolic = %G (constants.%G.1)] { +// CHECK:STDOUT: %.loc6: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc6 [symbolic = @G.%Class (constants.%Class.2)] +// CHECK:STDOUT: %self.loc6_8.1: @G.%Class (%Class.2) = param self +// CHECK:STDOUT: %self.loc6_8.2: @G.%Class (%Class.2) = bind_name self, %self.loc6_8.1 +// CHECK:STDOUT: %T.ref.loc6: type = name_ref T, file.%T.loc4_13.2 [symbolic = @G.%T (constants.%T)] +// CHECK:STDOUT: %return.var.loc6: ref @G.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %T.ref.loc7: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc7: @Class.%.1 (%.2) = field_decl n, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: .n = %.loc7 // CHECK:STDOUT: } +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: generic fn @F(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%n: %T) -> %T { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %n.ref: @F.%T (%T) = name_ref n, %n +// CHECK:STDOUT: return %n.ref +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%n: %T) -> %T -// CHECK:STDOUT: generic [file.%T.loc4_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %n.ref: %T = name_ref n, %n -// CHECK:STDOUT: return %n.ref +// CHECK:STDOUT: generic fn @G(file.%T.loc4_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = unbound_element_type @G.%Class (%Class.2), @G.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Class.2]() -> %T { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @G.%Class (%Class.2) = name_ref self, %self +// CHECK:STDOUT: %n.ref: @G.%.1 (%.2) = name_ref n, @Class.%.loc7 [template = @Class.%.loc7] +// CHECK:STDOUT: %.loc15_14.1: ref @G.%T (%T) = class_element_access %self.ref, element0 +// CHECK:STDOUT: %.loc15_14.2: @G.%T (%T) = bind_value %.loc15_14.1 +// CHECK:STDOUT: return %.loc15_14.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: %G.type => constants.%G.type +// CHECK:STDOUT: %G => constants.%G.2 +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@G.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- nested.carbon @@ -163,35 +270,47 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %A.type: type = generic_class_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A.1: %A.type = struct_value () [template] -// CHECK:STDOUT: %A.2: type = class_type @A, (%T) [symbolic] +// CHECK:STDOUT: %A.2: type = class_type @A, @A(%T) [symbolic] // CHECK:STDOUT: %N: %T = bind_symbolic_name N 1 [symbolic] // CHECK:STDOUT: %B.type: type = generic_class_type @B [template] // CHECK:STDOUT: %B.1: %B.type = struct_value () [template] -// CHECK:STDOUT: %B.2: type = class_type @B, (%T, %N) [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %B.2: type = class_type @B, @B(%T, %N) [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F, @B(%T, %N) [symbolic] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.3: type = ptr_type %.2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [template = constants.%A.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = @A.%T (constants.%T)] // CHECK:STDOUT: } -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [symbolic = constants.%F.1] { // CHECK:STDOUT: %T.loc10_6.1: type = param T // CHECK:STDOUT: %T.loc10_6.2: type = bind_symbolic_name T 0, %T.loc10_6.1 [symbolic = constants.%T] // CHECK:STDOUT: %T.ref.loc10_22: type = name_ref T, %T.loc10_6.2 [symbolic = constants.%T] // CHECK:STDOUT: %N.loc10_18.1: %T = param N // CHECK:STDOUT: %N.loc10_18.2: %T = bind_symbolic_name N 1, %N.loc10_18.1 [symbolic = constants.%N] -// CHECK:STDOUT: %.loc10: type = specific_constant constants.%B.2, (constants.%T, constants.%N) [symbolic = constants.%B.2] +// CHECK:STDOUT: %.loc10: type = specific_constant constants.%B.2, @B(constants.%T, constants.%N) [symbolic = constants.%B.2] // CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc10 [symbolic = constants.%B.2] // CHECK:STDOUT: %self.loc10_27.1: %B.2 = param self // CHECK:STDOUT: @F.%self: %B.2 = bind_name self, %self.loc10_27.1 @@ -201,40 +320,91 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @A -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type] { -// CHECK:STDOUT: %B.decl: %B.type = class_decl @B [template = constants.%B.1] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = %T.ref (constants.%T)] -// CHECK:STDOUT: %N.loc5_11.1: @A.%T.ref (%T) = param N -// CHECK:STDOUT: %N.loc5_11.2: @A.%T.ref (%T) = bind_symbolic_name N 1, %N.loc5_11.1 [symbolic = %N.loc5_11.2 (constants.%N)] +// CHECK:STDOUT: generic class @A(file.%T.loc4_9.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %B.decl: %B.type = class_decl @B [template = constants.%B.1] { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = @B.%T (constants.%T)] +// CHECK:STDOUT: %N.loc5_11.1: @B.%T (%T) = param N +// CHECK:STDOUT: %N.loc5_11.2: @B.%T (%T) = bind_symbolic_name N 1, %N.loc5_11.1 [symbolic = @B.%N (constants.%N)] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%A.2 +// CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%A.2 -// CHECK:STDOUT: .B = %B.decl +// CHECK:STDOUT: generic class @B(file.%T.loc4_9.2: type, @A.%N.loc5_11.2: @B.%T (%T)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: %T = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %F.type: type = fn_type @F, @B(%T, %N) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @B.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %F.decl: @B.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %.loc6: type = specific_constant constants.%B.2, @B(constants.%T, constants.%N) [symbolic = @F.%B (constants.%B.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc6 [symbolic = @F.%B (constants.%B.2)] +// CHECK:STDOUT: %self.loc6_10.1: @F.%B (%B.2) = param self +// CHECK:STDOUT: %self.loc6_10.2: @F.%B (%B.2) = bind_name self, %self.loc6_10.1 +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %a.loc6_22.1: @F.%T (%T) = param a +// CHECK:STDOUT: %a.loc6_22.2: @F.%T (%T) = bind_name a, %a.loc6_22.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%B.2 +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @B -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type, @A.%N.loc5_11.2: @A.%T.ref (%T)] { -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %.loc6: type = specific_constant constants.%B.2, (constants.%T, constants.%N) [symbolic = %.loc6 (constants.%B.2)] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc6 [symbolic = %.loc6 (constants.%B.2)] -// CHECK:STDOUT: %self.loc6_10.1: @B.%.loc6 (%B.2) = param self -// CHECK:STDOUT: %self.loc6_10.2: @B.%.loc6 (%B.2) = bind_name self, %self.loc6_10.1 -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = %T.ref (constants.%T)] -// CHECK:STDOUT: %a.loc6_22.1: @B.%T.ref (%T) = param a -// CHECK:STDOUT: %a.loc6_22.2: @B.%T.ref (%T) = bind_name a, %a.loc6_22.1 +// CHECK:STDOUT: generic fn @F(file.%T.loc4_9.2: type, @A.%N.loc5_11.2: @B.%T (%T)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: %T = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: %B: type = class_type @B, @B(%T, %N) [symbolic = %B (constants.%B.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %B.2](%a: %T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return // CHECK:STDOUT: } +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%B.2 -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: specific @A(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[%self: %B.2](%a: %T) -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type, @A.%N.loc5_11.2: @A.%T.ref (%T)] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @B(constants.%T, constants.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @B(@F.%T, @F.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T, constants.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: %B => constants.%B.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @B(@B.%T, @B.%N) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatched_not_generic_vs_generic.carbon @@ -250,17 +420,28 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %.3: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NotGeneric = %NotGeneric.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NotGeneric.decl: type = class_decl @NotGeneric [template = constants.%NotGeneric] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %T.loc15_15.1: type = param T -// CHECK:STDOUT: %T.loc15_15.2: type = bind_symbolic_name T 0, %T.loc15_15.1 [symbolic = %T.loc15_15.2 (constants.%T)] +// CHECK:STDOUT: %T.loc15_15.2: type = bind_symbolic_name T 0, %T.loc15_15.1 [symbolic = @.1.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -274,10 +455,19 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @F(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() -// CHECK:STDOUT: generic [file.%T.loc15_15.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @.1(file.%T.loc15_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatched_too_few_args.carbon @@ -287,45 +477,75 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Generic.type: type = generic_class_type @Generic [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Generic.1: %Generic.type = struct_value () [template] -// CHECK:STDOUT: %Generic.2: type = class_type @Generic, (%T) [symbolic] -// CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew [template] -// CHECK:STDOUT: %TooFew: %TooFew.type = struct_value () [template] +// CHECK:STDOUT: %Generic.2: type = class_type @Generic, @Generic(%T) [symbolic] +// CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew, @Generic(%T) [symbolic] +// CHECK:STDOUT: %TooFew: %TooFew.type = struct_value () [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.type: type = fn_type @.1 [template] // CHECK:STDOUT: %.3: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Generic = %Generic.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = @Generic.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Generic -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type] { -// CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] {} +// CHECK:STDOUT: generic class @Generic(file.%T.loc4_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Generic.2 -// CHECK:STDOUT: .TooFew = %TooFew.decl +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew, @Generic(%T) [symbolic = %TooFew.type (constants.%TooFew.type)] +// CHECK:STDOUT: %TooFew: @Generic.%TooFew.type (%TooFew.type) = struct_value () [symbolic = %TooFew (constants.%TooFew)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %TooFew.decl: @Generic.%TooFew.type (%TooFew.type) = fn_decl @TooFew [symbolic = %TooFew (constants.%TooFew)] {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Generic.2 +// CHECK:STDOUT: .TooFew = %TooFew.decl +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @TooFew() -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type]; +// CHECK:STDOUT: generic fn @TooFew(file.%T.loc4_15.2: type) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @.1() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @TooFew(constants.%T) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(@Generic.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatched_too_many_args.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -333,50 +553,91 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Generic.type: type = generic_class_type @Generic [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Generic.1: %Generic.type = struct_value () [template] -// CHECK:STDOUT: %Generic.2: type = class_type @Generic, (%T) [symbolic] -// CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany [template] -// CHECK:STDOUT: %TooMany: %TooMany.type = struct_value () [template] +// CHECK:STDOUT: %Generic.2: type = class_type @Generic, @Generic(%T) [symbolic] +// CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany, @Generic(%T) [symbolic] +// CHECK:STDOUT: %TooMany: %TooMany.type = struct_value () [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic] // CHECK:STDOUT: %.type: type = fn_type @.1 [template] // CHECK:STDOUT: %.3: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Generic = %Generic.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = @Generic.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %T.loc15_12.1: type = param T -// CHECK:STDOUT: %T.loc15_12.2: type = bind_symbolic_name T 0, %T.loc15_12.1 [symbolic = %T.loc15_12.2 (constants.%T)] +// CHECK:STDOUT: %T.loc15_12.2: type = bind_symbolic_name T 0, %T.loc15_12.1 [symbolic = @.1.%T (constants.%T)] // CHECK:STDOUT: %U.loc15_22.1: type = param U -// CHECK:STDOUT: %U.loc15_22.2: type = bind_symbolic_name U 1, %U.loc15_22.1 [symbolic = %U.loc15_22.2 (constants.%U)] +// CHECK:STDOUT: %U.loc15_22.2: type = bind_symbolic_name U 1, %U.loc15_22.1 [symbolic = @.1.%U (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Generic -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type] { -// CHECK:STDOUT: %TooMany.decl: %TooMany.type = fn_decl @TooMany [template = constants.%TooMany] {} +// CHECK:STDOUT: generic class @Generic(file.%T.loc4_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Generic.2 -// CHECK:STDOUT: .TooMany = %TooMany.decl +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany, @Generic(%T) [symbolic = %TooMany.type (constants.%TooMany.type)] +// CHECK:STDOUT: %TooMany: @Generic.%TooMany.type (%TooMany.type) = struct_value () [symbolic = %TooMany (constants.%TooMany)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %TooMany.decl: @Generic.%TooMany.type (%TooMany.type) = fn_decl @TooMany [symbolic = %TooMany (constants.%TooMany)] {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Generic.2 +// CHECK:STDOUT: .TooMany = %TooMany.decl +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @TooMany() -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type]; +// CHECK:STDOUT: generic fn @TooMany(file.%T.loc4_15.2: type) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() -// CHECK:STDOUT: generic [file.%T.loc15_12.2: type, file.%U.loc15_22.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(file.%T.loc15_12.2: type, file.%U.loc15_22.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @TooMany(constants.%T) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(@Generic.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T, constants.%U) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %U => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatched_wrong_arg_type.carbon @@ -386,49 +647,88 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Generic.type: type = generic_class_type @Generic [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Generic.1: %Generic.type = struct_value () [template] -// CHECK:STDOUT: %Generic.2: type = class_type @Generic, (%T.1) [symbolic] -// CHECK:STDOUT: %WrongType.type: type = fn_type @WrongType [template] -// CHECK:STDOUT: %WrongType: %WrongType.type = struct_value () [template] +// CHECK:STDOUT: %Generic.2: type = class_type @Generic, @Generic(%T.1) [symbolic] +// CHECK:STDOUT: %WrongType.type: type = fn_type @WrongType, @Generic(%T.1) [symbolic] +// CHECK:STDOUT: %WrongType: %WrongType.type = struct_value () [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %T.2: %.1 = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %.type: type = fn_type @.1 [template] // CHECK:STDOUT: %.3: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Generic = %Generic.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = @Generic.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %.loc14_17.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc14_17.2: type = converted %.loc14_17.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %T.loc14_12.1: %.1 = param T -// CHECK:STDOUT: %T.loc14_12.2: %.1 = bind_symbolic_name T 0, %T.loc14_12.1 [symbolic = %T.loc14_12.2 (constants.%T.2)] +// CHECK:STDOUT: %T.loc14_12.2: %.1 = bind_symbolic_name T 0, %T.loc14_12.1 [symbolic = @.1.%T (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Generic -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type] { -// CHECK:STDOUT: %WrongType.decl: %WrongType.type = fn_decl @WrongType [template = constants.%WrongType] {} +// CHECK:STDOUT: generic class @Generic(file.%T.loc4_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Generic.2 -// CHECK:STDOUT: .WrongType = %WrongType.decl +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %WrongType.type: type = fn_type @WrongType, @Generic(%T) [symbolic = %WrongType.type (constants.%WrongType.type)] +// CHECK:STDOUT: %WrongType: @Generic.%WrongType.type (%WrongType.type) = struct_value () [symbolic = %WrongType (constants.%WrongType)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %WrongType.decl: @Generic.%WrongType.type (%WrongType.type) = fn_decl @WrongType [symbolic = %WrongType (constants.%WrongType)] {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Generic.2 +// CHECK:STDOUT: .WrongType = %WrongType.decl +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @WrongType() -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type]; +// CHECK:STDOUT: generic fn @WrongType(file.%T.loc4_15.2: type) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() -// CHECK:STDOUT: generic [file.%T.loc14_12.2: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(file.%T.loc14_12.2: %.1) { +// CHECK:STDOUT: %T: %.1 = bind_symbolic_name T 0 [symbolic = %T (constants.%T.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @WrongType(constants.%T.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(@Generic.%T) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T.2) { +// CHECK:STDOUT: %T => constants.%T.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/method_deduce.carbon b/toolchain/check/testdata/class/generic/method_deduce.carbon new file mode 100644 index 0000000000000..6a3415ef9bef6 --- /dev/null +++ b/toolchain/check/testdata/class/generic/method_deduce.carbon @@ -0,0 +1,253 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/method_deduce.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/method_deduce.carbon + +class A {} +class B {} + +class Class(T:! type) { + fn Get(U:! type) -> (T, U); + fn GetNoDeduce(x: T, U:! type) -> (T, U); +} + +fn CallGenericMethod(c: Class(A)) -> (A, B) { + return c.Get(B); +} + +fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) { + return c.GetNoDeduce({}, B); +} + +// CHECK:STDOUT: --- method_deduce.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %A: type = class_type @A [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %B: type = class_type @B [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic] +// CHECK:STDOUT: %.3: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %.4: type = tuple_type (%T, %U) [symbolic] +// CHECK:STDOUT: %Get.type.1: type = fn_type @Get, @Class(%T) [symbolic] +// CHECK:STDOUT: %Get.1: %Get.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %GetNoDeduce.type.1: type = fn_type @GetNoDeduce, @Class(%T) [symbolic] +// CHECK:STDOUT: %GetNoDeduce.1: %GetNoDeduce.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %Class.3: type = class_type @Class, @Class(%A) [template] +// CHECK:STDOUT: %.5: type = tuple_type (%A, %B) [template] +// CHECK:STDOUT: %CallGenericMethod.type: type = fn_type @CallGenericMethod [template] +// CHECK:STDOUT: %CallGenericMethod: %CallGenericMethod.type = struct_value () [template] +// CHECK:STDOUT: %.6: type = ptr_type %.1 [template] +// CHECK:STDOUT: %.7: type = tuple_type (%.6, %.6) [template] +// CHECK:STDOUT: %.8: type = ptr_type %.7 [template] +// CHECK:STDOUT: %Get.type.2: type = fn_type @Get, @Class(%A) [template] +// CHECK:STDOUT: %Get.2: %Get.type.2 = struct_value () [template] +// CHECK:STDOUT: %GetNoDeduce.type.2: type = fn_type @GetNoDeduce, @Class(%A) [template] +// CHECK:STDOUT: %GetNoDeduce.2: %GetNoDeduce.type.2 = struct_value () [template] +// CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam.type: type = fn_type @CallGenericMethodWithNonDeducedParam [template] +// CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam: %CallGenericMethodWithNonDeducedParam.type = struct_value () [template] +// CHECK:STDOUT: %struct: %A = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: .B = %B.decl +// CHECK:STDOUT: .Class = %Class.decl +// CHECK:STDOUT: .CallGenericMethod = %CallGenericMethod.decl +// CHECK:STDOUT: .CallGenericMethodWithNonDeducedParam = %CallGenericMethodWithNonDeducedParam.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} +// CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} +// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { +// CHECK:STDOUT: %T.loc14_13.1: type = param T +// CHECK:STDOUT: %T.loc14_13.2: type = bind_symbolic_name T 0, %T.loc14_13.1 [symbolic = @Class.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallGenericMethod.decl: %CallGenericMethod.type = fn_decl @CallGenericMethod [template = constants.%CallGenericMethod] { +// CHECK:STDOUT: %Class.ref.loc19: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %A.ref.loc19_31: type = name_ref A, %A.decl [template = constants.%A] +// CHECK:STDOUT: %.loc19_30: init type = call %Class.ref.loc19(%A.ref.loc19_31) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc19_32.1: type = value_of_initializer %.loc19_30 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc19_32.2: type = converted %.loc19_30, %.loc19_32.1 [template = constants.%Class.3] +// CHECK:STDOUT: %c.loc19_22.1: %Class.3 = param c +// CHECK:STDOUT: @CallGenericMethod.%c: %Class.3 = bind_name c, %c.loc19_22.1 +// CHECK:STDOUT: %A.ref.loc19_39: type = name_ref A, %A.decl [template = constants.%A] +// CHECK:STDOUT: %B.ref.loc19: type = name_ref B, %B.decl [template = constants.%B] +// CHECK:STDOUT: %.loc19_43.1: %.3 = tuple_literal (%A.ref.loc19_39, %B.ref.loc19) +// CHECK:STDOUT: %.loc19_43.2: type = converted %.loc19_43.1, constants.%.5 [template = constants.%.5] +// CHECK:STDOUT: @CallGenericMethod.%return: ref %.5 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam.decl: %CallGenericMethodWithNonDeducedParam.type = fn_decl @CallGenericMethodWithNonDeducedParam [template = constants.%CallGenericMethodWithNonDeducedParam] { +// CHECK:STDOUT: %Class.ref.loc23: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %A.ref.loc23_50: type = name_ref A, %A.decl [template = constants.%A] +// CHECK:STDOUT: %.loc23_49: init type = call %Class.ref.loc23(%A.ref.loc23_50) [template = constants.%Class.3] +// CHECK:STDOUT: %.loc23_51.1: type = value_of_initializer %.loc23_49 [template = constants.%Class.3] +// CHECK:STDOUT: %.loc23_51.2: type = converted %.loc23_49, %.loc23_51.1 [template = constants.%Class.3] +// CHECK:STDOUT: %c.loc23_41.1: %Class.3 = param c +// CHECK:STDOUT: @CallGenericMethodWithNonDeducedParam.%c: %Class.3 = bind_name c, %c.loc23_41.1 +// CHECK:STDOUT: %A.ref.loc23_58: type = name_ref A, %A.decl [template = constants.%A] +// CHECK:STDOUT: %B.ref.loc23: type = name_ref B, %B.decl [template = constants.%B] +// CHECK:STDOUT: %.loc23_62.1: %.3 = tuple_literal (%A.ref.loc23_58, %B.ref.loc23) +// CHECK:STDOUT: %.loc23_62.2: type = converted %.loc23_62.1, constants.%.5 [template = constants.%.5] +// CHECK:STDOUT: @CallGenericMethodWithNonDeducedParam.%return: ref %.5 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @A { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%A +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @B { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%B +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Class(file.%T.loc14_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Get.type: type = fn_type @Get, @Class(%T) [symbolic = %Get.type (constants.%Get.type.1)] +// CHECK:STDOUT: %Get: @Class.%Get.type (%Get.type.1) = struct_value () [symbolic = %Get (constants.%Get.1)] +// CHECK:STDOUT: %GetNoDeduce.type: type = fn_type @GetNoDeduce, @Class(%T) [symbolic = %GetNoDeduce.type (constants.%GetNoDeduce.type.1)] +// CHECK:STDOUT: %GetNoDeduce: @Class.%GetNoDeduce.type (%GetNoDeduce.type.1) = struct_value () [symbolic = %GetNoDeduce (constants.%GetNoDeduce.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %Get.decl: @Class.%Get.type (%Get.type.1) = fn_decl @Get [symbolic = %Get (constants.%Get.1)] { +// CHECK:STDOUT: %U.loc15_10.1: type = param U +// CHECK:STDOUT: %U.loc15_10.2: type = bind_symbolic_name U 1, %U.loc15_10.1 [symbolic = @Get.%U.1 (constants.%U)] +// CHECK:STDOUT: %T.ref.loc15: type = name_ref T, file.%T.loc14_13.2 [symbolic = @Get.%T (constants.%T)] +// CHECK:STDOUT: %U.ref.loc15: type = name_ref U, %U.loc15_10.2 [symbolic = @Get.%U.1 (constants.%U)] +// CHECK:STDOUT: %.loc15_28.1: %.3 = tuple_literal (%T.ref.loc15, %U.ref.loc15) +// CHECK:STDOUT: %.loc15_28.2: type = converted %.loc15_28.1, constants.%.4 [symbolic = @Get.%.1 (constants.%.4)] +// CHECK:STDOUT: %return.var.loc15: ref @Get.%.1 (%.4) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %GetNoDeduce.decl: @Class.%GetNoDeduce.type (%GetNoDeduce.type.1) = fn_decl @GetNoDeduce [symbolic = %GetNoDeduce (constants.%GetNoDeduce.1)] { +// CHECK:STDOUT: %T.ref.loc16_21: type = name_ref T, file.%T.loc14_13.2 [symbolic = @GetNoDeduce.%T (constants.%T)] +// CHECK:STDOUT: %x.loc16_18.1: @GetNoDeduce.%T (%T) = param x +// CHECK:STDOUT: %x.loc16_18.2: @GetNoDeduce.%T (%T) = bind_name x, %x.loc16_18.1 +// CHECK:STDOUT: %U.loc16_24.1: type = param U +// CHECK:STDOUT: %U.loc16_24.2: type = bind_symbolic_name U 1, %U.loc16_24.1 [symbolic = @GetNoDeduce.%U.1 (constants.%U)] +// CHECK:STDOUT: %T.ref.loc16_38: type = name_ref T, file.%T.loc14_13.2 [symbolic = @GetNoDeduce.%T (constants.%T)] +// CHECK:STDOUT: %U.ref.loc16: type = name_ref U, %U.loc16_24.2 [symbolic = @GetNoDeduce.%U.1 (constants.%U)] +// CHECK:STDOUT: %.loc16_42.1: %.3 = tuple_literal (%T.ref.loc16_38, %U.ref.loc16) +// CHECK:STDOUT: %.loc16_42.2: type = converted %.loc16_42.1, constants.%.4 [symbolic = @GetNoDeduce.%.1 (constants.%.4)] +// CHECK:STDOUT: %return.var.loc16: ref @GetNoDeduce.%.1 (%.4) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .Get = %Get.decl +// CHECK:STDOUT: .GetNoDeduce = %GetNoDeduce.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Get(file.%T.loc14_13.2: type, @Class.%U.loc15_10.2: type) { +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.1: type = tuple_type (@Get.%T (%T), @Get.%U.1 (%U)) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@Class.%U.loc15_10.2: type) -> @Get.%.1 (%.4); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @GetNoDeduce(file.%T.loc14_13.2: type, @Class.%U.loc16_24.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: %.1: type = tuple_type (@GetNoDeduce.%T (%T), @GetNoDeduce.%U.1 (%U)) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@Class.%x.loc16_18.2: @GetNoDeduce.%T (%T), @Class.%U.loc16_24.2: type) -> @GetNoDeduce.%.1 (%.4); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallGenericMethod(%c: %Class.3) -> %return: %.5 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: %Class.3 = name_ref c, %c +// CHECK:STDOUT: %.loc20: %Get.type.2 = specific_constant @Class.%Get.decl, @Class(constants.%A) [template = constants.%Get.2] +// CHECK:STDOUT: %Get.ref: %Get.type.2 = name_ref Get, %.loc20 [template = constants.%Get.2] +// CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] +// CHECK:STDOUT: %.loc19: ref %.5 = splice_block %return {} +// CHECK:STDOUT: %Get.call: init %.5 = call %Get.ref(%B.ref) to %.loc19 +// CHECK:STDOUT: return %Get.call to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallGenericMethodWithNonDeducedParam(%c: %Class.3) -> %return: %.5 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: %Class.3 = name_ref c, %c +// CHECK:STDOUT: %.loc24_11: %GetNoDeduce.type.2 = specific_constant @Class.%GetNoDeduce.decl, @Class(constants.%A) [template = constants.%GetNoDeduce.2] +// CHECK:STDOUT: %GetNoDeduce.ref: %GetNoDeduce.type.2 = name_ref GetNoDeduce, %.loc24_11 [template = constants.%GetNoDeduce.2] +// CHECK:STDOUT: %.loc24_25.1: %.1 = struct_literal () +// CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] +// CHECK:STDOUT: %.loc23: ref %.5 = splice_block %return {} +// CHECK:STDOUT: %.loc24_25.2: ref %A = temporary_storage +// CHECK:STDOUT: %.loc24_25.3: init %A = class_init (), %.loc24_25.2 [template = constants.%struct] +// CHECK:STDOUT: %.loc24_25.4: ref %A = temporary %.loc24_25.2, %.loc24_25.3 +// CHECK:STDOUT: %.loc24_23.1: ref %A = converted %.loc24_25.1, %.loc24_25.4 +// CHECK:STDOUT: %.loc24_23.2: %A = bind_value %.loc24_23.1 +// CHECK:STDOUT: %GetNoDeduce.call: init %.5 = call %GetNoDeduce.ref(%.loc24_23.2, %B.ref) to %.loc23 +// CHECK:STDOUT: return %GetNoDeduce.call to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Get(constants.%T, constants.%U) { +// CHECK:STDOUT: %U.1 => constants.%U +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GetNoDeduce(constants.%T, constants.%U) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %U.1 => constants.%U +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%A) { +// CHECK:STDOUT: %T => constants.%A +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Get.type => constants.%Get.type.2 +// CHECK:STDOUT: %Get => constants.%Get.2 +// CHECK:STDOUT: %GetNoDeduce.type => constants.%GetNoDeduce.type.2 +// CHECK:STDOUT: %GetNoDeduce => constants.%GetNoDeduce.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Get(constants.%A, constants.%B) { +// CHECK:STDOUT: %U.1 => constants.%B +// CHECK:STDOUT: %T => constants.%A +// CHECK:STDOUT: %.1 => constants.%.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GetNoDeduce(constants.%A, constants.%B) { +// CHECK:STDOUT: %T => constants.%A +// CHECK:STDOUT: %U.1 => constants.%B +// CHECK:STDOUT: %.1 => constants.%.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/redeclare.carbon b/toolchain/check/testdata/class/generic/redeclare.carbon index 89f4c16fd5514..d9d0eb9428b61 100644 --- a/toolchain/check/testdata/class/generic/redeclare.carbon +++ b/toolchain/check/testdata/class/generic/redeclare.carbon @@ -93,20 +93,31 @@ class E(U:! type) {} // CHECK:STDOUT: %Generic.type: type = generic_class_type @Generic [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Generic.1: %Generic.type = struct_value () [template] -// CHECK:STDOUT: %Generic.2: type = class_type @Generic, (%T) [symbolic] +// CHECK:STDOUT: %Generic.2: type = class_type @Generic, @Generic(%T) [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Generic = %Generic.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl.loc4: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = @Generic.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %Generic.decl.loc6: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc6_15.1: type = param T @@ -114,10 +125,19 @@ class E(U:! type) {} // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Generic -// CHECK:STDOUT: generic [file.%T.loc4_15.2: type] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Generic.2 +// CHECK:STDOUT: generic class @Generic(file.%T.loc4_15.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Generic.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatch_param_list.carbon @@ -128,30 +148,50 @@ class E(U:! type) {} // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = class_type @.1, (%T) [symbolic] +// CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T) [symbolic] // CHECK:STDOUT: %.4: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc12_9.1: type = param T -// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T)] +// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = @.1.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A; // CHECK:STDOUT: -// CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%T.loc12_9.2: type] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: generic class @.1(file.%T.loc12_9.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatch_implicit_param_list.carbon @@ -163,53 +203,80 @@ class E(U:! type) {} // CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic] // CHECK:STDOUT: %B.type: type = generic_class_type @B [template] // CHECK:STDOUT: %B.1: %B.type = struct_value () [template] -// CHECK:STDOUT: %B.2: type = class_type @B, (%N.1) [symbolic] +// CHECK:STDOUT: %B.2: type = class_type @B, @B(%N.1) [symbolic] // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %N.2: %T = bind_symbolic_name N 1 [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = class_type @.1, (%T, %N.2) [symbolic] +// CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T, %N.2) [symbolic] // CHECK:STDOUT: %.4: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: %B.type = class_decl @B [template = constants.%B.1] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_13.2: type = converted %int.make_type_32, %.loc4_13.1 [template = i32] // CHECK:STDOUT: %N.loc4_9.1: i32 = param N -// CHECK:STDOUT: %N.loc4_9.2: i32 = bind_symbolic_name N 0, %N.loc4_9.1 [symbolic = %N.loc4_9.2 (constants.%N.1)] +// CHECK:STDOUT: %N.loc4_9.2: i32 = bind_symbolic_name N 0, %N.loc4_9.1 [symbolic = @B.%N (constants.%N.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc12_9.1: type = param T -// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T)] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc12_9.2 [symbolic = %T.loc12_9.2 (constants.%T)] -// CHECK:STDOUT: %N.loc12_19.1: file.%T.loc12_9.2 (%T) = param N -// CHECK:STDOUT: %N.loc12_19.2: file.%T.loc12_9.2 (%T) = bind_symbolic_name N 1, %N.loc12_19.1 [symbolic = %N.loc12_19.2 (constants.%N.2)] +// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = @.1.%T (constants.%T)] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc12_9.2 [symbolic = @.1.%T (constants.%T)] +// CHECK:STDOUT: %N.loc12_19.1: @.1.%T (%T) = param N +// CHECK:STDOUT: %N.loc12_19.2: @.1.%T (%T) = bind_symbolic_name N 1, %N.loc12_19.1 [symbolic = @.1.%N (constants.%N.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @B -// CHECK:STDOUT: generic [file.%N.loc4_9.2: i32]; +// CHECK:STDOUT: generic class @B(file.%N.loc4_9.2: i32) { +// CHECK:STDOUT: %N: i32 = bind_symbolic_name N 0 [symbolic = %N (constants.%N.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @.1(file.%T.loc12_9.2: type, file.%N.loc12_19.2: @.1.%T (%T)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %N: %T = bind_symbolic_name N 1 [symbolic = %N (constants.%N.2)] // CHECK:STDOUT: -// CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%T.loc12_9.2: type, file.%N.loc12_19.2: file.%T.loc12_9.2 (%T)] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @B(constants.%N.1) { +// CHECK:STDOUT: %N => constants.%N.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T, constants.%N.2) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %N => constants.%N.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatch_param_count.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -217,53 +284,80 @@ class E(U:! type) {} // CHECK:STDOUT: %C.type: type = generic_class_type @C [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] -// CHECK:STDOUT: %C.2: type = class_type @C, (%T) [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%T) [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %U: i32 = bind_symbolic_name U 1 [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = class_type @.1, (%T, %U) [symbolic] +// CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T, %U) [symbolic] // CHECK:STDOUT: %.4: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = @C.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc12_9.1: type = param T -// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T)] +// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = @.1.%T (constants.%T)] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_23.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc12_23.2: type = converted %int.make_type_32, %.loc12_23.1 [template = i32] // CHECK:STDOUT: %U.loc12_19.1: i32 = param U -// CHECK:STDOUT: %U.loc12_19.2: i32 = bind_symbolic_name U 1, %U.loc12_19.1 [symbolic = %U.loc12_19.2 (constants.%U)] +// CHECK:STDOUT: %U.loc12_19.2: i32 = bind_symbolic_name U 1, %U.loc12_19.1 [symbolic = @.1.%U (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type]; +// CHECK:STDOUT: generic class @C(file.%T.loc4_9.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%T.loc12_9.2: type, file.%U.loc12_19.2: i32] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @.1(file.%T.loc12_9.2: type, file.%U.loc12_19.2: i32) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %U: i32 = bind_symbolic_name U 1 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T, constants.%U) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatch_param_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -271,51 +365,76 @@ class E(U:! type) {} // CHECK:STDOUT: %D.type: type = generic_class_type @D [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %D.1: %D.type = struct_value () [template] -// CHECK:STDOUT: %D.2: type = class_type @D, (%T.1) [symbolic] +// CHECK:STDOUT: %D.2: type = class_type @D, @D(%T.1) [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %T.2: i32 = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = class_type @.1, (%T.2) [symbolic] +// CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T.2) [symbolic] // CHECK:STDOUT: %.4: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.decl: %D.type = class_decl @D [template = constants.%D.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = @D.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32, %.loc12_13.1 [template = i32] // CHECK:STDOUT: %T.loc12_9.1: i32 = param T -// CHECK:STDOUT: %T.loc12_9.2: i32 = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T.2)] +// CHECK:STDOUT: %T.loc12_9.2: i32 = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = @.1.%T (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @D -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type]; +// CHECK:STDOUT: generic class @D(file.%T.loc4_9.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] // CHECK:STDOUT: -// CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%T.loc12_9.2: i32] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @.1(file.%T.loc12_9.2: i32) { +// CHECK:STDOUT: %T: i32 = bind_symbolic_name T 0 [symbolic = %T (constants.%T.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @D(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T.2) { +// CHECK:STDOUT: %T => constants.%T.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatch_param_name.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -323,37 +442,64 @@ class E(U:! type) {} // CHECK:STDOUT: %E.type: type = generic_class_type @E [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %E.1: %E.type = struct_value () [template] -// CHECK:STDOUT: %E.2: type = class_type @E, (%T) [symbolic] +// CHECK:STDOUT: %E.2: type = class_type @E, @E(%T) [symbolic] // CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = class_type @.1, (%U) [symbolic] +// CHECK:STDOUT: %.3: type = class_type @.1, @.1(%U) [symbolic] // CHECK:STDOUT: %.4: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .E = %E.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %E.decl: %E.type = class_decl @E [template = constants.%E.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = @E.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %U.loc11_9.1: type = param U -// CHECK:STDOUT: %U.loc11_9.2: type = bind_symbolic_name U 0, %U.loc11_9.1 [symbolic = %U.loc11_9.2 (constants.%U)] +// CHECK:STDOUT: %U.loc11_9.2: type = bind_symbolic_name U 0, %U.loc11_9.1 [symbolic = @.1.%U (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @E -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type]; +// CHECK:STDOUT: generic class @E(file.%T.loc4_9.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @.1(file.%U.loc11_9.2: type) { +// CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @E(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%U.loc11_9.2: type] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%.3 +// CHECK:STDOUT: specific @.1(constants.%U) { +// CHECK:STDOUT: %U => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/self.carbon b/toolchain/check/testdata/class/generic/self.carbon index 1f7e9c2fb7f69..c0a5d5b80ba35 100644 --- a/toolchain/check/testdata/class/generic/self.carbon +++ b/toolchain/check/testdata/class/generic/self.carbon @@ -26,82 +26,166 @@ class Class(T:! type) { // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] -// CHECK:STDOUT: %MakeSelf.type: type = fn_type @MakeSelf [template] -// CHECK:STDOUT: %MakeSelf: %MakeSelf.type = struct_value () [template] -// CHECK:STDOUT: %MakeClass.type: type = fn_type @MakeClass [template] -// CHECK:STDOUT: %MakeClass: %MakeClass.type = struct_value () [template] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %MakeSelf.type: type = fn_type @MakeSelf, @Class(%T) [symbolic] +// CHECK:STDOUT: %MakeSelf.1: %MakeSelf.type = struct_value () [symbolic] +// CHECK:STDOUT: %MakeClass.type: type = fn_type @MakeClass, @Class(%T) [symbolic] +// CHECK:STDOUT: %MakeClass.1: %MakeClass.type = struct_value () [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %MakeSelf.2: %MakeSelf.type = struct_value () [symbolic] +// CHECK:STDOUT: %MakeClass.2: %MakeClass.type = struct_value () [symbolic] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.3: type = ptr_type %.2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %MakeSelf.decl: %MakeSelf.type = fn_decl @MakeSelf [template = constants.%MakeSelf] { -// CHECK:STDOUT: %.loc14: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = %.loc14 (constants.%Class.2)] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc14 [symbolic = %.loc14 (constants.%Class.2)] -// CHECK:STDOUT: %return.var.loc14: ref %Class.2 = var +// CHECK:STDOUT: generic class @Class(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %MakeSelf.type: type = fn_type @MakeSelf, @Class(%T) [symbolic = %MakeSelf.type (constants.%MakeSelf.type)] +// CHECK:STDOUT: %MakeSelf: @Class.%MakeSelf.type (%MakeSelf.type) = struct_value () [symbolic = %MakeSelf (constants.%MakeSelf.1)] +// CHECK:STDOUT: %MakeClass.type: type = fn_type @MakeClass, @Class(%T) [symbolic = %MakeClass.type (constants.%MakeClass.type)] +// CHECK:STDOUT: %MakeClass: @Class.%MakeClass.type (%MakeClass.type) = struct_value () [symbolic = %MakeClass (constants.%MakeClass.1)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @Class.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %MakeSelf.decl: @Class.%MakeSelf.type (%MakeSelf.type) = fn_decl @MakeSelf [symbolic = %MakeSelf (constants.%MakeSelf.1)] { +// CHECK:STDOUT: %.loc14: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @MakeSelf.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc14 [symbolic = @MakeSelf.%Class (constants.%Class.2)] +// CHECK:STDOUT: %return.var.loc14: ref @MakeSelf.%Class (%Class.2) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %MakeClass.decl: @Class.%MakeClass.type (%MakeClass.type) = fn_decl @MakeClass [symbolic = %MakeClass (constants.%MakeClass.1)] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = @MakeClass.%T (constants.%T)] +// CHECK:STDOUT: %.loc15_26: init type = call %Class.ref(%T.ref) [symbolic = @MakeClass.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc15_28.1: type = value_of_initializer %.loc15_26 [symbolic = @MakeClass.%Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc15_28.2: type = converted %.loc15_26, %.loc15_28.1 [symbolic = @MakeClass.%Class (constants.%Class.2)] +// CHECK:STDOUT: %return.var.loc15: ref @MakeClass.%Class (%Class.2) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .MakeSelf = %MakeSelf.decl +// CHECK:STDOUT: .MakeClass = %MakeClass.decl +// CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %MakeClass.decl: %MakeClass.type = fn_decl @MakeClass [template = constants.%MakeClass] { +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @MakeSelf(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @MakeSelf.%Class (%Class.2); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @MakeClass(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @MakeClass.%Class (%Class.2); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %MakeSelf.type: type = fn_type @MakeSelf, @Class(%T) [symbolic = %MakeSelf.type (constants.%MakeSelf.type)] +// CHECK:STDOUT: %MakeSelf: @F.%MakeSelf.type (%MakeSelf.type) = struct_value () [symbolic = %MakeSelf (constants.%MakeSelf.2)] +// CHECK:STDOUT: %MakeClass.type: type = fn_type @MakeClass, @Class(%T) [symbolic = %MakeClass.type (constants.%MakeClass.type)] +// CHECK:STDOUT: %MakeClass: @F.%MakeClass.type (%MakeClass.type) = struct_value () [symbolic = %MakeClass (constants.%MakeClass.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref (constants.%T)] -// CHECK:STDOUT: %.loc15_26: init type = call %Class.ref(%T.ref) [symbolic = %.loc15_26 (constants.%Class.2)] -// CHECK:STDOUT: %.loc15_28.1: type = value_of_initializer %.loc15_26 [symbolic = %.loc15_26 (constants.%Class.2)] -// CHECK:STDOUT: %.loc15_28.2: type = converted %.loc15_26, %.loc15_28.1 [symbolic = %.loc15_26 (constants.%Class.2)] -// CHECK:STDOUT: %return.var.loc15: ref %Class.2 = var +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc17_17: init type = call %Class.ref(%T.ref) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc17_19.1: type = value_of_initializer %.loc17_17 [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.loc17_19.2: type = converted %.loc17_17, %.loc17_19.1 [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %c.var: ref @F.%Class (%Class.2) = var c +// CHECK:STDOUT: %c: ref @F.%Class (%Class.2) = bind_name c, %c.var +// CHECK:STDOUT: %.loc17_23: @F.%MakeSelf.type (%MakeSelf.type) = specific_constant @Class.%MakeSelf.decl, @Class(constants.%T) [symbolic = %MakeSelf (constants.%MakeSelf.2)] +// CHECK:STDOUT: %MakeSelf.ref: @F.%MakeSelf.type (%MakeSelf.type) = name_ref MakeSelf, %.loc17_23 [symbolic = %MakeSelf (constants.%MakeSelf.2)] +// CHECK:STDOUT: %.loc17_9: ref @F.%Class (%Class.2) = splice_block %c.var {} +// CHECK:STDOUT: %MakeSelf.call: init @F.%Class (%Class.2) = call %MakeSelf.ref() to %.loc17_9 +// CHECK:STDOUT: assign %c.var, %MakeSelf.call +// CHECK:STDOUT: %.loc18_12: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc18_12 [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %s.var: ref @F.%Class (%Class.2) = var s +// CHECK:STDOUT: %s: ref @F.%Class (%Class.2) = bind_name s, %s.var +// CHECK:STDOUT: %.loc18_19: @F.%MakeClass.type (%MakeClass.type) = specific_constant @Class.%MakeClass.decl, @Class(constants.%T) [symbolic = %MakeClass (constants.%MakeClass.2)] +// CHECK:STDOUT: %MakeClass.ref: @F.%MakeClass.type (%MakeClass.type) = name_ref MakeClass, %.loc18_19 [symbolic = %MakeClass (constants.%MakeClass.2)] +// CHECK:STDOUT: %.loc18_9: ref @F.%Class (%Class.2) = splice_block %s.var {} +// CHECK:STDOUT: %MakeClass.call: init @F.%Class (%Class.2) = call %MakeClass.ref() to %.loc18_9 +// CHECK:STDOUT: assign %s.var, %MakeClass.call +// CHECK:STDOUT: return // CHECK:STDOUT: } -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %MakeSelf.type => constants.%MakeSelf.type +// CHECK:STDOUT: %MakeSelf => constants.%MakeSelf.2 +// CHECK:STDOUT: %MakeClass.type => constants.%MakeClass.type +// CHECK:STDOUT: %MakeClass => constants.%MakeClass.2 +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@MakeSelf.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @MakeSelf(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@MakeClass.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @MakeClass(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) {} // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .MakeSelf = %MakeSelf.decl -// CHECK:STDOUT: .MakeClass = %MakeClass.decl -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @MakeSelf() -> %Class.2 -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type]; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @MakeClass() -> %Class.2 -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type]; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc17_17: init type = call %Class.ref(%T.ref) [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc17_19.1: type = value_of_initializer %.loc17_17 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc17_19.2: type = converted %.loc17_17, %.loc17_19.1 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %c.var: ref %Class.2 = var c -// CHECK:STDOUT: %c: ref %Class.2 = bind_name c, %c.var -// CHECK:STDOUT: %MakeSelf.ref: %MakeSelf.type = name_ref MakeSelf, @Class.%MakeSelf.decl [template = constants.%MakeSelf] -// CHECK:STDOUT: %.loc17_9: ref %Class.2 = splice_block %c.var {} -// CHECK:STDOUT: %MakeSelf.call: init %Class.2 = call %MakeSelf.ref() to %.loc17_9 -// CHECK:STDOUT: assign %c.var, %MakeSelf.call -// CHECK:STDOUT: %.loc18_12: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = constants.%Class.2] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc18_12 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %s.var: ref %Class.2 = var s -// CHECK:STDOUT: %s: ref %Class.2 = bind_name s, %s.var -// CHECK:STDOUT: %MakeClass.ref: %MakeClass.type = name_ref MakeClass, @Class.%MakeClass.decl [template = constants.%MakeClass] -// CHECK:STDOUT: %.loc18_9: ref %Class.2 = splice_block %s.var {} -// CHECK:STDOUT: %MakeClass.call: init %Class.2 = call %MakeClass.ref() to %.loc18_9 -// CHECK:STDOUT: assign %s.var, %MakeClass.call -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @Class(@F.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic_method.carbon b/toolchain/check/testdata/class/generic_method.carbon index 2b4bf66d5112c..38ba96a16b038 100644 --- a/toolchain/check/testdata/class/generic_method.carbon +++ b/toolchain/check/testdata/class/generic_method.carbon @@ -22,29 +22,41 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] -// CHECK:STDOUT: %Class.2: type = class_type @Class, (%T) [symbolic] +// CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.a: %T} [symbolic] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] // CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @Class.%T (constants.%T)] // CHECK:STDOUT: } -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [symbolic = constants.%F.1] { // CHECK:STDOUT: %T.loc16_10.1: type = param T // CHECK:STDOUT: %T.loc16_10.2: type = bind_symbolic_name T 0, %T.loc16_10.1 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc16: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = constants.%Class.2] +// CHECK:STDOUT: %.loc16: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = constants.%Class.2] // CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc16 [symbolic = constants.%Class.2] // CHECK:STDOUT: %self.loc16_22.1: %Class.2 = param self // CHECK:STDOUT: @F.%self: %Class.2 = bind_name self, %self.loc16_22.1 @@ -54,29 +66,67 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @Class -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: %.2 = field_decl a, element0 [template] -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %.loc13: type = specific_constant constants.%Class.2, (constants.%T) [symbolic = %.loc13 (constants.%Class.2)] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc13 [symbolic = %.loc13 (constants.%Class.2)] -// CHECK:STDOUT: %self.loc13_8.1: @Class.%.loc13 (%Class.2) = param self -// CHECK:STDOUT: %self.loc13_8.2: @Class.%.loc13 (%Class.2) = bind_name self, %self.loc13_8.1 -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc13 (constants.%T)] -// CHECK:STDOUT: %n.loc13_20.1: @Class.%T.ref.loc13 (%T) = param n -// CHECK:STDOUT: %n.loc13_20.2: @Class.%T.ref.loc13 (%T) = bind_name n, %n.loc13_20.1 +// CHECK:STDOUT: generic class @Class(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @Class(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @Class.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.loc12: @Class.%.1 (%.2) = field_decl a, element0 [template] +// CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %.loc13: type = specific_constant constants.%Class.2, @Class(constants.%T) [symbolic = @F.%Class (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc13 [symbolic = @F.%Class (constants.%Class.2)] +// CHECK:STDOUT: %self.loc13_8.1: @F.%Class (%Class.2) = param self +// CHECK:STDOUT: %self.loc13_8.2: @F.%Class (%Class.2) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %n.loc13_20.1: @F.%T (%T) = param n +// CHECK:STDOUT: %n.loc13_20.2: @F.%T (%T) = bind_name n, %n.loc13_20.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Class.2 +// CHECK:STDOUT: .a = %.loc12 +// CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Class.2](%n: %T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Class => constants.%Class.2 +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Class(@F.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Class.2 -// CHECK:STDOUT: .a = %.loc12 -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %Class => constants.%Class.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[%self: %Class.2](%n: %T) -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @Class(@Class.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/import.carbon b/toolchain/check/testdata/class/import.carbon index b2af1ac0d788c..4b4c2936e88b5 100644 --- a/toolchain/check/testdata/class/import.carbon +++ b/toolchain/check/testdata/class/import.carbon @@ -70,19 +70,28 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: .Field = %Field.decl // CHECK:STDOUT: .ForwardDeclared = %ForwardDeclared.decl.loc11 // CHECK:STDOUT: .Incomplete = %Incomplete.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Empty.decl: type = class_decl @Empty [template = constants.%Empty] {} // CHECK:STDOUT: %Field.decl: type = class_decl @Field [template = constants.%Field] {} // CHECK:STDOUT: %ForwardDeclared.decl.loc11: type = class_decl @ForwardDeclared [template = constants.%ForwardDeclared] {} @@ -153,30 +162,39 @@ fn Run() { // CHECK:STDOUT: %.8: i32 = int_literal 2 [template] // CHECK:STDOUT: %ForwardDeclared.1: type = class_type @ForwardDeclared.1 [template] // CHECK:STDOUT: %struct.3: %ForwardDeclared.1 = struct_value () [template] -// CHECK:STDOUT: %ForwardDeclared.2: type = class_type @ForwardDeclared.2 [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.9: type = ptr_type %ForwardDeclared.1 [template] +// CHECK:STDOUT: %ForwardDeclared.2: type = class_type @ForwardDeclared.2 [template] // CHECK:STDOUT: %G.type: type = fn_type @G [template] // CHECK:STDOUT: %G: %G.type = struct_value () [template] +// CHECK:STDOUT: %.9: type = ptr_type %ForwardDeclared.1 [template] // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template] // CHECK:STDOUT: %.10: type = ptr_type %Incomplete [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%Empty] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loaded [template = constants.%Field] -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+22, loaded [template = constants.%ForwardDeclared.1] -// CHECK:STDOUT: %import_ref.4: type = import_ref ir1, inst+40, loaded [template = constants.%Incomplete] -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+7, unloaded -// CHECK:STDOUT: %import_ref.7: %.7 = import_ref ir1, inst+18, loaded [template = %.1] -// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+23, unloaded -// CHECK:STDOUT: %import_ref.9: %F.type = import_ref ir1, inst+28, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.10: %G.type = import_ref ir1, inst+37, loaded [template = constants.%G] -// CHECK:STDOUT: %import_ref.11 = import_ref ir1, inst+23, unloaded -// CHECK:STDOUT: %import_ref.12 = import_ref ir1, inst+28, unloaded -// CHECK:STDOUT: %import_ref.13 = import_ref ir1, inst+37, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%Empty] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//a, inst+6, loaded [template = constants.%Field] +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//a, inst+22, loaded [template = constants.%ForwardDeclared.1] +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//a, inst+40, loaded [template = constants.%Incomplete] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Main//a, inst+4, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//a, inst+7, unloaded +// CHECK:STDOUT: %import_ref.7: %.7 = import_ref Main//a, inst+18, loaded [template = %.1] +// CHECK:STDOUT: %import_ref.8 = import_ref Main//a, inst+23, unloaded +// CHECK:STDOUT: %import_ref.9: %F.type = import_ref Main//a, inst+28, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.10: %G.type = import_ref Main//a, inst+37, loaded [template = constants.%G] +// CHECK:STDOUT: %import_ref.11 = import_ref Main//a, inst+23, unloaded +// CHECK:STDOUT: %import_ref.12 = import_ref Main//a, inst+28, unloaded +// CHECK:STDOUT: %import_ref.13 = import_ref Main//a, inst+37, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -185,12 +203,11 @@ fn Run() { // CHECK:STDOUT: .Field = imports.%import_ref.2 // CHECK:STDOUT: .ForwardDeclared = imports.%import_ref.3 // CHECK:STDOUT: .Incomplete = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/import_base.carbon b/toolchain/check/testdata/class/import_base.carbon index 39c3de0c19c7e..b19c071616b94 100644 --- a/toolchain/check/testdata/class/import_base.carbon +++ b/toolchain/check/testdata/class/import_base.carbon @@ -56,18 +56,26 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Child = %Child.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Child.decl: type = class_decl @Child [template = constants.%Child] {} // CHECK:STDOUT: } @@ -142,27 +150,35 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+38, loaded [template = constants.%Child] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir1, inst+8, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %import_ref.6: %.11 = import_ref ir1, inst+27, loaded [template = %.1] -// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+34, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+39, unloaded -// CHECK:STDOUT: %import_ref.9 = import_ref ir1, inst+43, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//a, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//a, inst+37, loaded [template = constants.%Child] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+4, unloaded +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Main//a, inst+8, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//a, inst+15, unloaded +// CHECK:STDOUT: %import_ref.6: %.11 = import_ref Main//a, inst+27, loaded [template = %.1] +// CHECK:STDOUT: %import_ref.7 = import_ref Main//a, inst+33, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref Main//a, inst+38, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Main//a, inst+42, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Base = imports.%import_ref.1 // CHECK:STDOUT: .Child = imports.%import_ref.2 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/import_forward_decl.carbon b/toolchain/check/testdata/class/import_forward_decl.carbon index cc4f7ef5f9c07..d2231d5f905f0 100644 --- a/toolchain/check/testdata/class/import_forward_decl.carbon +++ b/toolchain/check/testdata/class/import_forward_decl.carbon @@ -27,13 +27,24 @@ class ForwardDecl { // CHECK:STDOUT: %ForwardDecl: type = class_type @ForwardDecl [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .ForwardDecl = %ForwardDecl.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ForwardDecl.decl: type = class_decl @ForwardDecl [template = constants.%ForwardDecl] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -47,18 +58,26 @@ class ForwardDecl { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+3, loaded [template = constants.%ForwardDecl] +// CHECK:STDOUT: %import_ref: type = import_ref Main//a, inst+3, loaded [template = constants.%ForwardDecl] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .ForwardDecl = %ForwardDecl.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ForwardDecl.decl: type = class_decl @ForwardDecl [template = constants.%ForwardDecl] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/import_indirect.carbon b/toolchain/check/testdata/class/import_indirect.carbon index 4595e512e8887..e8c4679bb2e03 100644 --- a/toolchain/check/testdata/class/import_indirect.carbon +++ b/toolchain/check/testdata/class/import_indirect.carbon @@ -107,13 +107,24 @@ var ptr: E* = &val; // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -134,21 +145,29 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .D = %D // CHECK:STDOUT: .b_val = %b_val // CHECK:STDOUT: .b_ptr = %b_ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %D: type = bind_alias D, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, imports.%import_ref.1 [template = constants.%C] @@ -189,21 +208,29 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .E = %E // CHECK:STDOUT: .c_val = %c_val // CHECK:STDOUT: .c_ptr = %c_ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %E: type = bind_alias E, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, imports.%import_ref.1 [template = constants.%C] @@ -244,11 +271,20 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir2, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+15, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir2, inst+25, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//b, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//b, inst+15, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//b, inst+25, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Main//a, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -257,13 +293,12 @@ var ptr: E* = &val; // CHECK:STDOUT: .D = imports.%import_ref.2 // CHECK:STDOUT: .b_val = imports.%import_ref.3 // CHECK:STDOUT: .b_ptr = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val // CHECK:STDOUT: .ptr = %ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %val.var: ref %C = var val // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var @@ -302,11 +337,20 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+25, unloaded -// CHECK:STDOUT: %import_ref.4: type = import_ref ir2, inst+3, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.5 = import_ref ir2, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//b, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//b, inst+15, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//b, inst+25, unloaded +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//a, inst+3, loaded [template = constants.%C] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Main//a, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -315,13 +359,12 @@ var ptr: E* = &val; // CHECK:STDOUT: .b_val = imports.%import_ref.2 // CHECK:STDOUT: .b_ptr = imports.%import_ref.3 // CHECK:STDOUT: .C = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val // CHECK:STDOUT: .ptr = %ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.4 [template = constants.%C] // CHECK:STDOUT: %val.var: ref %C = var val // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var @@ -360,13 +403,22 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+25, unloaded -// CHECK:STDOUT: %import_ref.4: type = import_ref ir2, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.5 = import_ref ir2, inst+15, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+25, unloaded -// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+8, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//b, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//b, inst+15, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//b, inst+25, unloaded +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//c, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//c, inst+15, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//c, inst+25, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7 = import_ref Main//b, inst+8, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -377,13 +429,12 @@ var ptr: E* = &val; // CHECK:STDOUT: .E = imports.%import_ref.4 // CHECK:STDOUT: .c_val = imports.%import_ref.5 // CHECK:STDOUT: .c_ptr = imports.%import_ref.6 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val // CHECK:STDOUT: .ptr = %ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %val.var: ref %C = var val // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var @@ -422,13 +473,22 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+25, unloaded -// CHECK:STDOUT: %import_ref.4: type = import_ref ir2, inst+10, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.5 = import_ref ir2, inst+15, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+25, unloaded -// CHECK:STDOUT: %import_ref.7 = import_ref ir2, inst+8, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//c, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//c, inst+15, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//c, inst+25, unloaded +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//b, inst+10, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//b, inst+15, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//b, inst+25, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7 = import_ref Main//b, inst+8, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -439,13 +499,12 @@ var ptr: E* = &val; // CHECK:STDOUT: .D = imports.%import_ref.4 // CHECK:STDOUT: .b_val = imports.%import_ref.5 // CHECK:STDOUT: .b_ptr = imports.%import_ref.6 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val // CHECK:STDOUT: .ptr = %ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.4 [template = constants.%C] // CHECK:STDOUT: %val.var: ref %C = var val // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var diff --git a/toolchain/check/testdata/class/import_member_cycle.carbon b/toolchain/check/testdata/class/import_member_cycle.carbon index d1f213e8b0223..29343c76de344 100644 --- a/toolchain/check/testdata/class/import_member_cycle.carbon +++ b/toolchain/check/testdata/class/import_member_cycle.carbon @@ -35,13 +35,24 @@ fn Run() { // CHECK:STDOUT: %.3: type = struct_type {.a: %.1} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Cycle = %Cycle.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Cycle.decl: type = class_decl @Cycle [template = constants.%Cycle] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -67,20 +78,28 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%Cycle] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+9, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%Cycle] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+4, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+9, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Cycle = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/import_struct_cyle.carbon b/toolchain/check/testdata/class/import_struct_cyle.carbon index 645869dd10da8..84544e95aa214 100644 --- a/toolchain/check/testdata/class/import_struct_cyle.carbon +++ b/toolchain/check/testdata/class/import_struct_cyle.carbon @@ -41,14 +41,25 @@ fn Run() { // CHECK:STDOUT: %.4: type = struct_type {.c: %.2} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Cycle = %Cycle.decl.loc4 // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Cycle.decl.loc4: type = class_decl @Cycle [template = constants.%Cycle] {} // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, %Cycle.decl.loc4 [template = constants.%Cycle] // CHECK:STDOUT: %.loc6_18: type = ptr_type %Cycle [template = constants.%.1] @@ -84,22 +95,30 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2: ref %.3 = import_ref ir1, inst+13, loaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.4: %.6 = import_ref ir1, inst+20, loaded [template = %.1] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//a, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2: ref %.3 = import_ref Main//a, inst+13, loaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+4, unloaded +// CHECK:STDOUT: %import_ref.4: %.6 = import_ref Main//a, inst+20, loaded [template = %.1] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Cycle = imports.%import_ref.1 // CHECK:STDOUT: .a = imports.%import_ref.2 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/init.carbon b/toolchain/check/testdata/class/init.carbon index 14c1c249416cb..52c63ddf9dfdb 100644 --- a/toolchain/check/testdata/class/init.carbon +++ b/toolchain/check/testdata/class/init.carbon @@ -41,20 +41,27 @@ fn MakeReorder(n: i32, next: Class*) -> Class { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Make = %Make.decl // CHECK:STDOUT: .MakeReorder = %MakeReorder.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] { // CHECK:STDOUT: %int.make_type_32.loc16: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/init_adapt.carbon b/toolchain/check/testdata/class/init_adapt.carbon index 4f7941863461b..5d77f8fff4fcc 100644 --- a/toolchain/check/testdata/class/init_adapt.carbon +++ b/toolchain/check/testdata/class/init_adapt.carbon @@ -100,13 +100,22 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .AdaptC = %AdaptC.decl // CHECK:STDOUT: .a = @__global_init.%a @@ -118,7 +127,6 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: .e = %e // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %AdaptC.decl: type = class_decl @AdaptC [template = constants.%AdaptC] {} // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C] @@ -233,13 +241,22 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .AdaptC = %AdaptC.decl // CHECK:STDOUT: .a = @__global_init.%a @@ -251,7 +268,6 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: .e = %e // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %AdaptC.decl: type = class_decl @AdaptC [template = constants.%AdaptC] {} // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C] diff --git a/toolchain/check/testdata/class/init_as.carbon b/toolchain/check/testdata/class/init_as.carbon index a2573e3b1aa0a..abcdab17a8326 100644 --- a/toolchain/check/testdata/class/init_as.carbon +++ b/toolchain/check/testdata/class/init_as.carbon @@ -35,19 +35,26 @@ fn F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/init_nested.carbon b/toolchain/check/testdata/class/init_nested.carbon index e10ac9e0ea89e..809d45b284183 100644 --- a/toolchain/check/testdata/class/init_nested.carbon +++ b/toolchain/check/testdata/class/init_nested.carbon @@ -47,20 +47,28 @@ fn MakeOuter() -> Outer { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Inner = %Inner.decl // CHECK:STDOUT: .MakeInner = %MakeInner.decl // CHECK:STDOUT: .Outer = %Outer.decl // CHECK:STDOUT: .MakeOuter = %MakeOuter.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Inner.decl: type = class_decl @Inner [template = constants.%Inner] {} // CHECK:STDOUT: %MakeInner.decl: %MakeInner.type = fn_decl @MakeInner [template = constants.%MakeInner] { // CHECK:STDOUT: %Inner.ref: type = name_ref Inner, %Inner.decl [template = constants.%Inner] diff --git a/toolchain/check/testdata/class/method.carbon b/toolchain/check/testdata/class/method.carbon index 62b165346b0f4..ba4da2f1ad49c 100644 --- a/toolchain/check/testdata/class/method.carbon +++ b/toolchain/check/testdata/class/method.carbon @@ -96,23 +96,22 @@ fn CallGOnInitializingExpr() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Call = %Call.decl // CHECK:STDOUT: .CallAlias = %CallAlias.decl @@ -125,7 +124,6 @@ fn CallGOnInitializingExpr() -> i32 { // CHECK:STDOUT: .CallGOnInitializingExpr = %CallGOnInitializingExpr.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class] diff --git a/toolchain/check/testdata/class/nested.carbon b/toolchain/check/testdata/class/nested.carbon index f3942900e8502..f665e17c55d1d 100644 --- a/toolchain/check/testdata/class/nested.carbon +++ b/toolchain/check/testdata/class/nested.carbon @@ -75,14 +75,25 @@ fn F(a: Outer*) { // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Outer = %Outer.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Outer.decl: type = class_decl @Outer [template = constants.%Outer] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %Outer.ref: type = name_ref Outer, %Outer.decl [template = constants.%Outer] diff --git a/toolchain/check/testdata/class/nested_name.carbon b/toolchain/check/testdata/class/nested_name.carbon index e7f1ce1862f4c..84f291a0bf0ca 100644 --- a/toolchain/check/testdata/class/nested_name.carbon +++ b/toolchain/check/testdata/class/nested_name.carbon @@ -42,19 +42,27 @@ fn G(o: Outer) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Outer = %Outer.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Outer.decl: type = class_decl @Outer [template = constants.%Outer] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Outer.ref.loc17: type = name_ref Outer, %Outer.decl [template = constants.%Outer] diff --git a/toolchain/check/testdata/class/no_prelude/export_name.carbon b/toolchain/check/testdata/class/no_prelude/export_name.carbon index 69ade4fe2a2df..0855eb093dc27 100644 --- a/toolchain/check/testdata/class/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/class/no_prelude/export_name.carbon @@ -65,8 +65,8 @@ var c: C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -93,8 +93,8 @@ var c: C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+7, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+6, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+7, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export, inst+6, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/class/no_prelude/implicit_import.carbon b/toolchain/check/testdata/class/no_prelude/implicit_import.carbon index 7783d5ce1889e..2bffb4e50cf4b 100644 --- a/toolchain/check/testdata/class/no_prelude/implicit_import.carbon +++ b/toolchain/check/testdata/class/no_prelude/implicit_import.carbon @@ -109,7 +109,7 @@ class B {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref: type = import_ref Main//basic, inst+1, loaded [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -153,8 +153,8 @@ class B {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//redecl_after_def, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//redecl_after_def, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -199,8 +199,8 @@ class B {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//redef_after_def, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//redef_after_def, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -249,8 +249,8 @@ class B {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir0, inst+4, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//def_alias, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//def_alias, inst+4, loaded [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/class/no_prelude/import_access.carbon b/toolchain/check/testdata/class/no_prelude/import_access.carbon index 50efe378cb498..2ba82b59ed518 100644 --- a/toolchain/check/testdata/class/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/class/no_prelude/import_access.carbon @@ -200,8 +200,8 @@ private class Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%Def] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Test//def, inst+1, loaded [template = constants.%Def] +// CHECK:STDOUT: %import_ref.2 = import_ref Test//def, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -259,14 +259,19 @@ private class Redecl {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} -// CHECK:STDOUT: %Test.ref: = name_ref Test, %Test [template = %Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %Def.ref: = name_ref Def, [template = ] // CHECK:STDOUT: %c.var: ref = var c // CHECK:STDOUT: %c: ref = bind_name c, %c.var @@ -290,8 +295,8 @@ private class Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%ForwardWithDef] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Test//forward_with_def, inst+1, loaded [template = constants.%ForwardWithDef] +// CHECK:STDOUT: %import_ref.2 = import_ref Test//forward_with_def, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -349,14 +354,19 @@ private class Redecl {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//forward_with_def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} -// CHECK:STDOUT: %Test.ref: = name_ref Test, %Test [template = %Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %ForwardWithDef.ref: = name_ref ForwardWithDef, [template = ] // CHECK:STDOUT: %c.var: ref = var c // CHECK:STDOUT: %c: ref = bind_name c, %c.var @@ -381,7 +391,7 @@ private class Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+1, loaded [template = constants.%Forward] +// CHECK:STDOUT: %import_ref: type = import_ref Test//forward, inst+1, loaded [template = constants.%Forward] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -444,15 +454,20 @@ private class Redecl {} // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//forward +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Test.ref: = name_ref Test, %Test [template = %Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %Forward.ref: = name_ref Forward, [template = ] // CHECK:STDOUT: %.loc9: type = ptr_type [template = ] // CHECK:STDOUT: %c.loc9_6.1: = param c diff --git a/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon b/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon index 6abf783c0d294..d906dc5732d98 100644 --- a/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon +++ b/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon @@ -133,7 +133,7 @@ var x: () = D.C.F(); // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//a, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -151,9 +151,9 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -173,7 +173,7 @@ var x: () = D.C.F(); // CHECK:STDOUT: --- d.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+8, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//c, inst+8, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -192,9 +192,9 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+8, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+6, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//c, inst+8, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//c, inst+6, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//c, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -224,7 +224,7 @@ var x: () = D.C.F(); // CHECK:STDOUT: --- f.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//e, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -246,9 +246,9 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir2, inst+3, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3: %F.type = import_ref Main//a, inst+3, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -292,9 +292,9 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+8, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+6, unloaded -// CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir1, inst+7, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//c, inst+8, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//c, inst+6, unloaded +// CHECK:STDOUT: %import_ref.3: %F.type = import_ref Main//c, inst+7, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -338,9 +338,9 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+8, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+6, unloaded -// CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir2, inst+7, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//c, inst+8, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//c, inst+6, unloaded +// CHECK:STDOUT: %import_ref.3: %F.type = import_ref Main//c, inst+7, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -385,11 +385,11 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+3, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+8, unloaded -// CHECK:STDOUT: %import_ref.5: %F.type = import_ref ir1, inst+9, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//e, inst+3, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//e, inst+4, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//e, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//e, inst+8, unloaded +// CHECK:STDOUT: %import_ref.5: %F.type = import_ref Main//e, inst+9, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -441,11 +441,11 @@ var x: () = D.C.F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+3, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+4, unloaded -// CHECK:STDOUT: %import_ref.3: type = import_ref ir2, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4 = import_ref ir2, inst+8, unloaded -// CHECK:STDOUT: %import_ref.5: %F.type = import_ref ir2, inst+9, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//e, inst+3, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//e, inst+4, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//e, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//e, inst+8, unloaded +// CHECK:STDOUT: %import_ref.5: %F.type = import_ref Main//e, inst+9, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/class/no_prelude/no_definition_in_impl_file.carbon b/toolchain/check/testdata/class/no_prelude/no_definition_in_impl_file.carbon index 922c97f965ca1..682585aaed88d 100644 --- a/toolchain/check/testdata/class/no_prelude/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/class/no_prelude/no_definition_in_impl_file.carbon @@ -94,7 +94,7 @@ class D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: type = import_ref Main//decl_in_api_definition_in_impl, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -121,7 +121,7 @@ class D; // CHECK:STDOUT: --- use_decl_in_api.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//decl_in_api_definition_in_impl, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -150,7 +150,7 @@ class D; // CHECK:STDOUT: --- decl_only_in_api.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir0, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//decl_only_in_api, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -183,7 +183,7 @@ class D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref: type = import_ref Main//decl_in_api_decl_in_impl, inst+1, loaded [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon b/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon new file mode 100644 index 0000000000000..5c1c4135c9c37 --- /dev/null +++ b/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon @@ -0,0 +1,794 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon + +// --- basic.carbon + +library "basic"; + +class C {} +alias D = C; + +class Foo(a: C); +class Foo(a: C) {} + +class Bar(a: D); +class Bar(a: D) {} + +// --- spacing.carbon + +library "spacing"; + +class C {} + +class Foo [ ] ( a : C ); +class Foo[](a: C) {} + +// --- fail_parens.carbon + +library "parens"; + +class C {} + +class Foo(a: C); +// CHECK:STDERR: fail_parens.carbon:[[@LINE+7]]:14: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: class Foo(a: (C)) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_parens.carbon:[[@LINE-4]]:14: Comparing with previous declaration here. +// CHECK:STDERR: class Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +class Foo(a: (C)) {} + +// --- todo_fail_raw_identifier.carbon + +library "raw_identifier"; + +class C {} + +class Foo(a: C); +class Foo(a: r#C) {} + +// --- two_file.carbon + +library "two_file"; + +class C {} +alias D = C; + +class Foo(a: C); +class Bar(a: D); + +// --- two_file.impl.carbon + +impl library "two_file"; + +class Foo(a: C) {} +class Bar(a: D) {} + +// --- fail_name_mismatch.carbon + +library "name_mismatch"; + +class C {} +alias D = C; + +class Foo(a: C); +// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE+7]]:11: ERROR: Redeclaration differs at parameter 1. +// CHECK:STDERR: class Foo(b: D) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE-4]]:11: Previous declaration's corresponding parameter here. +// CHECK:STDERR: class Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +class Foo(b: D) {} + +// --- fail_alias.carbon + +library "alias"; + +class C {} +alias D = C; + +class Foo(a: C); +// CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:14: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: class Foo(a: D) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_alias.carbon:[[@LINE-4]]:14: Comparing with previous declaration here. +// CHECK:STDERR: class Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +class Foo(a: D) {} + +// --- fail_deduced_alias.carbon + +library "deduced_alias"; + +class C {} +alias D = C; + +class Foo[a: C](); +// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE+7]]:14: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: class Foo[a: D]() {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE-4]]:14: Comparing with previous declaration here. +// CHECK:STDERR: class Foo[a: C](); +// CHECK:STDERR: ^ +// CHECK:STDERR: +class Foo[a: D]() {} + +// --- alias_two_file.carbon + +library "alias_two_file"; + +class C {} + +class Foo(a: C); + +// --- todo_fail_alias_two_file.impl.carbon + +impl library "alias_two_file"; + +alias D = C; + +class Foo(a: D) {} + +// --- fail_repeat_const.carbon + +library "repeat_const"; + +class C {} + +class Foo(a: const C); +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+11]]:14: WARNING: `const` applied repeatedly to the same type has no additional effect. +// CHECK:STDERR: class Foo(a: const (const C)) {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+7]]:20: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: class Foo(a: const (const C)) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE-8]]:20: Comparing with previous declaration here. +// CHECK:STDERR: class Foo(a: const C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +class Foo(a: const (const C)) {} + +// --- fail_self_type.carbon + +library "self_type"; + +base class Base { + var a: (); + + fn F[addr self: Self*](); +} + +// CHECK:STDERR: fail_self_type.carbon:[[@LINE+6]]:22: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: fn Base.F[addr self: Base*]() { +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: fail_self_type.carbon:[[@LINE-6]]:19: Comparing with previous declaration here. +// CHECK:STDERR: fn F[addr self: Self*](); +// CHECK:STDERR: ^~~~ +fn Base.F[addr self: Base*]() { + (*self).a = (); +} + +// CHECK:STDOUT: --- basic.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %Bar.type: type = generic_class_type @Bar [template] +// CHECK:STDOUT: %Bar.1: %Bar.type = struct_value () [template] +// CHECK:STDOUT: %Bar.2: type = class_type @Bar [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl.loc7 +// CHECK:STDOUT: .Bar = %Bar.decl.loc10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_11.1: %C = param a +// CHECK:STDOUT: %a.loc7_11.2: %C = bind_name a, %a.loc7_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc8: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc8_11.1: %C = param a +// CHECK:STDOUT: %a.loc8_11.2: %C = bind_name a, %a.loc8_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl.loc10: %Bar.type = class_decl @Bar [template = constants.%Bar.1] { +// CHECK:STDOUT: %D.ref.loc10: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc10_11.1: %C = param a +// CHECK:STDOUT: %a.loc10_11.2: %C = bind_name a, %a.loc10_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl.loc11: %Bar.type = class_decl @Bar [template = constants.%Bar.1] { +// CHECK:STDOUT: %D.ref.loc11: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc11_11.1: %C = param a +// CHECK:STDOUT: %a.loc11_11.2: %C = bind_name a, %a.loc11_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Foo.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Bar { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Bar.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- spacing.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl.loc6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_17.1: %C = param a +// CHECK:STDOUT: %a.loc6_17.2: %C = bind_name a, %a.loc6_17.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_13.1: %C = param a +// CHECK:STDOUT: %a.loc7_13.2: %C = bind_name a, %a.loc7_13.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Foo.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_parens.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = class_type @.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_11.1: %C = param a +// CHECK:STDOUT: %a.loc6_11.2: %C = bind_name a, %a.loc6_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %C.ref.loc14: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc14_11.1: %C = param a +// CHECK:STDOUT: %a.loc14_11.2: %C = bind_name a, %a.loc14_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @.1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- todo_fail_raw_identifier.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl.loc6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_11.1: %C = param a +// CHECK:STDOUT: %a.loc6_11.2: %C = bind_name a, %a.loc6_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_11.1: %C = param a +// CHECK:STDOUT: %a.loc7_11.2: %C = bind_name a, %a.loc7_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Foo.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- two_file.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %Bar.type: type = generic_class_type @Bar [template] +// CHECK:STDOUT: %Bar.1: %Bar.type = struct_value () [template] +// CHECK:STDOUT: %Bar.2: type = class_type @Bar [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .Bar = %Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_11.1: %C = param a +// CHECK:STDOUT: %a.loc7_11.2: %C = bind_name a, %a.loc7_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl: %Bar.type = class_decl @Bar [template = constants.%Bar.1] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc8_11.1: %C = param a +// CHECK:STDOUT: %a.loc8_11.2: %C = bind_name a, %a.loc8_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @Bar; +// CHECK:STDOUT: +// CHECK:STDOUT: --- two_file.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %Bar.type: type = generic_class_type @Bar [template] +// CHECK:STDOUT: %Bar.1: %Bar.type = struct_value () [template] +// CHECK:STDOUT: %Bar.2: type = class_type @Bar [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//two_file, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//two_file, inst+5, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3: %Foo.type = import_ref Main//two_file, inst+9, loaded [template = constants.%Foo.1] +// CHECK:STDOUT: %import_ref.4: %Bar.type = import_ref Main//two_file, inst+17, loaded [template = constants.%Bar.1] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//two_file, inst+2, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = imports.%import_ref.1 +// CHECK:STDOUT: .D = imports.%import_ref.2 +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .Bar = %Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc2_6.1 = import +// CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %a.loc4_11.1: %C = param a +// CHECK:STDOUT: %a.loc4_11.2: %C = bind_name a, %a.loc4_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl: %Bar.type = class_decl @Bar [template = constants.%Bar.1] { +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.2 [template = constants.%C] +// CHECK:STDOUT: %a.loc5_11.1: %C = param a +// CHECK:STDOUT: %a.loc5_11.2: %C = bind_name a, %a.loc5_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Foo.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Bar { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Bar.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_name_mismatch.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = class_type @.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_11.1: %C = param a +// CHECK:STDOUT: %a.loc7_11.2: %C = bind_name a, %a.loc7_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %b.loc15_11.1: %C = param b +// CHECK:STDOUT: %b.loc15_11.2: %C = bind_name b, %b.loc15_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @.1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_alias.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = class_type @.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_11.1: %C = param a +// CHECK:STDOUT: %a.loc7_11.2: %C = bind_name a, %a.loc7_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc15_11.1: %C = param a +// CHECK:STDOUT: %a.loc15_11.2: %C = bind_name a, %a.loc15_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @.1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_deduced_alias.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = class_type @.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_11.1: %C = param a +// CHECK:STDOUT: %a.loc7_11.2: %C = bind_name a, %a.loc7_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc15_11.1: %C = param a +// CHECK:STDOUT: %a.loc15_11.2: %C = bind_name a, %a.loc15_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @.1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- alias_two_file.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_11.1: %C = param a +// CHECK:STDOUT: %a.loc6_11.2: %C = bind_name a, %a.loc6_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: --- todo_fail_alias_two_file.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//alias_two_file, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: %Foo.type = import_ref Main//alias_two_file, inst+7, loaded [template = constants.%Foo.1] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//alias_two_file, inst+2, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = imports.%import_ref.1 +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc2_6.1 = import +// CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc6_11.1: %C = param a +// CHECK:STDOUT: %a.loc6_11.2: %C = bind_name a, %a.loc6_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Foo.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_repeat_const.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = const_type %C [template] +// CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [template] +// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %Foo.1: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Foo.2: type = class_type @Foo [template] +// CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] +// CHECK:STDOUT: %.4: %.type = struct_value () [template] +// CHECK:STDOUT: %.5: type = class_type @.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [template = constants.%Foo.1] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc6: type = const_type %C [template = constants.%.2] +// CHECK:STDOUT: %a.loc6_11.1: %.2 = param a +// CHECK:STDOUT: %a.loc6_11.2: %.2 = bind_name a, %a.loc6_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.4] { +// CHECK:STDOUT: %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc18_21: type = const_type %C [template = constants.%.2] +// CHECK:STDOUT: %.loc18_14: type = const_type %.2 [template = constants.%.2] +// CHECK:STDOUT: %a.loc18_11.1: %.2 = param a +// CHECK:STDOUT: %a.loc18_11.2: %.2 = bind_name a, %a.loc18_11.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @.1 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_self_type.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %Base: type = class_type @Base [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = unbound_element_type %Base, %.1 [template] +// CHECK:STDOUT: %.3: type = ptr_type %Base [template] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = struct_type {.a: %.1} [template] +// CHECK:STDOUT: %.type: type = fn_type @.1 [template] +// CHECK:STDOUT: %.5: %.type = struct_value () [template] +// CHECK:STDOUT: %.6: type = ptr_type %.4 [template] +// CHECK:STDOUT: %tuple: %.1 = tuple_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Base = %Base.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.5] { +// CHECK:STDOUT: %Base.ref: type = name_ref Base, %Base.decl [template = constants.%Base] +// CHECK:STDOUT: %.loc16_26: type = ptr_type %Base [template = constants.%.3] +// CHECK:STDOUT: %self.loc16_16.1: %.3 = param self +// CHECK:STDOUT: @.1.%self: %.3 = bind_name self, %self.loc16_16.1 +// CHECK:STDOUT: @.1.%.loc16: %.3 = addr_pattern @.1.%self +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @Base { +// CHECK:STDOUT: %.loc5_11.1: %.1 = tuple_literal () +// CHECK:STDOUT: %.loc5_11.2: type = converted %.loc5_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc5_8: %.2 = field_decl a, element0 [template] +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [template = constants.%Base] +// CHECK:STDOUT: %.loc7_23: type = ptr_type %Base [template = constants.%.3] +// CHECK:STDOUT: %self.loc7_13.1: %.3 = param self +// CHECK:STDOUT: %self.loc7_13.3: %.3 = bind_name self, %self.loc7_13.1 +// CHECK:STDOUT: %.loc7_8: %.3 = addr_pattern %self.loc7_13.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Base +// CHECK:STDOUT: .a = %.loc5_8 +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F[addr @Base.%self.loc7_13.3: %.3](); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @.1[addr %self: %.3]() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: %.3 = name_ref self, %self +// CHECK:STDOUT: %.loc17_4: ref %Base = deref %self.ref +// CHECK:STDOUT: %a.ref: %.2 = name_ref a, @Base.%.loc5_8 [template = @Base.%.loc5_8] +// CHECK:STDOUT: %.loc17_10: ref %.1 = class_element_access %.loc17_4, element0 +// CHECK:STDOUT: %.loc17_16.1: %.1 = tuple_literal () +// CHECK:STDOUT: %.loc17_16.2: init %.1 = tuple_init () to %.loc17_10 [template = constants.%tuple] +// CHECK:STDOUT: %.loc17_13: init %.1 = converted %.loc17_16.1, %.loc17_16.2 [template = constants.%tuple] +// CHECK:STDOUT: assign %.loc17_10, %.loc17_13 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/raw_self.carbon b/toolchain/check/testdata/class/raw_self.carbon index 42b98eb5c1da6..c7345da39786c 100644 --- a/toolchain/check/testdata/class/raw_self.carbon +++ b/toolchain/check/testdata/class/raw_self.carbon @@ -43,24 +43,25 @@ fn Class.G[self: Self](r#self: i32) -> (i32, i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class [template = constants.%Class] diff --git a/toolchain/check/testdata/class/raw_self_type.carbon b/toolchain/check/testdata/class/raw_self_type.carbon index 01a73a69b2ef0..db1235ea641f7 100644 --- a/toolchain/check/testdata/class/raw_self_type.carbon +++ b/toolchain/check/testdata/class/raw_self_type.carbon @@ -39,14 +39,25 @@ fn MemberNamedSelf.F(x: Self, y: r#Self) {} // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .MemberNamedSelf = %MemberNamedSelf.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %MemberNamedSelf.decl: type = class_decl @MemberNamedSelf [template = constants.%MemberNamedSelf] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { diff --git a/toolchain/check/testdata/class/redeclaration.carbon b/toolchain/check/testdata/class/redeclaration.carbon index 8137dd160c83c..06620b0755dab 100644 --- a/toolchain/check/testdata/class/redeclaration.carbon +++ b/toolchain/check/testdata/class/redeclaration.carbon @@ -30,17 +30,25 @@ fn Class.F[self: Self](b: bool) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl.loc11 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl.loc11: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Class.decl.loc13: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { diff --git a/toolchain/check/testdata/class/redeclaration_introducer.carbon b/toolchain/check/testdata/class/redeclaration_introducer.carbon index 8aa0e92c6600e..2ac75d6dd60ee 100644 --- a/toolchain/check/testdata/class/redeclaration_introducer.carbon +++ b/toolchain/check/testdata/class/redeclaration_introducer.carbon @@ -25,15 +25,26 @@ abstract class C {} // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl.loc11 // CHECK:STDOUT: .B = %B.decl.loc12 // CHECK:STDOUT: .C = %C.decl.loc13 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl.loc11: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl.loc12: type = class_decl @B [template = constants.%B] {} // CHECK:STDOUT: %C.decl.loc13: type = class_decl @C [template = constants.%C] {} diff --git a/toolchain/check/testdata/class/reenter_scope.carbon b/toolchain/check/testdata/class/reenter_scope.carbon index 105352fced7c9..561196dbc37df 100644 --- a/toolchain/check/testdata/class/reenter_scope.carbon +++ b/toolchain/check/testdata/class/reenter_scope.carbon @@ -34,18 +34,25 @@ fn Class.F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/reorder.carbon b/toolchain/check/testdata/class/reorder.carbon index cb64c5ccb63e6..9891bc9256ec4 100644 --- a/toolchain/check/testdata/class/reorder.carbon +++ b/toolchain/check/testdata/class/reorder.carbon @@ -35,17 +35,25 @@ class Class { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/reorder_qualified.carbon b/toolchain/check/testdata/class/reorder_qualified.carbon index 4216daa94f666..54c6b5c57d801 100644 --- a/toolchain/check/testdata/class/reorder_qualified.carbon +++ b/toolchain/check/testdata/class/reorder_qualified.carbon @@ -89,19 +89,25 @@ class A { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/scope.carbon b/toolchain/check/testdata/class/scope.carbon index 5b6cd2cbbce23..631471cd51488 100644 --- a/toolchain/check/testdata/class/scope.carbon +++ b/toolchain/check/testdata/class/scope.carbon @@ -49,22 +49,27 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/self.carbon b/toolchain/check/testdata/class/self.carbon index 08a7ee811d2fc..d00401bf45dda 100644 --- a/toolchain/check/testdata/class/self.carbon +++ b/toolchain/check/testdata/class/self.carbon @@ -41,20 +41,25 @@ fn Class.G[addr self: Self*]() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Self.ref.loc18: type = name_ref Self, constants.%Class [template = constants.%Class] diff --git a/toolchain/check/testdata/class/self_conversion.carbon b/toolchain/check/testdata/class/self_conversion.carbon index 92d3938ddc478..713e84c9527b2 100644 --- a/toolchain/check/testdata/class/self_conversion.carbon +++ b/toolchain/check/testdata/class/self_conversion.carbon @@ -59,21 +59,27 @@ fn Call(p: Derived*) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Base = %Base.decl // CHECK:STDOUT: .Derived = %Derived.decl // CHECK:STDOUT: .Call = %Call.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} // CHECK:STDOUT: %SelfBase.decl: %SelfBase.type = fn_decl @SelfBase [template = constants.%SelfBase] { diff --git a/toolchain/check/testdata/class/self_type.carbon b/toolchain/check/testdata/class/self_type.carbon index 59568d01b5cae..2af77d8139b48 100644 --- a/toolchain/check/testdata/class/self_type.carbon +++ b/toolchain/check/testdata/class/self_type.carbon @@ -40,17 +40,25 @@ fn Class.F[self: Self]() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class] diff --git a/toolchain/check/testdata/class/static_method.carbon b/toolchain/check/testdata/class/static_method.carbon index a650040063f05..867982a0b6cda 100644 --- a/toolchain/check/testdata/class/static_method.carbon +++ b/toolchain/check/testdata/class/static_method.carbon @@ -33,18 +33,26 @@ fn Run() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/class/syntactic_merge_literal.carbon b/toolchain/check/testdata/class/syntactic_merge_literal.carbon new file mode 100644 index 0000000000000..55d4b8cf2b32f --- /dev/null +++ b/toolchain/check/testdata/class/syntactic_merge_literal.carbon @@ -0,0 +1,249 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/syntactic_merge_literal.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/syntactic_merge_literal.carbon +// CHECK:STDERR: fail_int_mismatch.carbon: ERROR: Main//default previously provided by `int_match.carbon`. +// CHECK:STDERR: + +// --- int_match.carbon + +class C(a:! i32) {} +class D(b:! C(1_000)); +class D(b:! C(1_000)) {} + +// --- fail_int_mismatch.carbon + +class C(a:! i32) {} +class D(b:! C(1000)); +// CHECK:STDERR: fail_int_mismatch.carbon:[[@LINE+6]]:15: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: class D(b:! C(1_000)) {} +// CHECK:STDERR: ^~~~~ +// CHECK:STDERR: fail_int_mismatch.carbon:[[@LINE-4]]:15: Comparing with previous declaration here. +// CHECK:STDERR: class D(b:! C(1000)); +// CHECK:STDERR: ^~~~ +class D(b:! C(1_000)) {} + +// CHECK:STDOUT: --- int_match.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %a: i32 = bind_symbolic_name a 0 [symbolic] +// CHECK:STDOUT: %C.type: type = generic_class_type @C [template] +// CHECK:STDOUT: %C.1: %C.type = struct_value () [template] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%a) [symbolic] +// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %.3: i32 = int_literal 1000 [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%.3) [template] +// CHECK:STDOUT: %b: %C.3 = bind_symbolic_name b 0 [symbolic] +// CHECK:STDOUT: %D.type: type = generic_class_type @D [template] +// CHECK:STDOUT: %D.1: %D.type = struct_value () [template] +// CHECK:STDOUT: %D.2: type = class_type @D, @D(%b) [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D.decl.loc3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] { +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc2_13.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc2_13.2: type = converted %int.make_type_32, %.loc2_13.1 [template = i32] +// CHECK:STDOUT: %a.loc2_9.1: i32 = param a +// CHECK:STDOUT: %a.loc2_9.2: i32 = bind_symbolic_name a 0, %a.loc2_9.1 [symbolic = @C.%a (constants.%a)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %D.decl.loc3: %D.type = class_decl @D [template = constants.%D.1] { +// CHECK:STDOUT: %C.ref.loc3: %C.type = name_ref C, %C.decl [template = constants.%C.1] +// CHECK:STDOUT: %.loc3_15: i32 = int_literal 1000 [template = constants.%.3] +// CHECK:STDOUT: %.loc3_14: init type = call %C.ref.loc3(%.loc3_15) [template = constants.%C.3] +// CHECK:STDOUT: %.loc3_20.1: type = value_of_initializer %.loc3_14 [template = constants.%C.3] +// CHECK:STDOUT: %.loc3_20.2: type = converted %.loc3_14, %.loc3_20.1 [template = constants.%C.3] +// CHECK:STDOUT: %b.loc3_9.1: %C.3 = param b +// CHECK:STDOUT: %b.loc3_9.2: %C.3 = bind_symbolic_name b 0, %b.loc3_9.1 [symbolic = @D.%b (constants.%b)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %D.decl.loc4: %D.type = class_decl @D [template = constants.%D.1] { +// CHECK:STDOUT: %C.ref.loc4: %C.type = name_ref C, %C.decl [template = constants.%C.1] +// CHECK:STDOUT: %.loc4_15: i32 = int_literal 1000 [template = constants.%.3] +// CHECK:STDOUT: %.loc4_14: init type = call %C.ref.loc4(%.loc4_15) [template = constants.%C.3] +// CHECK:STDOUT: %.loc4_20.1: type = value_of_initializer %.loc4_14 [template = constants.%C.3] +// CHECK:STDOUT: %.loc4_20.2: type = converted %.loc4_14, %.loc4_20.1 [template = constants.%C.3] +// CHECK:STDOUT: %b.loc4_9.1: %C.3 = param b +// CHECK:STDOUT: %b.loc4_9.2: %C.3 = bind_symbolic_name b 0, %b.loc4_9.1 [symbolic = constants.%b] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(file.%a.loc2_9.2: i32) { +// CHECK:STDOUT: %a: i32 = bind_symbolic_name a 0 [symbolic = %a (constants.%a)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @D(file.%b.loc3_9.2: %C.3) { +// CHECK:STDOUT: %b: %C.3 = bind_symbolic_name b 0 [symbolic = %b (constants.%b)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%D.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%a) { +// CHECK:STDOUT: %a => constants.%a +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%.3) { +// CHECK:STDOUT: %a => constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @D(constants.%b) { +// CHECK:STDOUT: %b => constants.%b +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_int_mismatch.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %a: i32 = bind_symbolic_name a 0 [symbolic] +// CHECK:STDOUT: %C.type: type = generic_class_type @C [template] +// CHECK:STDOUT: %C.1: %C.type = struct_value () [template] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%a) [symbolic] +// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %.3: i32 = int_literal 1000 [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%.3) [template] +// CHECK:STDOUT: %b: %C.3 = bind_symbolic_name b 0 [symbolic] +// CHECK:STDOUT: %D.type: type = generic_class_type @D [template] +// CHECK:STDOUT: %D.1: %D.type = struct_value () [template] +// CHECK:STDOUT: %D.2: type = class_type @D, @D(%b) [symbolic] +// CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] +// CHECK:STDOUT: %.4: %.type = struct_value () [template] +// CHECK:STDOUT: %.5: type = class_type @.1, @.1(%b) [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] { +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc2_13.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc2_13.2: type = converted %int.make_type_32, %.loc2_13.1 [template = i32] +// CHECK:STDOUT: %a.loc2_9.1: i32 = param a +// CHECK:STDOUT: %a.loc2_9.2: i32 = bind_symbolic_name a 0, %a.loc2_9.1 [symbolic = @C.%a (constants.%a)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %D.decl: %D.type = class_decl @D [template = constants.%D.1] { +// CHECK:STDOUT: %C.ref.loc3: %C.type = name_ref C, %C.decl [template = constants.%C.1] +// CHECK:STDOUT: %.loc3_15: i32 = int_literal 1000 [template = constants.%.3] +// CHECK:STDOUT: %.loc3_14: init type = call %C.ref.loc3(%.loc3_15) [template = constants.%C.3] +// CHECK:STDOUT: %.loc3_19.1: type = value_of_initializer %.loc3_14 [template = constants.%C.3] +// CHECK:STDOUT: %.loc3_19.2: type = converted %.loc3_14, %.loc3_19.1 [template = constants.%C.3] +// CHECK:STDOUT: %b.loc3_9.1: %C.3 = param b +// CHECK:STDOUT: %b.loc3_9.2: %C.3 = bind_symbolic_name b 0, %b.loc3_9.1 [symbolic = @D.%b (constants.%b)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.4] { +// CHECK:STDOUT: %C.ref.loc10: %C.type = name_ref C, %C.decl [template = constants.%C.1] +// CHECK:STDOUT: %.loc10_15: i32 = int_literal 1000 [template = constants.%.3] +// CHECK:STDOUT: %.loc10_14: init type = call %C.ref.loc10(%.loc10_15) [template = constants.%C.3] +// CHECK:STDOUT: %.loc10_20.1: type = value_of_initializer %.loc10_14 [template = constants.%C.3] +// CHECK:STDOUT: %.loc10_20.2: type = converted %.loc10_14, %.loc10_20.1 [template = constants.%C.3] +// CHECK:STDOUT: %b.loc10_9.1: %C.3 = param b +// CHECK:STDOUT: %b.loc10_9.2: %C.3 = bind_symbolic_name b 0, %b.loc10_9.1 [symbolic = @.1.%b (constants.%b)] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(file.%a.loc2_9.2: i32) { +// CHECK:STDOUT: %a: i32 = bind_symbolic_name a 0 [symbolic = %a (constants.%a)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @D(file.%b.loc3_9.2: %C.3) { +// CHECK:STDOUT: %b: %C.3 = bind_symbolic_name b 0 [symbolic = %b (constants.%b)] +// CHECK:STDOUT: +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @.1(file.%b.loc10_9.2: %C.3) { +// CHECK:STDOUT: %b: %C.3 = bind_symbolic_name b 0 [symbolic = %b (constants.%b)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%a) { +// CHECK:STDOUT: %a => constants.%a +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%.3) { +// CHECK:STDOUT: %a => constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @D(constants.%b) { +// CHECK:STDOUT: %b => constants.%b +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%b) { +// CHECK:STDOUT: %b => constants.%b +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/const/basic.carbon b/toolchain/check/testdata/const/basic.carbon index 2a58370cfc25f..9b60c3a164020 100644 --- a/toolchain/check/testdata/const/basic.carbon +++ b/toolchain/check/testdata/const/basic.carbon @@ -34,20 +34,26 @@ fn B(p: const (i32*)) -> const (i32*) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] { // CHECK:STDOUT: %int.make_type_32.loc11_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_15 [template = i32] diff --git a/toolchain/check/testdata/const/collapse.carbon b/toolchain/check/testdata/const/collapse.carbon index 1638a28c80de1..2693152e1a6b6 100644 --- a/toolchain/check/testdata/const/collapse.carbon +++ b/toolchain/check/testdata/const/collapse.carbon @@ -30,17 +30,25 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc15_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_9.1: type = value_of_initializer %int.make_type_32.loc15_15 [template = i32] diff --git a/toolchain/check/testdata/const/fail_collapse.carbon b/toolchain/check/testdata/const/fail_collapse.carbon index 53a04abf784fd..2234e7e744fc0 100644 --- a/toolchain/check/testdata/const/fail_collapse.carbon +++ b/toolchain/check/testdata/const/fail_collapse.carbon @@ -35,17 +35,25 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32.loc15_22: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_16.1: type = value_of_initializer %int.make_type_32.loc15_22 [template = i32] diff --git a/toolchain/check/testdata/const/import.carbon b/toolchain/check/testdata/const/import.carbon index a9b4e32ea282a..71cd29a12755b 100644 --- a/toolchain/check/testdata/const/import.carbon +++ b/toolchain/check/testdata/const/import.carbon @@ -39,20 +39,27 @@ var a_ptr: const i32* = a_ptr_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: .a_ptr_ref = %a_ptr_ref // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] @@ -101,11 +108,20 @@ var a_ptr: const i32* = a_ptr_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+15, unloaded -// CHECK:STDOUT: %import_ref.2: ref %.2 = import_ref ir0, inst+24, loaded -// CHECK:STDOUT: %import_ref.3: ref %.3 = import_ref ir0, inst+36, loaded -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+15, unloaded +// CHECK:STDOUT: %import_ref.2: ref %.2 = import_ref Implicit//default, inst+23, loaded +// CHECK:STDOUT: %import_ref.3: ref %.3 = import_ref Implicit//default, inst+34, loaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.4 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -113,14 +129,13 @@ var a_ptr: const i32* = a_ptr_ref; // CHECK:STDOUT: .F = imports.%import_ref.1 // CHECK:STDOUT: .a_ref = imports.%import_ref.2 // CHECK:STDOUT: .a_ptr_ref = imports.%import_ref.3 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .a_ptr = %a_ptr // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_8.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32] // CHECK:STDOUT: %.loc6_8.2: type = converted %int.make_type_32.loc6, %.loc6_8.1 [template = i32] diff --git a/toolchain/check/testdata/eval/aggregate.carbon b/toolchain/check/testdata/eval/aggregate.carbon index 7f0fe06fc7b3a..94f8215e8db98 100644 --- a/toolchain/check/testdata/eval/aggregate.carbon +++ b/toolchain/check/testdata/eval/aggregate.carbon @@ -12,7 +12,7 @@ var tuple_copy: (i32, i32) = (1, 2) as (i32, i32); var struct_copy: {.a: i32, .b: i32, .c: i32} = {.c = 3, .b = 2, .a = 1} as {.b: i32, .a: i32, .c: i32}; -var tuple_index: [i32; 1] = (0,) as [i32; (5, 7, 1, 9)[2]]; +var tuple_index: [i32; 1] = (0,) as [i32; (5, 7, 1, 9).2]; var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; @@ -53,32 +53,28 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .tuple_copy = %tuple_copy // CHECK:STDOUT: .struct_copy = %struct_copy // CHECK:STDOUT: .tuple_index = %tuple_index // CHECK:STDOUT: .struct_access = %struct_access // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_18: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_23: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_26.1: %.2 = tuple_literal (%int.make_type_32.loc11_18, %int.make_type_32.loc11_23) @@ -178,10 +174,10 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %.loc15_56: i32 = int_literal 2 [template = constants.%.6] // CHECK:STDOUT: %tuple: %.20 = tuple_value (%.loc15_44, %.loc15_47, %.loc15_50, %.loc15_53) [template = constants.%tuple.2] // CHECK:STDOUT: %.loc15_54.2: %.20 = converted %.loc15_54.1, %tuple [template = constants.%tuple.2] -// CHECK:STDOUT: %.loc15_57: i32 = tuple_index %.loc15_54.2, %.loc15_56 [template = constants.%.5] +// CHECK:STDOUT: %.loc15_55: i32 = tuple_index %.loc15_54.2, %.loc15_56 [template = constants.%.5] // CHECK:STDOUT: %.loc15_38.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] // CHECK:STDOUT: %.loc15_38.2: type = converted %int.make_type_32.loc15, %.loc15_38.1 [template = i32] -// CHECK:STDOUT: %.loc15_58: type = array_type %.loc15_57, i32 [template = constants.%.13] +// CHECK:STDOUT: %.loc15_57: type = array_type %.loc15_55, i32 [template = constants.%.13] // CHECK:STDOUT: %.loc15_5: ref %.13 = splice_block file.%tuple_index.var {} // CHECK:STDOUT: %.loc15_32.2: i32 = int_literal 0 [template = constants.%.15] // CHECK:STDOUT: %.loc15_32.3: ref i32 = array_index %.loc15_5, %.loc15_32.2 diff --git a/toolchain/check/testdata/eval/fail_aggregate.carbon b/toolchain/check/testdata/eval/fail_aggregate.carbon index a90bfe82ee315..01f9fb95ebef0 100644 --- a/toolchain/check/testdata/eval/fail_aggregate.carbon +++ b/toolchain/check/testdata/eval/fail_aggregate.carbon @@ -39,18 +39,25 @@ var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .array_index = %array_index // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc16_24: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc16_19.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/eval/fail_symbolic.carbon b/toolchain/check/testdata/eval/fail_symbolic.carbon index f85a4c9940838..32211a76cb04d 100644 --- a/toolchain/check/testdata/eval/fail_symbolic.carbon +++ b/toolchain/check/testdata/eval/fail_symbolic.carbon @@ -28,38 +28,55 @@ fn G(N:! i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_32, %.loc12_10.1 [template = i32] // CHECK:STDOUT: %N.loc12_6.1: i32 = param N -// CHECK:STDOUT: @G.%N: i32 = bind_symbolic_name N 0, %N.loc12_6.1 [symbolic = @G.%N (constants.%N)] +// CHECK:STDOUT: @G.%N.loc12: i32 = bind_symbolic_name N 0, %N.loc12_6.1 [symbolic = @G.%N.1 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%N: i32) -// CHECK:STDOUT: generic [%N: i32] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %N.ref: i32 = name_ref N, %N [symbolic = constants.%N] -// CHECK:STDOUT: %.loc16_11.1: type = value_of_initializer %int.make_type_32 [template = i32] -// CHECK:STDOUT: %.loc16_11.2: type = converted %int.make_type_32, %.loc16_11.1 [template = i32] -// CHECK:STDOUT: %.loc16_17: type = array_type %N.ref, i32 [template = ] -// CHECK:STDOUT: %k.var: ref = var k -// CHECK:STDOUT: %k: ref = bind_name k, %k.var -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @G(%N.loc12: i32) { +// CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic = %N.1 (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%N.loc12: i32) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %N.ref: i32 = name_ref N, %N.loc12 [symbolic = %N.1 (constants.%N)] +// CHECK:STDOUT: %.loc16_11.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc16_11.2: type = converted %int.make_type_32, %.loc16_11.1 [template = i32] +// CHECK:STDOUT: %.loc16_17: type = array_type %N.ref, i32 [template = ] +// CHECK:STDOUT: %k.var: ref = var k +// CHECK:STDOUT: %k: ref = bind_name k, %k.var +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%N) { +// CHECK:STDOUT: %N.1 => constants.%N // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/symbolic.carbon b/toolchain/check/testdata/eval/symbolic.carbon index 5b3999892ba62..c0724fcace721 100644 --- a/toolchain/check/testdata/eval/symbolic.carbon +++ b/toolchain/check/testdata/eval/symbolic.carbon @@ -34,39 +34,64 @@ fn F(T:! type) { // CHECK:STDOUT: %.11: type = ptr_type %.10 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc12_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc12_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: @F.%T.loc12: type = bind_symbolic_name T 0, %T.loc12_6.1 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(%T.loc12: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %.2: type = const_type @F.%T.1 (%T) [symbolic = %.2 (constants.%.3)] +// CHECK:STDOUT: %.3: type = tuple_type (@F.%.1 (%.2), @F.%.2 (%.3)) [symbolic = %.3 (constants.%.5)] +// CHECK:STDOUT: %.4: type = struct_type {.a: @F.%T.1 (%T)} [symbolic = %.4 (constants.%.8)] +// CHECK:STDOUT: %.5: type = array_type constants.%.9, @F.%T.1 (%T) [symbolic = %.5 (constants.%.10)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc12: type) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref.loc13_11: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc13_12: type = ptr_type %T [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %T.ref.loc13_21: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc13_15: type = const_type %T [symbolic = %.2 (constants.%.3)] +// CHECK:STDOUT: %.loc13_22.1: %.4 = tuple_literal (%.loc13_12, %.loc13_15) +// CHECK:STDOUT: %.loc13_22.2: type = converted %.loc13_22.1, constants.%.5 [symbolic = %.3 (constants.%.5)] +// CHECK:STDOUT: %u.var: ref @F.%.3 (%.5) = var u +// CHECK:STDOUT: %u: ref @F.%.3 (%.5) = bind_name u, %u.var +// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc14: type = struct_type {.a: %T} [symbolic = %.4 (constants.%.8)] +// CHECK:STDOUT: %v.var: ref @F.%.4 (%.8) = var v +// CHECK:STDOUT: %v: ref @F.%.4 (%.8) = bind_name v, %v.var +// CHECK:STDOUT: %T.ref.loc15: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc15_14: i32 = int_literal 5 [template = constants.%.9] +// CHECK:STDOUT: %.loc15_15: type = array_type %.loc15_14, %T [symbolic = %.5 (constants.%.10)] +// CHECK:STDOUT: %w.var: ref @F.%.5 (%.10) = var w +// CHECK:STDOUT: %w: ref @F.%.5 (%.10) = bind_name w, %w.var +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type) -// CHECK:STDOUT: generic [%T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref.loc13_11: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc13_12: type = ptr_type %T [symbolic = constants.%.2] -// CHECK:STDOUT: %T.ref.loc13_21: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc13_15: type = const_type %T [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc13_22.1: %.4 = tuple_literal (%.loc13_12, %.loc13_15) -// CHECK:STDOUT: %.loc13_22.2: type = converted %.loc13_22.1, constants.%.5 [symbolic = constants.%.5] -// CHECK:STDOUT: %u.var: ref %.5 = var u -// CHECK:STDOUT: %u: ref %.5 = bind_name u, %u.var -// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc14: type = struct_type {.a: %T} [symbolic = constants.%.8] -// CHECK:STDOUT: %v.var: ref %.8 = var v -// CHECK:STDOUT: %v: ref %.8 = bind_name v, %v.var -// CHECK:STDOUT: %T.ref.loc15: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc15_14: i32 = int_literal 5 [template = constants.%.9] -// CHECK:STDOUT: %.loc15_15: type = array_type %.loc15_14, %T [symbolic = constants.%.10] -// CHECK:STDOUT: %w.var: ref %.10 = var w -// CHECK:STDOUT: %w: ref %.10 = bind_name w, %w.var -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon b/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon index 425e1b96d2940..745cd24d8a9a6 100644 --- a/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon +++ b/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon @@ -17,7 +17,7 @@ fn G() -> (i32, i32) { } fn H() -> i32 { - return G()[0]; + return G().0; } // CHECK:STDOUT: --- in_place_tuple_init.carbon @@ -39,24 +39,27 @@ fn H() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .H = %H.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_17: init type = call constants.%Int32() [template = i32] @@ -125,8 +128,8 @@ fn H() -> i32 { // CHECK:STDOUT: %G.call: init %.3 = call %G.ref() to %.loc20_11.1 // CHECK:STDOUT: %.loc20_14: i32 = int_literal 0 [template = constants.%.5] // CHECK:STDOUT: %.loc20_11.2: ref %.3 = temporary %.loc20_11.1, %G.call -// CHECK:STDOUT: %.loc20_15.1: ref i32 = tuple_index %.loc20_11.2, %.loc20_14 -// CHECK:STDOUT: %.loc20_15.2: i32 = bind_value %.loc20_15.1 -// CHECK:STDOUT: return %.loc20_15.2 +// CHECK:STDOUT: %.loc20_13.1: ref i32 = tuple_index %.loc20_11.2, %.loc20_14 +// CHECK:STDOUT: %.loc20_13.2: i32 = bind_value %.loc20_13.1 +// CHECK:STDOUT: return %.loc20_13.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/call.carbon b/toolchain/check/testdata/function/builtin/call.carbon index 4f3596b5d0379..b3ad4650670cb 100644 --- a/toolchain/check/testdata/function/builtin/call.carbon +++ b/toolchain/check/testdata/function/builtin/call.carbon @@ -28,20 +28,26 @@ var arr: [i32; Add(1, 2)]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/function/builtin/definition.carbon b/toolchain/check/testdata/function/builtin/definition.carbon index b3af25b76f734..9b213b9989ab1 100644 --- a/toolchain/check/testdata/function/builtin/definition.carbon +++ b/toolchain/check/testdata/function/builtin/definition.carbon @@ -21,18 +21,25 @@ fn Add(a: i32, b: i32) -> i32 = "int.sadd"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Add.decl: %Add.type = fn_decl @Add [template = constants.%Add] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/function/builtin/fail_redefined.carbon b/toolchain/check/testdata/function/builtin/fail_redefined.carbon index 20794ed519ccf..cff1c7b4def50 100644 --- a/toolchain/check/testdata/function/builtin/fail_redefined.carbon +++ b/toolchain/check/testdata/function/builtin/fail_redefined.carbon @@ -52,35 +52,27 @@ fn C(n: i32, m: i32) -> i32 = "int.sadd"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.15: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.16: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.17: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.18: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl.loc11 // CHECK:STDOUT: .B = %B.decl.loc21 // CHECK:STDOUT: .C = %C.decl.loc31 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl.loc11: %A.type = fn_decl @A [template = constants.%A] { // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32] diff --git a/toolchain/check/testdata/function/builtin/fail_unknown.carbon b/toolchain/check/testdata/function/builtin/fail_unknown.carbon index ec3ac227a6d56..ddf4ebeeea5bb 100644 --- a/toolchain/check/testdata/function/builtin/fail_unknown.carbon +++ b/toolchain/check/testdata/function/builtin/fail_unknown.carbon @@ -21,13 +21,24 @@ fn UnknownBuiltin() = "unknown.builtin.name"; // CHECK:STDOUT: %UnknownBuiltin: %UnknownBuiltin.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .UnknownBuiltin = %UnknownBuiltin.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %UnknownBuiltin.decl: %UnknownBuiltin.type = fn_decl @UnknownBuiltin [template = constants.%UnknownBuiltin] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/method.carbon b/toolchain/check/testdata/function/builtin/method.carbon index debe90653de9e..e677e05c3cf79 100644 --- a/toolchain/check/testdata/function/builtin/method.carbon +++ b/toolchain/check/testdata/function/builtin/method.carbon @@ -42,21 +42,26 @@ var arr: [i32; 1.(I.F)(2)]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] @@ -82,20 +87,20 @@ var arr: [i32; 1.(I.F)(2)]; // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %self.loc12_8.1: @I.%Self.ref.loc12_14 (%Self) = param self -// CHECK:STDOUT: %self.loc12_8.2: @I.%Self.ref.loc12_14 (%Self) = bind_name self, %self.loc12_8.1 -// CHECK:STDOUT: %Self.ref.loc12_27: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_27.1: type = facet_type_access %Self.ref.loc12_27 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_27.2: type = converted %Self.ref.loc12_27, %.loc12_27.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %other.loc12_20.1: @I.%Self.ref.loc12_14 (%Self) = param other -// CHECK:STDOUT: %other.loc12_20.2: @I.%Self.ref.loc12_14 (%Self) = bind_name other, %other.loc12_20.1 -// CHECK:STDOUT: %Self.ref.loc12_36: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_36.1: type = facet_type_access %Self.ref.loc12_36 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_36.2: type = converted %Self.ref.loc12_36, %.loc12_36.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %return.var: ref %Self = var +// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc12_8.1: @F.1.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc12_8.2: @F.1.%Self (%Self) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref.loc12_27: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_27.1: type = facet_type_access %Self.ref.loc12_27 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_27.2: type = converted %Self.ref.loc12_27, %.loc12_27.1 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %other.loc12_20.1: @F.1.%Self (%Self) = param other +// CHECK:STDOUT: %other.loc12_20.2: @F.1.%Self (%Self) = bind_name other, %other.loc12_20.1 +// CHECK:STDOUT: %Self.ref.loc12_36: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_36.1: type = facet_type_access %Self.ref.loc12_36 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_36.2: type = converted %Self.ref.loc12_36, %.loc12_36.1 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %return.var: ref @F.1.%Self (%Self) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_40: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: @@ -129,10 +134,17 @@ var arr: [i32; 1.(I.F)(2)]; // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1[@I.%self.loc12_8.2: @I.%Self.ref.loc12_14 (%Self)](@I.%other.loc12_20.2: @I.%Self.ref.loc12_14 (%Self)) -> %Self -// CHECK:STDOUT: generic [@I.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@I.%self.loc12_8.2: @F.1.%Self (%Self)](@I.%other.loc12_20.2: @F.1.%Self (%Self)) -> @F.1.%Self (%Self); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2[@impl.%self.loc16_8.2: i32](@impl.%other.loc16_19.2: i32) -> i32 = "int.sadd"; // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon index 1e9adc3897dcf..50011b20ffb26 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon @@ -58,20 +58,20 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: interface @Add { // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %Op.decl: %Op.type = fn_decl @Op [template = constants.%Op] { -// CHECK:STDOUT: %Self.ref.loc7_15: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %.loc7_15.1: type = facet_type_access %Self.ref.loc7_15 [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %.loc7_15.2: type = converted %Self.ref.loc7_15, %.loc7_15.1 [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %self.loc7_9.1: @Add.%Self.ref.loc7_15 (%Self) = param self -// CHECK:STDOUT: %self.loc7_9.2: @Add.%Self.ref.loc7_15 (%Self) = bind_name self, %self.loc7_9.1 -// CHECK:STDOUT: %Self.ref.loc7_28: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %.loc7_28.1: type = facet_type_access %Self.ref.loc7_28 [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %.loc7_28.2: type = converted %Self.ref.loc7_28, %.loc7_28.1 [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %other.loc7_21.1: @Add.%Self.ref.loc7_15 (%Self) = param other -// CHECK:STDOUT: %other.loc7_21.2: @Add.%Self.ref.loc7_15 (%Self) = bind_name other, %other.loc7_21.1 -// CHECK:STDOUT: %Self.ref.loc7_37: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %.loc7_37.1: type = facet_type_access %Self.ref.loc7_37 [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %.loc7_37.2: type = converted %Self.ref.loc7_37, %.loc7_37.1 [symbolic = %Self.ref.loc7_15 (constants.%Self)] -// CHECK:STDOUT: %return.var: ref %Self = var +// CHECK:STDOUT: %Self.ref.loc7_15: %.2 = name_ref Self, %Self [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc7_15.1: type = facet_type_access %Self.ref.loc7_15 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc7_15.2: type = converted %Self.ref.loc7_15, %.loc7_15.1 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc7_9.1: @Op.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc7_9.2: @Op.%Self (%Self) = bind_name self, %self.loc7_9.1 +// CHECK:STDOUT: %Self.ref.loc7_28: %.2 = name_ref Self, %Self [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc7_28.1: type = facet_type_access %Self.ref.loc7_28 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc7_28.2: type = converted %Self.ref.loc7_28, %.loc7_28.1 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %other.loc7_21.1: @Op.%Self (%Self) = param other +// CHECK:STDOUT: %other.loc7_21.2: @Op.%Self (%Self) = bind_name other, %other.loc7_21.1 +// CHECK:STDOUT: %Self.ref.loc7_37: %.2 = name_ref Self, %Self [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc7_37.1: type = facet_type_access %Self.ref.loc7_37 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc7_37.2: type = converted %Self.ref.loc7_37, %.loc7_37.1 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %return.var: ref @Op.%Self (%Self) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc7_41: %.3 = assoc_entity element0, %Op.decl [template = constants.%.4] // CHECK:STDOUT: @@ -83,8 +83,15 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[@Add.%self.loc7_9.2: @Add.%Self.ref.loc7_15 (%Self)](@Add.%other.loc7_21.2: @Add.%Self.ref.loc7_15 (%Self)) -> %Self -// CHECK:STDOUT: generic [@Add.%Self: %.2]; +// CHECK:STDOUT: generic fn @Op(@Add.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Add.%self.loc7_9.2: @Op.%Self (%Self)](@Add.%other.loc7_21.2: @Op.%Self (%Self)) -> @Op.%Self (%Self); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- user.carbon // CHECK:STDOUT: @@ -102,7 +109,7 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: %.4: i32 = int_literal 1 [template] // CHECK:STDOUT: %.5: i32 = int_literal 2 [template] // CHECK:STDOUT: %.6: type = assoc_entity_type @Add, %Op.type.2 [template] -// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template] // CHECK:STDOUT: %.8: = bound_method %.4, %Op.1 [template] // CHECK:STDOUT: %.9: i32 = int_literal 3 [template] // CHECK:STDOUT: %.10: type = array_type %.9, i32 [template] @@ -116,29 +123,30 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir1, inst+2, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+6, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+8, unloaded -// CHECK:STDOUT: %import_ref.4: %.6 = import_ref ir1, inst+28, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.5: %Op.type.2 = import_ref ir1, inst+24, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir1, inst+2, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: type = import_ref ir1, inst+6, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+24, unloaded -// CHECK:STDOUT: %import_ref.9: type = import_ref ir1, inst+6, loaded [template = constants.%.2] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Add = %import_ref.2 +// CHECK:STDOUT: import Core//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//default, inst+2, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: type = import_ref Core//default, inst+6, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.3 = import_ref Core//default, inst+8, unloaded +// CHECK:STDOUT: %import_ref.4: %.6 = import_ref Core//default, inst+29, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.5: %Op.type.2 = import_ref Core//default, inst+24, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//default, inst+24, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_6.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32] // CHECK:STDOUT: %.loc6_6.2: type = converted %int.make_type_32.loc6, %.loc6_6.1 [template = i32] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Add.ref: type = name_ref Add, imports.%import_ref.2 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %int.make_type_32.loc10: init type = call constants.%Int32() [template = i32] @@ -183,7 +191,11 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.1[@impl.%self.loc7_9.2: i32](@impl.%other.loc7_21.2: i32) -> i32 = "int.sadd"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/function/builtin/no_prelude/import.carbon b/toolchain/check/testdata/function/builtin/no_prelude/import.carbon index 55d3e8b314d67..c3b47fe58952a 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/import.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/import.carbon @@ -80,19 +80,23 @@ var arr: [i32; Core.TestAdd(1, 2)] = (1, 2, 3); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir1, inst+2, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %TestAdd.type = import_ref ir1, inst+20, loaded [template = constants.%TestAdd] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .TestAdd = %import_ref.2 +// CHECK:STDOUT: import Core//test +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//test, inst+2, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %TestAdd.type = import_ref Core//test, inst+20, loaded [template = constants.%TestAdd] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %TestAdd.ref: %TestAdd.type = name_ref TestAdd, imports.%import_ref.2 [template = constants.%TestAdd] // CHECK:STDOUT: %.loc4_29: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc4_32: i32 = int_literal 2 [template = constants.%.3] diff --git a/toolchain/check/testdata/function/call/fail_not_callable.carbon b/toolchain/check/testdata/function/call/fail_not_callable.carbon index 11f5383ac40f9..e5317efde6719 100644 --- a/toolchain/check/testdata/function/call/fail_not_callable.carbon +++ b/toolchain/check/testdata/function/call/fail_not_callable.carbon @@ -28,16 +28,25 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/fail_param_count.carbon b/toolchain/check/testdata/function/call/fail_param_count.carbon index 338d1e3a2fd35..73535ac723b80 100644 --- a/toolchain/check/testdata/function/call/fail_param_count.carbon +++ b/toolchain/check/testdata/function/call/fail_param_count.carbon @@ -83,21 +83,28 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run0 = %Run0.decl // CHECK:STDOUT: .Run1 = %Run1.decl // CHECK:STDOUT: .Run2 = %Run2.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Run0.decl: %Run0.type = fn_decl @Run0 [template = constants.%Run0] {} // CHECK:STDOUT: %Run1.decl: %Run1.type = fn_decl @Run1 [template = constants.%Run1] { // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/function/call/fail_param_type.carbon b/toolchain/check/testdata/function/call/fail_param_type.carbon index 843ae67ac8fa5..eccb9cdc226ec 100644 --- a/toolchain/check/testdata/function/call/fail_param_type.carbon +++ b/toolchain/check/testdata/function/call/fail_param_type.carbon @@ -34,17 +34,26 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon index d3d5d194f9dd8..065e68205b4cd 100644 --- a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon @@ -34,18 +34,28 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %.loc11_13.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%.loc11_13.1) [template = f64] diff --git a/toolchain/check/testdata/function/call/i32.carbon b/toolchain/check/testdata/function/call/i32.carbon index 647b93cf536b2..ca60dd53ffa93 100644 --- a/toolchain/check/testdata/function/call/i32.carbon +++ b/toolchain/check/testdata/function/call/i32.carbon @@ -30,19 +30,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Echo = %Echo.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Echo.decl: %Echo.type = fn_decl @Echo [template = constants.%Echo] { // CHECK:STDOUT: %int.make_type_32.loc11_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_12.1: type = value_of_initializer %int.make_type_32.loc11_12 [template = i32] diff --git a/toolchain/check/testdata/function/call/more_param_ir.carbon b/toolchain/check/testdata/function/call/more_param_ir.carbon index 63bc93e40bc5c..4c89646b072b5 100644 --- a/toolchain/check/testdata/function/call/more_param_ir.carbon +++ b/toolchain/check/testdata/function/call/more_param_ir.carbon @@ -13,7 +13,7 @@ fn Foo(a: i32, b: i32) {} fn Main() { var x: (i32,) = (1,); // Generates multiple IR instructions for the first parameter. - Foo(x[0], 6); + Foo(x.0, 6); } // CHECK:STDOUT: --- more_param_ir.carbon @@ -35,19 +35,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] @@ -87,10 +94,10 @@ fn Main() { // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo] // CHECK:STDOUT: %x.ref: ref %.3 = name_ref x, %x // CHECK:STDOUT: %.loc16_9: i32 = int_literal 0 [template = constants.%.5] -// CHECK:STDOUT: %.loc16_10.1: ref i32 = tuple_index %x.ref, %.loc16_9 -// CHECK:STDOUT: %.loc16_13: i32 = int_literal 6 [template = constants.%.6] -// CHECK:STDOUT: %.loc16_10.2: i32 = bind_value %.loc16_10.1 -// CHECK:STDOUT: %Foo.call: init %.1 = call %Foo.ref(%.loc16_10.2, %.loc16_13) +// CHECK:STDOUT: %.loc16_8.1: ref i32 = tuple_index %x.ref, %.loc16_9 +// CHECK:STDOUT: %.loc16_12: i32 = int_literal 6 [template = constants.%.6] +// CHECK:STDOUT: %.loc16_8.2: i32 = bind_value %.loc16_8.1 +// CHECK:STDOUT: %Foo.call: init %.1 = call %Foo.ref(%.loc16_8.2, %.loc16_12) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/params_one.carbon b/toolchain/check/testdata/function/call/params_one.carbon index 4b6a36c5de32c..d540db2abab3f 100644 --- a/toolchain/check/testdata/function/call/params_one.carbon +++ b/toolchain/check/testdata/function/call/params_one.carbon @@ -28,17 +28,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/function/call/params_one_comma.carbon b/toolchain/check/testdata/function/call/params_one_comma.carbon index a93958e1d48b9..35287c752ac4d 100644 --- a/toolchain/check/testdata/function/call/params_one_comma.carbon +++ b/toolchain/check/testdata/function/call/params_one_comma.carbon @@ -29,17 +29,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/function/call/params_two.carbon b/toolchain/check/testdata/function/call/params_two.carbon index 66828677303c6..8fa6732837cda 100644 --- a/toolchain/check/testdata/function/call/params_two.carbon +++ b/toolchain/check/testdata/function/call/params_two.carbon @@ -29,18 +29,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/function/call/params_two_comma.carbon b/toolchain/check/testdata/function/call/params_two_comma.carbon index c7d599b7a1755..8658f6330c7cb 100644 --- a/toolchain/check/testdata/function/call/params_two_comma.carbon +++ b/toolchain/check/testdata/function/call/params_two_comma.carbon @@ -30,18 +30,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon b/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon index 49d9d9ab3b72c..35d66af028cba 100644 --- a/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon +++ b/toolchain/check/testdata/function/declaration/fail_param_in_type.carbon @@ -24,17 +24,25 @@ fn F(n: i32, a: [i32; n]*); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc14_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_9.1: type = value_of_initializer %int.make_type_32.loc14_9 [template = i32] diff --git a/toolchain/check/testdata/function/declaration/fail_param_redecl.carbon b/toolchain/check/testdata/function/declaration/fail_param_redecl.carbon index 11dfc35e9a834..28ef7267e28e1 100644 --- a/toolchain/check/testdata/function/declaration/fail_param_redecl.carbon +++ b/toolchain/check/testdata/function/declaration/fail_param_redecl.carbon @@ -27,17 +27,25 @@ fn F(n: i32, n: i32); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc17_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc17_9.1: type = value_of_initializer %int.make_type_32.loc17_9 [template = i32] diff --git a/toolchain/check/testdata/function/declaration/import.carbon b/toolchain/check/testdata/function/declaration/import.carbon index 1166f7d447ce2..a83174da6636d 100644 --- a/toolchain/check/testdata/function/declaration/import.carbon +++ b/toolchain/check/testdata/function/declaration/import.carbon @@ -389,15 +389,22 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl @@ -405,7 +412,6 @@ import library "extern_api"; // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] { // CHECK:STDOUT: %int.make_type_32.loc5_9: init type = call constants.%Int32() [template = i32] @@ -473,15 +479,22 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl @@ -489,7 +502,6 @@ import library "extern_api"; // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] { // CHECK:STDOUT: %int.make_type_32.loc5_16: init type = call constants.%Int32() [template = i32] @@ -547,9 +559,9 @@ import library "extern_api"; // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: %.2: i32 = int_literal 1 [template] // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template] -// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %C.type: type = fn_type @C [template] // CHECK:STDOUT: %C: %C.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template] // CHECK:STDOUT: %D.type: type = fn_type @D [template] // CHECK:STDOUT: %D: %D.type = struct_value () [template] @@ -558,13 +570,26 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+44, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+47, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.5: %E.type = import_ref ir1, inst+51, loaded [template = constants.%E] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -573,8 +598,8 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c @@ -583,11 +608,6 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -644,8 +664,8 @@ import library "extern_api"; // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D] // CHECK:STDOUT: %D.call: init %.1 = call %D.ref() // CHECK:STDOUT: assign file.%d.var, %D.call -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.5 [template = constants.%E] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E] // CHECK:STDOUT: %E.call: init %.1 = call %E.ref() // CHECK:STDOUT: assign file.%e.var, %E.call // CHECK:STDOUT: return @@ -675,17 +695,26 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+44, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+47, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.5: %E.type = import_ref ir1, inst+51, loaded [template = constants.%E] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = file.%E.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -694,8 +723,8 @@ import library "extern_api"; // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b.loc13 // CHECK:STDOUT: .c = %c.loc14 @@ -704,11 +733,6 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = %E.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] { // CHECK:STDOUT: %int.make_type_32.loc7_16: init type = call constants.%Int32() [template = i32] @@ -793,7 +817,7 @@ import library "extern_api"; // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D] // CHECK:STDOUT: %D.call: init %.1 = call %D.ref() // CHECK:STDOUT: assign file.%d.var, %D.call -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E] // CHECK:STDOUT: %E.call: init %.1 = call %E.ref() // CHECK:STDOUT: assign file.%e.var, %E.call @@ -824,17 +848,26 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+44, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+47, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.5: %E.type = import_ref ir1, inst+51, loaded [template = constants.%E] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, inst+21, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, inst+41, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, inst+44, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//extern_api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = file.%E.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, inst+48, loaded [template = constants.%E] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -843,8 +876,8 @@ import library "extern_api"; // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b.loc13 // CHECK:STDOUT: .c = %c.loc14 @@ -853,11 +886,6 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = %E.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] { // CHECK:STDOUT: %int.make_type_32.loc7_16: init type = call constants.%Int32() [template = i32] @@ -942,7 +970,7 @@ import library "extern_api"; // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D] // CHECK:STDOUT: %D.call: init %.1 = call %D.ref() // CHECK:STDOUT: assign file.%d.var, %D.call -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E] // CHECK:STDOUT: %E.call: init %.1 = call %E.ref() // CHECK:STDOUT: assign file.%e.var, %E.call @@ -961,9 +989,9 @@ import library "extern_api"; // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: %.2: i32 = int_literal 1 [template] // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template] -// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %C.type: type = fn_type @C [template] // CHECK:STDOUT: %C: %C.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template] // CHECK:STDOUT: %D.type: type = fn_type @D [template] // CHECK:STDOUT: %D: %D.type = struct_value () [template] @@ -972,18 +1000,31 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+44, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+47, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.5: %E.type = import_ref ir1, inst+51, loaded [template = constants.%E] -// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+3, unloaded -// CHECK:STDOUT: %import_ref.7 = import_ref ir2, inst+22, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir2, inst+44, unloaded -// CHECK:STDOUT: %import_ref.9 = import_ref ir2, inst+47, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir2, inst+51, unloaded -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir5, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir5, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E] +// CHECK:STDOUT: %import_ref.7 = import_ref Main//extern_api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref Main//extern_api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Main//extern_api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Main//extern_api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.11 = import_ref Main//extern_api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.12 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -992,8 +1033,8 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c @@ -1002,11 +1043,6 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc72_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc72_9.2: type = converted %.loc72_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -1063,8 +1099,8 @@ import library "extern_api"; // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D] // CHECK:STDOUT: %D.call: init %.1 = call %D.ref() // CHECK:STDOUT: assign file.%d.var, %D.call -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.5 [template = constants.%E] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E] // CHECK:STDOUT: %E.call: init %.1 = call %E.ref() // CHECK:STDOUT: assign file.%e.var, %E.call // CHECK:STDOUT: return @@ -1082,9 +1118,9 @@ import library "extern_api"; // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: %.2: i32 = int_literal 1 [template] // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template] -// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %C.type: type = fn_type @C [template] // CHECK:STDOUT: %C: %C.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template] // CHECK:STDOUT: %D.type: type = fn_type @D [template] // CHECK:STDOUT: %D: %D.type = struct_value () [template] @@ -1093,18 +1129,31 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+44, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+47, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.5: %E.type = import_ref ir1, inst+51, loaded [template = constants.%E] -// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+3, unloaded -// CHECK:STDOUT: %import_ref.7 = import_ref ir2, inst+22, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir2, inst+44, unloaded -// CHECK:STDOUT: %import_ref.9 = import_ref ir2, inst+47, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir2, inst+51, unloaded -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir5, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir5, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, inst+21, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, inst+41, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, inst+44, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//extern_api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, inst+48, loaded [template = constants.%E] +// CHECK:STDOUT: %import_ref.7 = import_ref Main//api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref Main//api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Main//api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Main//api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.11 = import_ref Main//api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.12 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1113,8 +1162,8 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c @@ -1123,11 +1172,6 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc72_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc72_9.2: type = converted %.loc72_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -1184,8 +1228,8 @@ import library "extern_api"; // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D] // CHECK:STDOUT: %D.call: init %.1 = call %D.ref() // CHECK:STDOUT: assign file.%d.var, %D.call -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.5 [template = constants.%E] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E] // CHECK:STDOUT: %E.call: init %.1 = call %E.ref() // CHECK:STDOUT: assign file.%e.var, %E.call // CHECK:STDOUT: return @@ -1200,11 +1244,24 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+44, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+51, unloaded +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Main//extern_api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1213,17 +1270,12 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -1254,12 +1306,26 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+44, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+51, unloaded -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Main//extern_api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1268,17 +1334,12 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -1314,11 +1375,24 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+44, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+51, unloaded +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Main//api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1327,17 +1401,12 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -1358,11 +1427,24 @@ import library "extern_api"; // CHECK:STDOUT: --- unloaded.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+44, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+51, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Main//api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1371,26 +1453,34 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- unloaded_extern.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+44, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+51, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Main//extern_api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1399,31 +1489,39 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_todo_loaded_merge.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+44, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+51, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+3, unloaded -// CHECK:STDOUT: %import_ref.7 = import_ref ir2, inst+22, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir2, inst+44, unloaded -// CHECK:STDOUT: %import_ref.9 = import_ref ir2, inst+47, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir2, inst+51, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Main//api, inst+47, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.5, [template] { +// CHECK:STDOUT: .E = %import_ref.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//extern_api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref Main//extern_api, inst+21, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Main//extern_api, inst+41, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Main//extern_api, inst+44, unloaded +// CHECK:STDOUT: %import_ref.11 = import_ref Main//extern_api, inst+48, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1432,15 +1530,10 @@ import library "extern_api"; // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+50, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .E = imports.%import_ref.5 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon b/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon index fc6eaab4f0ad7..16fabc0b53489 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon @@ -64,7 +64,7 @@ var f: () = F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %F.type = import_ref ir1, inst+1, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref: %F.type = import_ref Main//base, inst+1, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -86,7 +86,7 @@ var f: () = F(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %F.type = import_ref ir1, inst+7, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref: %F.type = import_ref Main//export, inst+7, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon b/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon index 6e4e7b6b204db..8c960562acc69 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon @@ -44,18 +44,30 @@ fn F(); // --- fail_member_extern.carbon +library "member_extern"; + class C { // CHECK:STDERR: fail_member_extern.carbon:[[@LINE+4]]:3: ERROR: `extern` not allowed on `fn` declaration that is a member. // CHECK:STDERR: extern fn F(); // CHECK:STDERR: ^~~~~~ // CHECK:STDERR: extern fn F(); - // CHECK:STDERR: fail_member_extern.carbon:[[@LINE+3]]:3: ERROR: `extern` not allowed on `fn` declaration that is a member. + // CHECK:STDERR: fail_member_extern.carbon:[[@LINE+4]]:3: ERROR: `extern` not allowed on `fn` declaration that is a member. // CHECK:STDERR: extern fn G[self: Self](); // CHECK:STDERR: ^~~~~~ + // CHECK:STDERR: extern fn G[self: Self](); } +// --- fail_todo_extern_library.carbon + +library "extern_library"; + +// CHECK:STDERR: fail_todo_extern_library.carbon:[[@LINE+3]]:1: ERROR: Semantics TODO: `extern library syntax`. +// CHECK:STDERR: extern library "foo" fn F(); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ +extern library "foo" fn F(); + // CHECK:STDOUT: --- basic.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -132,8 +144,8 @@ class C { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C] -// CHECK:STDOUT: %self.loc11_15.1: %C = param self -// CHECK:STDOUT: %self.loc11_15.2: %C = bind_name self, %self.loc11_15.1 +// CHECK:STDOUT: %self.loc14_15.1: %C = param self +// CHECK:STDOUT: %self.loc14_15.2: %C = bind_name self, %self.loc14_15.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -144,5 +156,9 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @G[@C.%self.loc11_15.2: %C](); +// CHECK:STDOUT: fn @G[@C.%self.loc14_15.2: %C](); +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_extern_library.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: file {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon b/toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon index 6cb84ded9e1b0..b55884ab7b386 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon @@ -54,7 +54,7 @@ library "use_imported"; import library "api"; fn CallFAndGIncomplete() { - // CHECK:STDERR: fail_use_imported.carbon:[[@LINE+15]]:3: ERROR: Function returns incomplete type `C`. + // CHECK:STDERR: fail_use_imported.carbon:[[@LINE+16]]:3: ERROR: Function returns incomplete type `C`. // CHECK:STDERR: ReturnCUnused(); // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_use_imported.carbon:[[@LINE-6]]:1: In import. @@ -69,7 +69,23 @@ fn CallFAndGIncomplete() { // CHECK:STDERR: fail_incomplete_return.carbon:7:20: Return type declared here. // CHECK:STDERR: fn ReturnCUnused() -> C; // CHECK:STDERR: ^~~~ + // CHECK:STDERR: ReturnCUnused(); + // CHECK:STDERR: fail_use_imported.carbon:[[@LINE+15]]:3: ERROR: Function returns incomplete type `C`. + // CHECK:STDERR: ReturnCUsed(); + // CHECK:STDERR: ^~~~~~~~~~~ + // CHECK:STDERR: fail_use_imported.carbon:[[@LINE-23]]:1: In import. + // CHECK:STDERR: import library "api"; + // CHECK:STDERR: ^~~~~~ + // CHECK:STDERR: fail_incomplete_return.carbon:4:1: Class was forward declared here. + // CHECK:STDERR: class C; + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: fail_use_imported.carbon:[[@LINE-29]]:1: In import. + // CHECK:STDERR: import library "api"; + // CHECK:STDERR: ^~~~~~ + // CHECK:STDERR: fail_incomplete_return.carbon:8:18: Return type declared here. + // CHECK:STDERR: fn ReturnCUsed() -> C; + // CHECK:STDERR: ^~~~ ReturnCUsed(); ReturnDUnused(); ReturnDUsed(); @@ -156,29 +172,29 @@ fn CallFAndGIncomplete() { // CHECK:STDOUT: %CallFAndGIncomplete.type: type = fn_type @CallFAndGIncomplete [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %CallFAndGIncomplete: %CallFAndGIncomplete.type = struct_value () [template] -// CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: %ReturnCUnused.type: type = fn_type @ReturnCUnused [template] // CHECK:STDOUT: %ReturnCUnused: %ReturnCUnused.type = struct_value () [template] +// CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: %ReturnCUsed.type: type = fn_type @ReturnCUsed [template] // CHECK:STDOUT: %ReturnCUsed: %ReturnCUsed.type = struct_value () [template] -// CHECK:STDOUT: %D: type = class_type @D [template] -// CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %ReturnDUnused.type: type = fn_type @ReturnDUnused [template] // CHECK:STDOUT: %ReturnDUnused: %ReturnDUnused.type = struct_value () [template] +// CHECK:STDOUT: %D: type = class_type @D [template] +// CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = ptr_type %.2 [template] // CHECK:STDOUT: %ReturnDUsed.type: type = fn_type @ReturnDUsed [template] // CHECK:STDOUT: %ReturnDUsed: %ReturnDUsed.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %ReturnCUnused.type = import_ref ir1, inst+7, loaded [template = constants.%ReturnCUnused] -// CHECK:STDOUT: %import_ref.4: %ReturnCUsed.type = import_ref ir1, inst+13, loaded [template = constants.%ReturnCUsed] -// CHECK:STDOUT: %import_ref.5: %ReturnDUnused.type = import_ref ir1, inst+18, loaded [template = constants.%ReturnDUnused] -// CHECK:STDOUT: %import_ref.6: %ReturnDUsed.type = import_ref ir1, inst+23, loaded [template = constants.%ReturnDUsed] -// CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+26, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//api, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %ReturnCUnused.type = import_ref Main//api, inst+7, loaded [template = constants.%ReturnCUnused] +// CHECK:STDOUT: %import_ref.4: %ReturnCUsed.type = import_ref Main//api, inst+13, loaded [template = constants.%ReturnCUsed] +// CHECK:STDOUT: %import_ref.5: %ReturnDUnused.type = import_ref Main//api, inst+18, loaded [template = constants.%ReturnDUnused] +// CHECK:STDOUT: %import_ref.6: %ReturnDUsed.type = import_ref Main//api, inst+23, loaded [template = constants.%ReturnDUsed] +// CHECK:STDOUT: %import_ref.7 = import_ref Main//api, inst+26, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref Main//api, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -210,11 +226,13 @@ fn CallFAndGIncomplete() { // CHECK:STDOUT: %ReturnCUsed.ref: %ReturnCUsed.type = name_ref ReturnCUsed, imports.%import_ref.4 [template = constants.%ReturnCUsed] // CHECK:STDOUT: %ReturnCUsed.call: init = call %ReturnCUsed.ref() // CHECK:STDOUT: %ReturnDUnused.ref: %ReturnDUnused.type = name_ref ReturnDUnused, imports.%import_ref.5 [template = constants.%ReturnDUnused] -// CHECK:STDOUT: %.loc24_16.1: ref %D = temporary_storage -// CHECK:STDOUT: %ReturnDUnused.call: init %D = call %ReturnDUnused.ref() to %.loc24_16.1 -// CHECK:STDOUT: %.loc24_16.2: ref %D = temporary %.loc24_16.1, %ReturnDUnused.call +// CHECK:STDOUT: %.loc40_16.1: ref %D = temporary_storage +// CHECK:STDOUT: %ReturnDUnused.call: init %D = call %ReturnDUnused.ref() to %.loc40_16.1 +// CHECK:STDOUT: %.loc40_16.2: ref %D = temporary %.loc40_16.1, %ReturnDUnused.call // CHECK:STDOUT: %ReturnDUsed.ref: %ReturnDUsed.type = name_ref ReturnDUsed, imports.%import_ref.6 [template = constants.%ReturnDUsed] -// CHECK:STDOUT: %ReturnDUsed.call: init = call %ReturnDUsed.ref() +// CHECK:STDOUT: %.loc41_14.1: ref %D = temporary_storage +// CHECK:STDOUT: %ReturnDUsed.call: init %D = call %ReturnDUsed.ref() to %.loc41_14.1 +// CHECK:STDOUT: %.loc41_14.2: ref %D = temporary %.loc41_14.1, %ReturnDUsed.call // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon b/toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon index ac764e2648c2e..e6d69b607d039 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon @@ -93,7 +93,7 @@ extern fn A(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//basic, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -136,7 +136,7 @@ extern fn A(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern_api, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -176,7 +176,7 @@ extern fn A(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern_impl, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/function/declaration/no_prelude/no_definition_in_impl_file.carbon b/toolchain/check/testdata/function/declaration/no_prelude/no_definition_in_impl_file.carbon index 243ca89faea8c..edaa755ea5be4 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/no_definition_in_impl_file.carbon @@ -97,7 +97,7 @@ fn D(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//decl_in_api_definition_in_impl, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -124,7 +124,7 @@ fn D(); // CHECK:STDOUT: --- use_decl_in_api.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//decl_in_api_definition_in_impl, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -155,7 +155,7 @@ fn D(); // CHECK:STDOUT: --- decl_only_in_api.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir0, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//decl_only_in_api, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -192,7 +192,7 @@ fn D(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %C.type = import_ref ir0, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref: %C.type = import_ref Main//decl_in_api_decl_in_impl, inst+1, loaded [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/function/declaration/param_same_name.carbon b/toolchain/check/testdata/function/declaration/param_same_name.carbon index eaa1098956570..2a6979d60d686 100644 --- a/toolchain/check/testdata/function/declaration/param_same_name.carbon +++ b/toolchain/check/testdata/function/declaration/param_same_name.carbon @@ -25,18 +25,26 @@ fn G(a: i32); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/function/definition/import.carbon b/toolchain/check/testdata/function/definition/import.carbon index 36f0e5b9ceca8..db0fa849e6fce 100644 --- a/toolchain/check/testdata/function/definition/import.carbon +++ b/toolchain/check/testdata/function/definition/import.carbon @@ -18,7 +18,7 @@ library "fns"; fn A() {} fn B(b: i32) -> i32 { return b; } -fn C(c: (i32,)) -> {.c: i32} { return {.c = c[0]}; } +fn C(c: (i32,)) -> {.c: i32} { return {.c = c.0}; } fn D(); // --- extern.carbon @@ -115,22 +115,28 @@ fn D() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] { // CHECK:STDOUT: %int.make_type_32.loc5_9: init type = call constants.%Int32() [template = i32] @@ -177,11 +183,11 @@ fn D() {} // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %.3 = name_ref c, %c // CHECK:STDOUT: %.loc6_47: i32 = int_literal 0 [template = constants.%.5] -// CHECK:STDOUT: %.loc6_48: i32 = tuple_index %c.ref, %.loc6_47 -// CHECK:STDOUT: %.loc6_49: %.4 = struct_literal (%.loc6_48) -// CHECK:STDOUT: %struct: %.4 = struct_value (%.loc6_48) -// CHECK:STDOUT: %.loc6_50: %.4 = converted %.loc6_49, %struct -// CHECK:STDOUT: return %.loc6_50 +// CHECK:STDOUT: %.loc6_46: i32 = tuple_index %c.ref, %.loc6_47 +// CHECK:STDOUT: %.loc6_48: %.4 = struct_literal (%.loc6_46) +// CHECK:STDOUT: %struct: %.4 = struct_value (%.loc6_46) +// CHECK:STDOUT: %.loc6_49: %.4 = converted %.loc6_48, %struct +// CHECK:STDOUT: return %.loc6_49 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @D(); @@ -194,13 +200,24 @@ fn D() {} // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -218,19 +235,28 @@ fn D() {} // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: %.2: i32 = int_literal 1 [template] // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template] -// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %C.type: type = fn_type @C [template] // CHECK:STDOUT: %C: %C.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = tuple_type (i32) [template] // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+23, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+47, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+59, unloaded -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//fns, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//fns, inst+22, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//fns, inst+44, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//fns, inst+56, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -239,14 +265,13 @@ fn D() {} // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -304,12 +329,21 @@ fn D() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+23, loaded [template = constants.%B] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+59, unloaded -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//fns, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//fns, inst+22, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//fns, inst+44, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//fns, inst+56, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -318,11 +352,10 @@ fn D() {} // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] { // CHECK:STDOUT: %int.make_type_32.loc27_9: init type = call constants.%Int32() [template = i32] @@ -355,17 +388,25 @@ fn D() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl.loc6 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl.loc6: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: %A.decl.loc7: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } @@ -384,10 +425,19 @@ fn D() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+23, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+47, unloaded -// CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+59, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//fns, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//fns, inst+22, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//fns, inst+44, unloaded +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//fns, inst+56, loaded [template = constants.%D] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -396,11 +446,10 @@ fn D() {} // CHECK:STDOUT: .B = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .D = %D.decl.loc13 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.decl.loc6: %D.type = fn_decl @D [template = constants.%D] {} // CHECK:STDOUT: %D.decl.loc13: %D.type = fn_decl @D [template = constants.%D] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/import_access.carbon b/toolchain/check/testdata/function/definition/import_access.carbon index 3432bd08a9394..11b03e0a73e79 100644 --- a/toolchain/check/testdata/function/definition/import_access.carbon +++ b/toolchain/check/testdata/function/definition/import_access.carbon @@ -143,13 +143,24 @@ private fn Redecl() {} // CHECK:STDOUT: %Def: %Def.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Def [private] = %Def.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Def.decl: %Def.type = fn_decl @Def [template = constants.%Def] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -166,13 +177,24 @@ private fn Redecl() {} // CHECK:STDOUT: %ForwardWithDef: %ForwardWithDef.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .ForwardWithDef [private] = %ForwardWithDef.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ForwardWithDef.decl.loc4: %ForwardWithDef.type = fn_decl @ForwardWithDef [template = constants.%ForwardWithDef] {} // CHECK:STDOUT: %ForwardWithDef.decl.loc6: %ForwardWithDef.type = fn_decl @ForwardWithDef [template = constants.%ForwardWithDef] {} // CHECK:STDOUT: } @@ -190,13 +212,24 @@ private fn Redecl() {} // CHECK:STDOUT: %Forward: %Forward.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Forward [private] = %Forward.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Forward.decl: %Forward.type = fn_decl @Forward [template = constants.%Forward] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -211,19 +244,27 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Def.type = import_ref ir0, inst+3, loaded [template = constants.%Def] +// CHECK:STDOUT: %import_ref: %Def.type = import_ref Test//def, inst+3, loaded [template = constants.%Def] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Def [private] = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -246,14 +287,25 @@ private fn Redecl() {} // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -273,16 +325,29 @@ private fn Redecl() {} // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -291,7 +356,7 @@ private fn Redecl() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Test.ref: = name_ref Test, file.%Test [template = file.%Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %Def.ref: = name_ref Def, [template = ] // CHECK:STDOUT: assign file.%f.var, // CHECK:STDOUT: return @@ -306,19 +371,27 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %ForwardWithDef.type = import_ref ir0, inst+3, loaded [template = constants.%ForwardWithDef] +// CHECK:STDOUT: %import_ref: %ForwardWithDef.type = import_ref Test//forward_with_def, inst+3, loaded [template = constants.%ForwardWithDef] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .ForwardWithDef [private] = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -341,14 +414,25 @@ private fn Redecl() {} // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -368,16 +452,29 @@ private fn Redecl() {} // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//forward_with_def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -386,7 +483,7 @@ private fn Redecl() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Test.ref: = name_ref Test, file.%Test [template = file.%Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %ForwardWithDef.ref: = name_ref ForwardWithDef, [template = ] // CHECK:STDOUT: assign file.%f.var, // CHECK:STDOUT: return @@ -401,19 +498,27 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Forward.type = import_ref ir0, inst+3, loaded [template = constants.%Forward] +// CHECK:STDOUT: %import_ref: %Forward.type = import_ref Test//forward, inst+3, loaded [template = constants.%Forward] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Forward [private] = %Forward.decl -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -440,14 +545,25 @@ private fn Redecl() {} // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -467,16 +583,29 @@ private fn Redecl() {} // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//forward +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %.loc9_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc9_9.2: type = converted %.loc9_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %f.var: ref %.1 = var f @@ -485,7 +614,7 @@ private fn Redecl() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Test.ref: = name_ref Test, file.%Test [template = file.%Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %Forward.ref: = name_ref Forward, [template = ] // CHECK:STDOUT: assign file.%f.var, // CHECK:STDOUT: return @@ -499,13 +628,24 @@ private fn Redecl() {} // CHECK:STDOUT: %Redecl: %Redecl.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Redecl [private] = %Redecl.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Redecl.decl.loc4: %Redecl.type = fn_decl @Redecl [template = constants.%Redecl] {} // CHECK:STDOUT: %Redecl.decl.loc6: %Redecl.type = fn_decl @Redecl [template = constants.%Redecl] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon b/toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon index 4f409a60881b8..ea24b90508152 100644 --- a/toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon @@ -150,7 +150,7 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//basic, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -193,7 +193,7 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern_api, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -236,7 +236,7 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern_impl, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -282,7 +282,7 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//redecl_after_def, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -325,7 +325,7 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+1, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Main//redef_after_def, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -373,8 +373,8 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2: %A.type = import_ref ir0, inst+6, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.1 = import_ref Main//def_alias, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: %A.type = import_ref Main//def_alias, inst+6, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/function/definition/no_prelude/syntactic_merge.carbon b/toolchain/check/testdata/function/definition/no_prelude/syntactic_merge.carbon new file mode 100644 index 0000000000000..bc081cd815004 --- /dev/null +++ b/toolchain/check/testdata/function/definition/no_prelude/syntactic_merge.carbon @@ -0,0 +1,754 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/definition/no_prelude/syntactic_merge.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/no_prelude/syntactic_merge.carbon + +// --- basic.carbon + +library "basic"; + +class C {} +alias D = C; + +fn Foo(a: C); +fn Foo(a: C) {} + +fn Bar(a: D); +fn Bar(a: D) {} + +// --- spacing.carbon + +library "spacing"; + +class C {} + +fn Foo [ ] ( a : C ); +fn Foo[](a: C) {} + +// --- fail_parens.carbon + +library "parens"; + +class C {} + +fn Foo(a: C); +// CHECK:STDERR: fail_parens.carbon:[[@LINE+7]]:11: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: fn Foo(a: (C)) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_parens.carbon:[[@LINE-4]]:11: Comparing with previous declaration here. +// CHECK:STDERR: fn Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +fn Foo(a: (C)) {} + +// --- todo_fail_raw_identifier.carbon + +library "raw_identifier"; + +class C {} + +fn Foo(a: C); +fn Foo(a: r#C) {} + +// --- two_file.carbon + +library "two_file"; + +class C {} +alias D = C; + +fn Foo(a: C); +fn Bar(a: D); + +// --- two_file.impl.carbon + +impl library "two_file"; + +fn Foo(a: C) {} +fn Bar(a: D) {} + +// --- fail_name_mismatch.carbon + +library "name_mismatch"; + +class C {} +alias D = C; + +fn Foo(a: C); +// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE+7]]:8: ERROR: Redeclaration differs at parameter 1. +// CHECK:STDERR: fn Foo(b: D) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE-4]]:8: Previous declaration's corresponding parameter here. +// CHECK:STDERR: fn Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +fn Foo(b: D) {} + +// --- fail_alias.carbon + +library "alias"; + +class C {} +alias D = C; + +fn Foo(a: C); +// CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:11: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: fn Foo(a: D) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_alias.carbon:[[@LINE-4]]:11: Comparing with previous declaration here. +// CHECK:STDERR: fn Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +fn Foo(a: D) {} + +// --- fail_deduced_alias.carbon + +library "deduced_alias"; + +class C {} +alias D = C; + +fn Foo[a: C](); +// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE+7]]:11: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: fn Foo[a: D]() {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE-4]]:11: Comparing with previous declaration here. +// CHECK:STDERR: fn Foo[a: C](); +// CHECK:STDERR: ^ +// CHECK:STDERR: +fn Foo[a: D]() {} + +// --- todo_fail_alias_in_return.carbon + +library "alias_in_return"; + +class C {} +alias D = C; + +fn Foo() -> C; +fn Foo() -> D { return {}; } + +// --- alias_two_file.carbon + +library "alias_two_file"; + +class C {} + +fn Foo(a: C); + +// --- todo_fail_alias_two_file.impl.carbon + +impl library "alias_two_file"; + +alias D = C; + +fn Foo(a: D) {} + +// --- fail_repeat_const.carbon + +library "repeat_const"; + +class C {} + +fn Foo(a: const C); +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+10]]:11: WARNING: `const` applied repeatedly to the same type has no additional effect. +// CHECK:STDERR: fn Foo(a: const (const C)) {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+6]]:17: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: fn Foo(a: const (const C)) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE-8]]:17: Comparing with previous declaration here. +// CHECK:STDERR: fn Foo(a: const C); +// CHECK:STDERR: ^ +fn Foo(a: const (const C)) {} + +// CHECK:STDOUT: --- basic.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template] +// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl.loc7 +// CHECK:STDOUT: .Bar = %Bar.decl.loc10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_8.1: %C = param a +// CHECK:STDOUT: %a.loc7_8.2: %C = bind_name a, %a.loc7_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc8: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc8_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc8_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl.loc10: %Bar.type = fn_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref.loc10: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc10_8.1: %C = param a +// CHECK:STDOUT: %a.loc10_8.2: %C = bind_name a, %a.loc10_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl.loc11: %Bar.type = fn_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref.loc11: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc11_8.1: %C = param a +// CHECK:STDOUT: @Bar.%a: %C = bind_name a, %a.loc11_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Bar(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- spacing.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl.loc6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_14.1: %C = param a +// CHECK:STDOUT: %a.loc6_14.2: %C = bind_name a, %a.loc6_14.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_10.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_10.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo[](%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_parens.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = fn_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc6_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %C.ref.loc14: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc14_8.1: %C = param a +// CHECK:STDOUT: @.1.%a: %C = bind_name a, %a.loc14_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @.1(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- todo_fail_raw_identifier.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl.loc6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_8.1: %C = param a +// CHECK:STDOUT: %a.loc6_8.2: %C = bind_name a, %a.loc6_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- two_file.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template] +// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .Bar = %Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc8_8.1: %C = param a +// CHECK:STDOUT: @Bar.%a: %C = bind_name a, %a.loc8_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Bar(%a: %C); +// CHECK:STDOUT: +// CHECK:STDOUT: --- two_file.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template] +// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//two_file, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//two_file, inst+5, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3: %Foo.type = import_ref Main//two_file, inst+9, loaded [template = constants.%Foo] +// CHECK:STDOUT: %import_ref.4: %Bar.type = import_ref Main//two_file, inst+16, loaded [template = constants.%Bar] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//two_file, inst+2, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = imports.%import_ref.1 +// CHECK:STDOUT: .D = imports.%import_ref.2 +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .Bar = %Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc2_6.1 = import +// CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %a.loc4_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc4_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.2 [template = constants.%C] +// CHECK:STDOUT: %a.loc5_8.1: %C = param a +// CHECK:STDOUT: @Bar.%a: %C = bind_name a, %a.loc5_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Bar(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_name_mismatch.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = fn_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %b.loc15_8.1: %C = param b +// CHECK:STDOUT: @.1.%b: %C = bind_name b, %b.loc15_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @.1(%b: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_alias.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = fn_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc15_8.1: %C = param a +// CHECK:STDOUT: @.1.%a: %C = bind_name a, %a.loc15_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @.1(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_deduced_alias.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = fn_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc7_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc15_8.1: %C = param a +// CHECK:STDOUT: @.1.%a: %C = bind_name a, %a.loc15_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo[%a: %C](); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @.1[%a: %C]() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- todo_fail_alias_in_return.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %struct: %C = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl.loc7 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %return.var.loc7: ref %C = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc8: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: @Foo.%return: ref %C = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo() -> %return: %C { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8_25.1: %.1 = struct_literal () +// CHECK:STDOUT: %.loc8_25.2: init %C = class_init (), %return [template = constants.%struct] +// CHECK:STDOUT: %.loc8_26: init %C = converted %.loc8_25.1, %.loc8_25.2 [template = constants.%struct] +// CHECK:STDOUT: return %.loc8_26 to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- alias_two_file.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc6_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C); +// CHECK:STDOUT: +// CHECK:STDOUT: --- todo_fail_alias_two_file.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//alias_two_file, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: %Foo.type = import_ref Main//alias_two_file, inst+7, loaded [template = constants.%Foo] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//alias_two_file, inst+2, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = imports.%import_ref.1 +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc2_6.1 = import +// CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc6_8.1: %C = param a +// CHECK:STDOUT: @Foo.%a: %C = bind_name a, %a.loc6_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_repeat_const.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = const_type %C [template] +// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template] +// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = fn_type @.1 [template] +// CHECK:STDOUT: %.4: %.type = struct_value () [template] +// CHECK:STDOUT: %.5: type = ptr_type %.1 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc6: type = const_type %C [template = constants.%.2] +// CHECK:STDOUT: %a.loc6_8.1: %.2 = param a +// CHECK:STDOUT: @Foo.%a: %.2 = bind_name a, %a.loc6_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { +// CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc17_18: type = const_type %C [template = constants.%.2] +// CHECK:STDOUT: %.loc17_11: type = const_type %.2 [template = constants.%.2] +// CHECK:STDOUT: %a.loc17_8.1: %.2 = param a +// CHECK:STDOUT: @.1.%a: %.2 = bind_name a, %a.loc17_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Foo(%a: %.2); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @.1(%a: %.2) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/definition/params_one.carbon b/toolchain/check/testdata/function/definition/params_one.carbon index 1f8199244ba74..f741f3186b5b8 100644 --- a/toolchain/check/testdata/function/definition/params_one.carbon +++ b/toolchain/check/testdata/function/definition/params_one.carbon @@ -21,16 +21,25 @@ fn Foo(a: i32) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/function/definition/params_one_comma.carbon b/toolchain/check/testdata/function/definition/params_one_comma.carbon index b67ec6fccf9c4..cab18c138b544 100644 --- a/toolchain/check/testdata/function/definition/params_one_comma.carbon +++ b/toolchain/check/testdata/function/definition/params_one_comma.carbon @@ -21,16 +21,25 @@ fn Foo(a: i32,) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/function/definition/params_two.carbon b/toolchain/check/testdata/function/definition/params_two.carbon index 0da6b65a4cf35..1f196062a7989 100644 --- a/toolchain/check/testdata/function/definition/params_two.carbon +++ b/toolchain/check/testdata/function/definition/params_two.carbon @@ -21,17 +21,25 @@ fn Foo(a: i32, b: i32) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/function/definition/params_two_comma.carbon b/toolchain/check/testdata/function/definition/params_two_comma.carbon index 67a780628eb08..c36bbcf0d2e83 100644 --- a/toolchain/check/testdata/function/definition/params_two_comma.carbon +++ b/toolchain/check/testdata/function/definition/params_two_comma.carbon @@ -21,17 +21,25 @@ fn Foo(a: i32, b: i32,) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/function/generic/deduce.carbon b/toolchain/check/testdata/function/generic/deduce.carbon new file mode 100644 index 0000000000000..b9f8699adb48a --- /dev/null +++ b/toolchain/check/testdata/function/generic/deduce.carbon @@ -0,0 +1,679 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/deduce.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/deduce.carbon + +// --- deduce_explicit.carbon + +library "deduce_explicit"; + +fn ExplicitGenericParam(T:! type) -> T*; + +fn CallExplicitGenericParam() -> i32* { + return ExplicitGenericParam(i32); +} + +fn CallExplicitGenericParamWithGenericArg(T:! type) -> {.a: T}* { + return ExplicitGenericParam({.a: T}); +} + +// --- fail_todo_explicit_vs_deduced.carbon + +library "fail_todo_explicit_vs_deduced"; + +class A {} + +fn ExplicitAndAlsoDeduced(T:! type, x: T) -> T*; + +// TODO: This should presumably be accepted. We shouldn't deduce values for parameters with explicitly-specified values. +fn CallExplicitAndAlsoDeduced(n: i32) -> i32* { + // CHECK:STDERR: fail_todo_explicit_vs_deduced.carbon:[[@LINE+7]]:10: ERROR: Inconsistent deductions for value of generic parameter `T`. + // CHECK:STDERR: return ExplicitAndAlsoDeduced(A, {}); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_todo_explicit_vs_deduced.carbon:[[@LINE-7]]:1: While deducing parameters of generic declared here. + // CHECK:STDERR: fn ExplicitAndAlsoDeduced(T:! type, x: T) -> T*; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + return ExplicitAndAlsoDeduced(A, {}); +} + +// --- fail_todo_deduce_implicit.carbon + +library "fail_todo_deduce_implicit"; + +fn ImplicitGenericParam[T:! type](x: T) -> T*; + +fn CallImplicitGenericParam(n: i32) -> i32* { + // CHECK:STDERR: fail_todo_deduce_implicit.carbon:[[@LINE+4]]:10: ERROR: Semantics TODO: `Call with implicit parameters`. + // CHECK:STDERR: return ImplicitGenericParam(n); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + return ImplicitGenericParam(n); +} + +// --- fail_todo_deduce_nested.carbon + +library "fail_todo_deduce_nested"; + +fn TupleParam[T:! type](x: (T, i32)); + +fn CallTupleParam() { + // CHECK:STDERR: fail_todo_deduce_nested.carbon:[[@LINE+7]]:3: ERROR: Cannot deduce value for generic parameter `T`. + // CHECK:STDERR: TupleParam((1, 2)); + // CHECK:STDERR: ^~~~~~~~~~~ + // CHECK:STDERR: fail_todo_deduce_nested.carbon:[[@LINE-6]]:1: While deducing parameters of generic declared here. + // CHECK:STDERR: fn TupleParam[T:! type](x: (T, i32)); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + TupleParam((1, 2)); +} + +fn StructParam[T:! type](x: {.a: T, .b: i32}); + +fn CallStructParam() { + // CHECK:STDERR: fail_todo_deduce_nested.carbon:[[@LINE+7]]:3: ERROR: Cannot deduce value for generic parameter `T`. + // CHECK:STDERR: StructParam({.a = 1, .b = 2}); + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: fail_todo_deduce_nested.carbon:[[@LINE-6]]:1: While deducing parameters of generic declared here. + // CHECK:STDERR: fn StructParam[T:! type](x: {.a: T, .b: i32}); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + StructParam({.a = 1, .b = 2}); +} + +// --- fail_deduce_incomplete.carbon + +library "fail_deduce_incomplete"; + +// TODO: It would be nice to diagnose this at its point of declaration, because +// U is not deducible. +fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U; + +fn CallImplicitNotDeducible() { + // CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE+7]]:3: ERROR: Cannot deduce value for generic parameter `U`. + // CHECK:STDERR: ImplicitNotDeducible(42); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE-6]]:1: While deducing parameters of generic declared here. + // CHECK:STDERR: fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + ImplicitNotDeducible(42); +} + +// --- fail_deduce_inconsistent.carbon + +library "fail_deduce_inconsistent"; + +fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T; + +fn CallImplicitNotDeducible() { + // CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE+6]]:3: ERROR: Inconsistent deductions for value of generic parameter `T`. + // CHECK:STDERR: ImplicitNotDeducible(42, {.x = 12}); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE-6]]:1: While deducing parameters of generic declared here. + // CHECK:STDERR: fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ImplicitNotDeducible(42, {.x = 12}); +} + +// CHECK:STDOUT: --- deduce_explicit.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %.1: type = ptr_type %T [symbolic] +// CHECK:STDOUT: %ExplicitGenericParam.type: type = fn_type @ExplicitGenericParam [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %ExplicitGenericParam: %ExplicitGenericParam.type = struct_value () [template] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type i32 [template] +// CHECK:STDOUT: %CallExplicitGenericParam.type: type = fn_type @CallExplicitGenericParam [template] +// CHECK:STDOUT: %CallExplicitGenericParam: %CallExplicitGenericParam.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = struct_type {.a: %T} [symbolic] +// CHECK:STDOUT: %.5: type = ptr_type %.4 [symbolic] +// CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg.type: type = fn_type @CallExplicitGenericParamWithGenericArg [template] +// CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg: %CallExplicitGenericParamWithGenericArg.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .ExplicitGenericParam = %ExplicitGenericParam.decl +// CHECK:STDOUT: .CallExplicitGenericParam = %CallExplicitGenericParam.decl +// CHECK:STDOUT: .CallExplicitGenericParamWithGenericArg = %CallExplicitGenericParamWithGenericArg.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %ExplicitGenericParam.decl: %ExplicitGenericParam.type = fn_decl @ExplicitGenericParam [template = constants.%ExplicitGenericParam] { +// CHECK:STDOUT: %T.loc4_25.1: type = param T +// CHECK:STDOUT: @ExplicitGenericParam.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_25.1 [symbolic = @ExplicitGenericParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, @ExplicitGenericParam.%T.loc4 [symbolic = @ExplicitGenericParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = @ExplicitGenericParam.%.1 (constants.%.1)] +// CHECK:STDOUT: @ExplicitGenericParam.%return: ref @ExplicitGenericParam.%.1 (%.1) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallExplicitGenericParam.decl: %CallExplicitGenericParam.type = fn_decl @CallExplicitGenericParam [template = constants.%CallExplicitGenericParam] { +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc6_37.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc6_37.2: type = converted %int.make_type_32, %.loc6_37.1 [template = i32] +// CHECK:STDOUT: %.loc6_37.3: type = ptr_type i32 [template = constants.%.3] +// CHECK:STDOUT: @CallExplicitGenericParam.%return: ref %.3 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg.decl: %CallExplicitGenericParamWithGenericArg.type = fn_decl @CallExplicitGenericParamWithGenericArg [template = constants.%CallExplicitGenericParamWithGenericArg] { +// CHECK:STDOUT: %T.loc10_43.1: type = param T +// CHECK:STDOUT: @CallExplicitGenericParamWithGenericArg.%T.loc10: type = bind_symbolic_name T 0, %T.loc10_43.1 [symbolic = @CallExplicitGenericParamWithGenericArg.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc10: type = name_ref T, @CallExplicitGenericParamWithGenericArg.%T.loc10 [symbolic = @CallExplicitGenericParamWithGenericArg.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc10_62: type = struct_type {.a: %T} [symbolic = @CallExplicitGenericParamWithGenericArg.%.1 (constants.%.4)] +// CHECK:STDOUT: %.loc10_63: type = ptr_type %.4 [symbolic = @CallExplicitGenericParamWithGenericArg.%.2 (constants.%.5)] +// CHECK:STDOUT: @CallExplicitGenericParamWithGenericArg.%return: ref @CallExplicitGenericParamWithGenericArg.%.2 (%.5) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @ExplicitGenericParam(%T.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = ptr_type @ExplicitGenericParam.%T.1 (%T) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc4: type) -> @ExplicitGenericParam.%.1 (%.1); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallExplicitGenericParam() -> %.3 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam] +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc7_30.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc7_30.2: type = converted %int.make_type_32, %.loc7_30.1 [template = i32] +// CHECK:STDOUT: %ExplicitGenericParam.call: init %.3 = call %ExplicitGenericParam.ref(%.loc7_30.2) +// CHECK:STDOUT: %.loc7_35.1: %.3 = value_of_initializer %ExplicitGenericParam.call +// CHECK:STDOUT: %.loc7_35.2: %.3 = converted %ExplicitGenericParam.call, %.loc7_35.1 +// CHECK:STDOUT: return %.loc7_35.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @CallExplicitGenericParamWithGenericArg(%T.loc10: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = struct_type {.a: @CallExplicitGenericParamWithGenericArg.%T.1 (%T)} [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: %.2: type = ptr_type @CallExplicitGenericParamWithGenericArg.%.1 (%.4) [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc10: type) -> @CallExplicitGenericParamWithGenericArg.%.2 (%.5) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc10 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc11_37: type = struct_type {.a: %T} [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: %ExplicitGenericParam.call: init @CallExplicitGenericParamWithGenericArg.%.2 (%.5) = call %ExplicitGenericParam.ref(%.loc11_37) +// CHECK:STDOUT: %.loc11_39.1: @CallExplicitGenericParamWithGenericArg.%.2 (%.5) = value_of_initializer %ExplicitGenericParam.call +// CHECK:STDOUT: %.loc11_39.2: @CallExplicitGenericParamWithGenericArg.%.2 (%.5) = converted %ExplicitGenericParam.call, %.loc11_39.1 +// CHECK:STDOUT: return %.loc11_39.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ExplicitGenericParam(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ExplicitGenericParam(i32) { +// CHECK:STDOUT: %T.1 => i32 +// CHECK:STDOUT: %.1 => constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CallExplicitGenericParamWithGenericArg(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.4 +// CHECK:STDOUT: %.2 => constants.%.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ExplicitGenericParam(constants.%.4) { +// CHECK:STDOUT: %T.1 => constants.%.4 +// CHECK:STDOUT: %.1 => constants.%.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_explicit_vs_deduced.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %A: type = class_type @A [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %.2: type = ptr_type %T [symbolic] +// CHECK:STDOUT: %ExplicitAndAlsoDeduced.type: type = fn_type @ExplicitAndAlsoDeduced [template] +// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %ExplicitAndAlsoDeduced: %ExplicitAndAlsoDeduced.type = struct_value () [template] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type i32 [template] +// CHECK:STDOUT: %CallExplicitAndAlsoDeduced.type: type = fn_type @CallExplicitAndAlsoDeduced [template] +// CHECK:STDOUT: %CallExplicitAndAlsoDeduced: %CallExplicitAndAlsoDeduced.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: .ExplicitAndAlsoDeduced = %ExplicitAndAlsoDeduced.decl +// CHECK:STDOUT: .CallExplicitAndAlsoDeduced = %CallExplicitAndAlsoDeduced.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} +// CHECK:STDOUT: %ExplicitAndAlsoDeduced.decl: %ExplicitAndAlsoDeduced.type = fn_decl @ExplicitAndAlsoDeduced [template = constants.%ExplicitAndAlsoDeduced] { +// CHECK:STDOUT: %T.loc6_27.1: type = param T +// CHECK:STDOUT: @ExplicitAndAlsoDeduced.%T.loc6: type = bind_symbolic_name T 0, %T.loc6_27.1 [symbolic = @ExplicitAndAlsoDeduced.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc6_40: type = name_ref T, @ExplicitAndAlsoDeduced.%T.loc6 [symbolic = @ExplicitAndAlsoDeduced.%T.1 (constants.%T)] +// CHECK:STDOUT: %x.loc6_37.1: @ExplicitAndAlsoDeduced.%T.1 (%T) = param x +// CHECK:STDOUT: @ExplicitAndAlsoDeduced.%x: @ExplicitAndAlsoDeduced.%T.1 (%T) = bind_name x, %x.loc6_37.1 +// CHECK:STDOUT: %T.ref.loc6_46: type = name_ref T, @ExplicitAndAlsoDeduced.%T.loc6 [symbolic = @ExplicitAndAlsoDeduced.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc6: type = ptr_type %T [symbolic = @ExplicitAndAlsoDeduced.%.1 (constants.%.2)] +// CHECK:STDOUT: @ExplicitAndAlsoDeduced.%return: ref @ExplicitAndAlsoDeduced.%.1 (%.2) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallExplicitAndAlsoDeduced.decl: %CallExplicitAndAlsoDeduced.type = fn_decl @CallExplicitAndAlsoDeduced [template = constants.%CallExplicitAndAlsoDeduced] { +// CHECK:STDOUT: %int.make_type_32.loc9_34: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc9_34.1: type = value_of_initializer %int.make_type_32.loc9_34 [template = i32] +// CHECK:STDOUT: %.loc9_34.2: type = converted %int.make_type_32.loc9_34, %.loc9_34.1 [template = i32] +// CHECK:STDOUT: %n.loc9_31.1: i32 = param n +// CHECK:STDOUT: @CallExplicitAndAlsoDeduced.%n: i32 = bind_name n, %n.loc9_31.1 +// CHECK:STDOUT: %int.make_type_32.loc9_42: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc9_45.1: type = value_of_initializer %int.make_type_32.loc9_42 [template = i32] +// CHECK:STDOUT: %.loc9_45.2: type = converted %int.make_type_32.loc9_42, %.loc9_45.1 [template = i32] +// CHECK:STDOUT: %.loc9_45.3: type = ptr_type i32 [template = constants.%.4] +// CHECK:STDOUT: @CallExplicitAndAlsoDeduced.%return: ref %.4 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @A { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%A +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @ExplicitAndAlsoDeduced(%T.loc6: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = ptr_type @ExplicitAndAlsoDeduced.%T.1 (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc6: type, %x: @ExplicitAndAlsoDeduced.%T.1 (%T)) -> @ExplicitAndAlsoDeduced.%.1 (%.2); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallExplicitAndAlsoDeduced(%n: i32) -> %.4 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ExplicitAndAlsoDeduced.ref: %ExplicitAndAlsoDeduced.type = name_ref ExplicitAndAlsoDeduced, file.%ExplicitAndAlsoDeduced.decl [template = constants.%ExplicitAndAlsoDeduced] +// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %.loc17: %.1 = struct_literal () +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ExplicitAndAlsoDeduced(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_deduce_implicit.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %.1: type = ptr_type %T [symbolic] +// CHECK:STDOUT: %ImplicitGenericParam.type: type = fn_type @ImplicitGenericParam [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %ImplicitGenericParam: %ImplicitGenericParam.type = struct_value () [template] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type i32 [template] +// CHECK:STDOUT: %CallImplicitGenericParam.type: type = fn_type @CallImplicitGenericParam [template] +// CHECK:STDOUT: %CallImplicitGenericParam: %CallImplicitGenericParam.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .ImplicitGenericParam = %ImplicitGenericParam.decl +// CHECK:STDOUT: .CallImplicitGenericParam = %CallImplicitGenericParam.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %ImplicitGenericParam.decl: %ImplicitGenericParam.type = fn_decl @ImplicitGenericParam [template = constants.%ImplicitGenericParam] { +// CHECK:STDOUT: %T.loc4_25.1: type = param T +// CHECK:STDOUT: @ImplicitGenericParam.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_25.1 [symbolic = @ImplicitGenericParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, @ImplicitGenericParam.%T.loc4 [symbolic = @ImplicitGenericParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %x.loc4_35.1: @ImplicitGenericParam.%T.1 (%T) = param x +// CHECK:STDOUT: @ImplicitGenericParam.%x: @ImplicitGenericParam.%T.1 (%T) = bind_name x, %x.loc4_35.1 +// CHECK:STDOUT: %T.ref.loc4_44: type = name_ref T, @ImplicitGenericParam.%T.loc4 [symbolic = @ImplicitGenericParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = @ImplicitGenericParam.%.1 (constants.%.1)] +// CHECK:STDOUT: @ImplicitGenericParam.%return: ref @ImplicitGenericParam.%.1 (%.1) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallImplicitGenericParam.decl: %CallImplicitGenericParam.type = fn_decl @CallImplicitGenericParam [template = constants.%CallImplicitGenericParam] { +// CHECK:STDOUT: %int.make_type_32.loc6_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc6_32.1: type = value_of_initializer %int.make_type_32.loc6_32 [template = i32] +// CHECK:STDOUT: %.loc6_32.2: type = converted %int.make_type_32.loc6_32, %.loc6_32.1 [template = i32] +// CHECK:STDOUT: %n.loc6_29.1: i32 = param n +// CHECK:STDOUT: @CallImplicitGenericParam.%n: i32 = bind_name n, %n.loc6_29.1 +// CHECK:STDOUT: %int.make_type_32.loc6_40: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc6_43.1: type = value_of_initializer %int.make_type_32.loc6_40 [template = i32] +// CHECK:STDOUT: %.loc6_43.2: type = converted %int.make_type_32.loc6_40, %.loc6_43.1 [template = i32] +// CHECK:STDOUT: %.loc6_43.3: type = ptr_type i32 [template = constants.%.3] +// CHECK:STDOUT: @CallImplicitGenericParam.%return: ref %.3 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @ImplicitGenericParam(%T.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = ptr_type @ImplicitGenericParam.%T.1 (%T) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%T.loc4: type](%x: @ImplicitGenericParam.%T.1 (%T)) -> @ImplicitGenericParam.%.1 (%.1); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallImplicitGenericParam(%n: i32) -> %.3 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ImplicitGenericParam.ref: %ImplicitGenericParam.type = name_ref ImplicitGenericParam, file.%ImplicitGenericParam.decl [template = constants.%ImplicitGenericParam] +// CHECK:STDOUT: %n.ref: i32 = name_ref n, %n +// CHECK:STDOUT: %ImplicitGenericParam.call: init %.3 = call %ImplicitGenericParam.ref() [template = ] +// CHECK:STDOUT: %.loc11_33.1: %.3 = value_of_initializer %ImplicitGenericParam.call [template = ] +// CHECK:STDOUT: %.loc11_33.2: %.3 = converted %ImplicitGenericParam.call, %.loc11_33.1 [template = ] +// CHECK:STDOUT: return %.loc11_33.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitGenericParam(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitGenericParam(i32) { +// CHECK:STDOUT: %T.1 => i32 +// CHECK:STDOUT: %.1 => constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_deduce_nested.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.2: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %.3: type = tuple_type (%T, i32) [symbolic] +// CHECK:STDOUT: %TupleParam.type: type = fn_type @TupleParam [template] +// CHECK:STDOUT: %TupleParam: %TupleParam.type = struct_value () [template] +// CHECK:STDOUT: %CallTupleParam.type: type = fn_type @CallTupleParam [template] +// CHECK:STDOUT: %CallTupleParam: %CallTupleParam.type = struct_value () [template] +// CHECK:STDOUT: %.4: i32 = int_literal 1 [template] +// CHECK:STDOUT: %.5: i32 = int_literal 2 [template] +// CHECK:STDOUT: %.6: type = tuple_type (i32, i32) [template] +// CHECK:STDOUT: %.7: type = struct_type {.a: %T, .b: i32} [symbolic] +// CHECK:STDOUT: %StructParam.type: type = fn_type @StructParam [template] +// CHECK:STDOUT: %StructParam: %StructParam.type = struct_value () [template] +// CHECK:STDOUT: %CallStructParam.type: type = fn_type @CallStructParam [template] +// CHECK:STDOUT: %CallStructParam: %CallStructParam.type = struct_value () [template] +// CHECK:STDOUT: %.8: type = struct_type {.a: i32, .b: i32} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .TupleParam = %TupleParam.decl +// CHECK:STDOUT: .CallTupleParam = %CallTupleParam.decl +// CHECK:STDOUT: .StructParam = %StructParam.decl +// CHECK:STDOUT: .CallStructParam = %CallStructParam.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %TupleParam.decl: %TupleParam.type = fn_decl @TupleParam [template = constants.%TupleParam] { +// CHECK:STDOUT: %T.loc4_15.1: type = param T +// CHECK:STDOUT: @TupleParam.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = @TupleParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, @TupleParam.%T.loc4 [symbolic = @TupleParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc4_35.1: %.2 = tuple_literal (%T.ref.loc4, %int.make_type_32.loc4) +// CHECK:STDOUT: %.loc4_35.2: type = value_of_initializer %int.make_type_32.loc4 [template = i32] +// CHECK:STDOUT: %.loc4_35.3: type = converted %int.make_type_32.loc4, %.loc4_35.2 [template = i32] +// CHECK:STDOUT: %.loc4_35.4: type = converted %.loc4_35.1, constants.%.3 [symbolic = @TupleParam.%.1 (constants.%.3)] +// CHECK:STDOUT: %x.loc4_25.1: @TupleParam.%.1 (%.3) = param x +// CHECK:STDOUT: @TupleParam.%x: @TupleParam.%.1 (%.3) = bind_name x, %x.loc4_25.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallTupleParam.decl: %CallTupleParam.type = fn_decl @CallTupleParam [template = constants.%CallTupleParam] {} +// CHECK:STDOUT: %StructParam.decl: %StructParam.type = fn_decl @StructParam [template = constants.%StructParam] { +// CHECK:STDOUT: %T.loc17_16.1: type = param T +// CHECK:STDOUT: @StructParam.%T.loc17: type = bind_symbolic_name T 0, %T.loc17_16.1 [symbolic = @StructParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc17: type = name_ref T, @StructParam.%T.loc17 [symbolic = @StructParam.%T.1 (constants.%T)] +// CHECK:STDOUT: %int.make_type_32.loc17: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc17_41.1: type = value_of_initializer %int.make_type_32.loc17 [template = i32] +// CHECK:STDOUT: %.loc17_41.2: type = converted %int.make_type_32.loc17, %.loc17_41.1 [template = i32] +// CHECK:STDOUT: %.loc17_44: type = struct_type {.a: %T, .b: i32} [symbolic = @StructParam.%.1 (constants.%.7)] +// CHECK:STDOUT: %x.loc17_26.1: @StructParam.%.1 (%.7) = param x +// CHECK:STDOUT: @StructParam.%x: @StructParam.%.1 (%.7) = bind_name x, %x.loc17_26.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallStructParam.decl: %CallStructParam.type = fn_decl @CallStructParam [template = constants.%CallStructParam] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @TupleParam(%T.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = tuple_type (@TupleParam.%T.1 (%T), i32) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%T.loc4: type](%x: @TupleParam.%.1 (%.3)); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallTupleParam() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %TupleParam.ref: %TupleParam.type = name_ref TupleParam, file.%TupleParam.decl [template = constants.%TupleParam] +// CHECK:STDOUT: %.loc14_15: i32 = int_literal 1 [template = constants.%.4] +// CHECK:STDOUT: %.loc14_18: i32 = int_literal 2 [template = constants.%.5] +// CHECK:STDOUT: %.loc14_19: %.6 = tuple_literal (%.loc14_15, %.loc14_18) +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @StructParam(%T.loc17: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = struct_type {.a: @StructParam.%T.1 (%T), .b: i32} [symbolic = %.1 (constants.%.7)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%T.loc17: type](%x: @StructParam.%.1 (%.7)); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallStructParam() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %StructParam.ref: %StructParam.type = name_ref StructParam, file.%StructParam.decl [template = constants.%StructParam] +// CHECK:STDOUT: %.loc27_21: i32 = int_literal 1 [template = constants.%.4] +// CHECK:STDOUT: %.loc27_29: i32 = int_literal 2 [template = constants.%.5] +// CHECK:STDOUT: %.loc27_30: %.8 = struct_literal (%.loc27_21, %.loc27_29) +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @TupleParam(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @StructParam(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.7 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_deduce_incomplete.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic] +// CHECK:STDOUT: %ImplicitNotDeducible.type: type = fn_type @ImplicitNotDeducible [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %ImplicitNotDeducible: %ImplicitNotDeducible.type = struct_value () [template] +// CHECK:STDOUT: %CallImplicitNotDeducible.type: type = fn_type @CallImplicitNotDeducible [template] +// CHECK:STDOUT: %CallImplicitNotDeducible: %CallImplicitNotDeducible.type = struct_value () [template] +// CHECK:STDOUT: %.2: i32 = int_literal 42 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .ImplicitNotDeducible = %ImplicitNotDeducible.decl +// CHECK:STDOUT: .CallImplicitNotDeducible = %CallImplicitNotDeducible.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %ImplicitNotDeducible.decl: %ImplicitNotDeducible.type = fn_decl @ImplicitNotDeducible [template = constants.%ImplicitNotDeducible] { +// CHECK:STDOUT: %T.loc6_25.1: type = param T +// CHECK:STDOUT: @ImplicitNotDeducible.%T.loc6: type = bind_symbolic_name T 0, %T.loc6_25.1 [symbolic = @ImplicitNotDeducible.%T.1 (constants.%T)] +// CHECK:STDOUT: %U.loc6_35.1: type = param U +// CHECK:STDOUT: @ImplicitNotDeducible.%U.loc6: type = bind_symbolic_name U 1, %U.loc6_35.1 [symbolic = @ImplicitNotDeducible.%U.1 (constants.%U)] +// CHECK:STDOUT: %T.ref: type = name_ref T, @ImplicitNotDeducible.%T.loc6 [symbolic = @ImplicitNotDeducible.%T.1 (constants.%T)] +// CHECK:STDOUT: %x.loc6_45.1: @ImplicitNotDeducible.%T.1 (%T) = param x +// CHECK:STDOUT: @ImplicitNotDeducible.%x: @ImplicitNotDeducible.%T.1 (%T) = bind_name x, %x.loc6_45.1 +// CHECK:STDOUT: %U.ref: type = name_ref U, @ImplicitNotDeducible.%U.loc6 [symbolic = @ImplicitNotDeducible.%U.1 (constants.%U)] +// CHECK:STDOUT: @ImplicitNotDeducible.%return: ref @ImplicitNotDeducible.%U.1 (%U) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallImplicitNotDeducible.decl: %CallImplicitNotDeducible.type = fn_decl @CallImplicitNotDeducible [template = constants.%CallImplicitNotDeducible] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @ImplicitNotDeducible(%T.loc6: type, %U.loc6: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%T.loc6: type, %U.loc6: type](%x: @ImplicitNotDeducible.%T.1 (%T)) -> @ImplicitNotDeducible.%U.1 (%U); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallImplicitNotDeducible() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ImplicitNotDeducible.ref: %ImplicitNotDeducible.type = name_ref ImplicitNotDeducible, file.%ImplicitNotDeducible.decl [template = constants.%ImplicitNotDeducible] +// CHECK:STDOUT: %.loc16: i32 = int_literal 42 [template = constants.%.2] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitNotDeducible(constants.%T, constants.%U) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %U.1 => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_deduce_inconsistent.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %ImplicitNotDeducible.type: type = fn_type @ImplicitNotDeducible [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %ImplicitNotDeducible: %ImplicitNotDeducible.type = struct_value () [template] +// CHECK:STDOUT: %CallImplicitNotDeducible.type: type = fn_type @CallImplicitNotDeducible [template] +// CHECK:STDOUT: %CallImplicitNotDeducible: %CallImplicitNotDeducible.type = struct_value () [template] +// CHECK:STDOUT: %.2: i32 = int_literal 42 [template] +// CHECK:STDOUT: %.3: i32 = int_literal 12 [template] +// CHECK:STDOUT: %.4: type = struct_type {.x: i32} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .ImplicitNotDeducible = %ImplicitNotDeducible.decl +// CHECK:STDOUT: .CallImplicitNotDeducible = %CallImplicitNotDeducible.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %ImplicitNotDeducible.decl: %ImplicitNotDeducible.type = fn_decl @ImplicitNotDeducible [template = constants.%ImplicitNotDeducible] { +// CHECK:STDOUT: %T.loc4_25.1: type = param T +// CHECK:STDOUT: @ImplicitNotDeducible.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_25.1 [symbolic = @ImplicitNotDeducible.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, @ImplicitNotDeducible.%T.loc4 [symbolic = @ImplicitNotDeducible.%T.1 (constants.%T)] +// CHECK:STDOUT: %x.loc4_35.1: @ImplicitNotDeducible.%T.1 (%T) = param x +// CHECK:STDOUT: @ImplicitNotDeducible.%x: @ImplicitNotDeducible.%T.1 (%T) = bind_name x, %x.loc4_35.1 +// CHECK:STDOUT: %T.ref.loc4_44: type = name_ref T, @ImplicitNotDeducible.%T.loc4 [symbolic = @ImplicitNotDeducible.%T.1 (constants.%T)] +// CHECK:STDOUT: %y.loc4_41.1: @ImplicitNotDeducible.%T.1 (%T) = param y +// CHECK:STDOUT: @ImplicitNotDeducible.%y: @ImplicitNotDeducible.%T.1 (%T) = bind_name y, %y.loc4_41.1 +// CHECK:STDOUT: %T.ref.loc4_50: type = name_ref T, @ImplicitNotDeducible.%T.loc4 [symbolic = @ImplicitNotDeducible.%T.1 (constants.%T)] +// CHECK:STDOUT: @ImplicitNotDeducible.%return: ref @ImplicitNotDeducible.%T.1 (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %CallImplicitNotDeducible.decl: %CallImplicitNotDeducible.type = fn_decl @CallImplicitNotDeducible [template = constants.%CallImplicitNotDeducible] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @ImplicitNotDeducible(%T.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%T.loc4: type](%x: @ImplicitNotDeducible.%T.1 (%T), %y: @ImplicitNotDeducible.%T.1 (%T)) -> @ImplicitNotDeducible.%T.1 (%T); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallImplicitNotDeducible() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ImplicitNotDeducible.ref: %ImplicitNotDeducible.type = name_ref ImplicitNotDeducible, file.%ImplicitNotDeducible.decl [template = constants.%ImplicitNotDeducible] +// CHECK:STDOUT: %.loc13_24: i32 = int_literal 42 [template = constants.%.2] +// CHECK:STDOUT: %.loc13_34: i32 = int_literal 12 [template = constants.%.3] +// CHECK:STDOUT: %.loc13_36: %.4 = struct_literal (%.loc13_34) +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitNotDeducible(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon b/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon index 40ec90f4b23ad..7cdc7b1ac6661 100644 --- a/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon +++ b/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon @@ -25,25 +25,33 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc14_10: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_10.1: type = value_of_initializer %int.make_type_32.loc14_10 [template = i32] // CHECK:STDOUT: %.loc14_10.2: type = converted %int.make_type_32.loc14_10, %.loc14_10.1 [template = i32] // CHECK:STDOUT: %N.loc14_6.1: i32 = param N -// CHECK:STDOUT: @F.%N: i32 = bind_symbolic_name N 0, %N.loc14_6.1 [symbolic = @F.%N (constants.%N)] +// CHECK:STDOUT: @F.%N.loc14: i32 = bind_symbolic_name N 0, %N.loc14_6.1 [symbolic = @F.%N.1 (constants.%N)] // CHECK:STDOUT: %int.make_type_32.loc14_19: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %N.ref: i32 = name_ref N, @F.%N [symbolic = @F.%N (constants.%N)] +// CHECK:STDOUT: %N.ref: i32 = name_ref N, @F.%N.loc14 [symbolic = @F.%N.1 (constants.%N)] // CHECK:STDOUT: %.loc14_19.1: type = value_of_initializer %int.make_type_32.loc14_19 [template = i32] // CHECK:STDOUT: %.loc14_19.2: type = converted %int.make_type_32.loc14_19, %.loc14_19.1 [template = i32] // CHECK:STDOUT: %.loc14_25: type = array_type %N.ref, i32 [template = ] @@ -55,6 +63,13 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%N: i32, %a: ) -// CHECK:STDOUT: generic [%N: i32]; +// CHECK:STDOUT: generic fn @F(%N.loc14: i32) { +// CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic = %N.1 (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%N.loc14: i32, %a: ); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%N) { +// CHECK:STDOUT: %N.1 => constants.%N +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon index 7f074834f6d83..aedc94c9e4c73 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon @@ -33,24 +33,36 @@ fn F(T:! type, U:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: @F.%T.loc11: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T.1 (constants.%T)] // CHECK:STDOUT: %U.loc11_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc11_16.1 [symbolic = @F.%U (constants.%U)] +// CHECK:STDOUT: @F.%U.loc11: type = bind_symbolic_name U 1, %U.loc11_16.1 [symbolic = @F.%U.1 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %U: type) -// CHECK:STDOUT: generic [%T: type, %U: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = constants.%.2] -// CHECK:STDOUT: %p.var: ref %.2 = var p -// CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var -// CHECK:STDOUT: %U.ref: type = name_ref U, %U [symbolic = constants.%U] -// CHECK:STDOUT: %p.ref: ref %.2 = name_ref p, %p -// CHECK:STDOUT: %.loc16_15: %.2 = bind_value %p.ref -// CHECK:STDOUT: %.loc16_14: ref %T = deref %.loc16_15 -// CHECK:STDOUT: %n: %U = bind_name n, -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F(%T.loc11: type, %U.loc11: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc11: type, %U.loc11: type) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %p.var: ref @F.%.1 (%.2) = var p +// CHECK:STDOUT: %p: ref @F.%.1 (%.2) = bind_name p, %p.var +// CHECK:STDOUT: %U.ref: type = name_ref U, %U.loc11 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: %p.ref: ref @F.%.1 (%.2) = name_ref p, %p +// CHECK:STDOUT: %.loc16_15: @F.%.1 (%.2) = bind_value %p.ref +// CHECK:STDOUT: %.loc16_14: ref @F.%T.1 (%T) = deref %.loc16_15 +// CHECK:STDOUT: %n: @F.%U.1 (%U) = bind_name n, +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T, constants.%U) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %U.1 => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/forward_decl.carbon b/toolchain/check/testdata/function/generic/no_prelude/forward_decl.carbon new file mode 100644 index 0000000000000..c8ea4608f2563 --- /dev/null +++ b/toolchain/check/testdata/function/generic/no_prelude/forward_decl.carbon @@ -0,0 +1,41 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/no_prelude/forward_decl.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/no_prelude/forward_decl.carbon + +fn F(T:! type); + +// CHECK:STDOUT: --- forward_decl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %T.loc11_6.1: type = param T +// CHECK:STDOUT: @F.%T.loc11: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(%T.loc11: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc11: type); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon b/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon index 30b9b910b3f79..b0981e84e9219 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon @@ -29,24 +29,37 @@ fn F(T:! type, p: T**) -> T* { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: %.loc11_20: type = ptr_type %T [symbolic = %.loc11_20 (constants.%.1)] -// CHECK:STDOUT: %.loc11_21: type = ptr_type %.1 [symbolic = %.loc11_21 (constants.%.2)] -// CHECK:STDOUT: %p.loc11_16.1: file.%.loc11_21 (%.2) = param p -// CHECK:STDOUT: @F.%p: file.%.loc11_21 (%.2) = bind_name p, %p.loc11_16.1 -// CHECK:STDOUT: %T.ref.loc11_27: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: %.loc11_28: type = ptr_type %T [symbolic = %.loc11_20 (constants.%.1)] -// CHECK:STDOUT: @F.%return: ref %.1 = var +// CHECK:STDOUT: @F.%T.loc11: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T.loc11 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc11_20: type = ptr_type %T [symbolic = @F.%.1 (constants.%.1)] +// CHECK:STDOUT: %.loc11_21: type = ptr_type %.1 [symbolic = @F.%.2 (constants.%.2)] +// CHECK:STDOUT: %p.loc11_16.1: @F.%.2 (%.2) = param p +// CHECK:STDOUT: @F.%p: @F.%.2 (%.2) = bind_name p, %p.loc11_16.1 +// CHECK:STDOUT: %T.ref.loc11_27: type = name_ref T, @F.%T.loc11 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc11_28: type = ptr_type %T [symbolic = @F.%.1 (constants.%.1)] +// CHECK:STDOUT: @F.%return: ref @F.%.1 (%.1) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %p: file.%.loc11_21 (%.2)) -> %.1 -// CHECK:STDOUT: generic [%T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %p.ref: %.2 = name_ref p, %p -// CHECK:STDOUT: %.loc12_10.1: ref %.1 = deref %p.ref -// CHECK:STDOUT: %.loc12_10.2: %.1 = bind_value %.loc12_10.1 -// CHECK:STDOUT: return %.loc12_10.2 +// CHECK:STDOUT: generic fn @F(%T.loc11: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: %.2: type = ptr_type @F.%.1 (%.1) [symbolic = %.2 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc11: type, %p: @F.%.2 (%.2)) -> @F.%.1 (%.1) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %p.ref: @F.%.2 (%.2) = name_ref p, %p +// CHECK:STDOUT: %.loc12_10.1: ref @F.%.1 (%.1) = deref %p.ref +// CHECK:STDOUT: %.loc12_10.2: @F.%.1 (%.1) = bind_value %.loc12_10.1 +// CHECK:STDOUT: return %.loc12_10.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.1 +// CHECK:STDOUT: %.2 => constants.%.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon index a2866b32e01ca..56d005540bdc5 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon @@ -29,23 +29,33 @@ fn F(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: @F.%T.loc11: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T.1 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type) -// CHECK:STDOUT: generic [%T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = constants.%.2] -// CHECK:STDOUT: %p.var: ref %.2 = var p -// CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %p.ref: ref %.2 = name_ref p, %p -// CHECK:STDOUT: %.loc13_15: %.2 = bind_value %p.ref -// CHECK:STDOUT: %.loc13_14.1: ref %T = deref %.loc13_15 -// CHECK:STDOUT: %.loc13_14.2: %T = bind_value %.loc13_14.1 -// CHECK:STDOUT: %n: %T = bind_name n, %.loc13_14.2 -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F(%T.loc11: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc11: type) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, %T.loc11 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %p.var: ref @F.%.1 (%.2) = var p +// CHECK:STDOUT: %p: ref @F.%.1 (%.2) = bind_name p, %p.var +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T.loc11 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %p.ref: ref @F.%.1 (%.2) = name_ref p, %p +// CHECK:STDOUT: %.loc13_15: @F.%.1 (%.2) = bind_value %p.ref +// CHECK:STDOUT: %.loc13_14.1: ref @F.%T.1 (%T) = deref %.loc13_15 +// CHECK:STDOUT: %.loc13_14.2: @F.%T.1 (%T) = bind_value %.loc13_14.1 +// CHECK:STDOUT: %n: @F.%T.1 (%T) = bind_name n, %.loc13_14.2 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon index 493a397f9f87c..9980f745deb4a 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon @@ -28,22 +28,31 @@ fn F(T:! type, n: T) -> T { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: %n.loc11_16.1: @F.%T (%T) = param n -// CHECK:STDOUT: @F.%n: @F.%T (%T) = bind_name n, %n.loc11_16.1 -// CHECK:STDOUT: %T.ref.loc11_25: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: @F.%return: ref %T = var +// CHECK:STDOUT: @F.%T.loc11: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T.loc11 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %n.loc11_16.1: @F.%T.1 (%T) = param n +// CHECK:STDOUT: @F.%n: @F.%T.1 (%T) = bind_name n, %n.loc11_16.1 +// CHECK:STDOUT: %T.ref.loc11_25: type = name_ref T, @F.%T.loc11 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: @F.%return: ref @F.%T.1 (%T) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %n: @F.%T (%T)) -> %T -// CHECK:STDOUT: generic [%T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %n.ref: %T = name_ref n, %n -// CHECK:STDOUT: %m: %T = bind_name m, %n.ref -// CHECK:STDOUT: %m.ref: %T = name_ref m, %m -// CHECK:STDOUT: return %m.ref +// CHECK:STDOUT: generic fn @F(%T.loc11: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc11: type, %n: @F.%T.1 (%T)) -> @F.%T.1 (%T) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %n.ref: @F.%T.1 (%T) = name_ref n, %n +// CHECK:STDOUT: %m: @F.%T.1 (%T) = bind_name m, %n.ref +// CHECK:STDOUT: %m.ref: @F.%T.1 (%T) = name_ref m, %m +// CHECK:STDOUT: return %m.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/redeclare.carbon b/toolchain/check/testdata/function/generic/redeclare.carbon index afe5077bd0431..25abe7e459563 100644 --- a/toolchain/check/testdata/function/generic/redeclare.carbon +++ b/toolchain/check/testdata/function/generic/redeclare.carbon @@ -32,14 +32,12 @@ fn F(T:! type, U:! type) -> T*; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fn F(T:! type, U:! type) -> U* { - // CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+11]]:3: ERROR: Cannot implicitly convert from `T*` to `U*`. - // CHECK:STDERR: return F(T); - // CHECK:STDERR: ^~~~~~~~~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:10: ERROR: 1 argument(s) passed to function expecting 2 argument(s). + // TODO: This diagnostic is not very good. We should check the arity in a + // function call before, or as part of, deduction. + // CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:10: ERROR: Cannot deduce value for generic parameter `T`. // CHECK:STDERR: return F(T); // CHECK:STDERR: ^~ - // CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-17]]:1: Calling function declared here. + // CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-15]]:1: While deducing parameters of generic declared here. // CHECK:STDERR: fn F(T:! type, U:! type) -> T*; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: @@ -60,14 +58,10 @@ fn F(T:! type, U:! type) -> T*; // CHECK:STDERR: ^ // CHECK:STDERR: fn F(U:! type, T:! type) -> T* { - // CHECK:STDERR: fail_reorder.carbon:[[@LINE+11]]:3: ERROR: Cannot implicitly convert from `T*` to `T*`. - // CHECK:STDERR: return F(T); - // CHECK:STDERR: ^~~~~~~~~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:10: ERROR: 1 argument(s) passed to function expecting 2 argument(s). + // CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:10: ERROR: Cannot deduce value for generic parameter `T`. // CHECK:STDERR: return F(T); // CHECK:STDERR: ^~ - // CHECK:STDERR: fail_reorder.carbon:[[@LINE-17]]:1: Calling function declared here. + // CHECK:STDERR: fail_reorder.carbon:[[@LINE-13]]:1: While deducing parameters of generic declared here. // CHECK:STDERR: fn F(T:! type, U:! type) -> T*; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: @@ -88,14 +82,10 @@ fn F(T:! type, U:! type) -> T*; // CHECK:STDERR: ^ // CHECK:STDERR: fn F(U:! type, T:! type) -> U* { - // CHECK:STDERR: fail_rename.carbon:[[@LINE+10]]:3: ERROR: Cannot implicitly convert from `T*` to `U*`. - // CHECK:STDERR: return F(T); - // CHECK:STDERR: ^~~~~~~~~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_rename.carbon:[[@LINE+6]]:10: ERROR: 1 argument(s) passed to function expecting 2 argument(s). + // CHECK:STDERR: fail_rename.carbon:[[@LINE+6]]:10: ERROR: Cannot deduce value for generic parameter `T`. // CHECK:STDERR: return F(T); // CHECK:STDERR: ^~ - // CHECK:STDERR: fail_rename.carbon:[[@LINE-17]]:1: Calling function declared here. + // CHECK:STDERR: fail_rename.carbon:[[@LINE-13]]:1: While deducing parameters of generic declared here. // CHECK:STDERR: fn F(T:! type, U:! type) -> T*; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return F(T); @@ -111,38 +101,60 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl.loc4: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: %T.loc4_6.2: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = %T.loc4_6.2 (constants.%T)] -// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, %T.loc4_6.2 [symbolic = %T.loc4_6.2 (constants.%T)] -// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = %.loc4 (constants.%.1)] -// CHECK:STDOUT: %return.var.loc4: ref %.1 = var +// CHECK:STDOUT: %T.loc4_6.2: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, %T.loc4_6.2 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = @F.%.1 (constants.%.1)] +// CHECK:STDOUT: %return.var.loc4: ref @F.%.1 (%.1) = var // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl.loc6: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc6_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc6_6.1 [symbolic = constants.%T] -// CHECK:STDOUT: %T.ref.loc6: type = name_ref T, @F.%T [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T.loc6: type = bind_symbolic_name T 0, %T.loc6_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.ref.loc6: type = name_ref T, @F.%T.loc6 [symbolic = constants.%T] // CHECK:STDOUT: %.loc6: type = ptr_type %T [symbolic = constants.%.1] // CHECK:STDOUT: @F.%return: ref %.1 = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type) -> %.1 -// CHECK:STDOUT: generic [file.%T.loc4_6.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl.loc4 [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref(%T.ref) -// CHECK:STDOUT: %.loc7_14.1: %.1 = value_of_initializer %F.call -// CHECK:STDOUT: %.loc7_14.2: %.1 = converted %F.call, %.loc7_14.1 -// CHECK:STDOUT: return %.loc7_14.2 +// CHECK:STDOUT: generic fn @F(file.%T.loc4_6.2: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc6: type) -> %.1 { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl.loc4 [template = constants.%F] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %F.call: init @F.%.1 (%.1) = call %F.ref(%T.ref) +// CHECK:STDOUT: %.loc7_14.1: @F.%.1 (%.1) = value_of_initializer %F.call +// CHECK:STDOUT: %.loc7_14.2: @F.%.1 (%.1) = converted %F.call, %.loc7_14.1 +// CHECK:STDOUT: return %.loc7_14.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %.1 => constants.%.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_different_return_type.carbon @@ -159,43 +171,77 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %.4: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: @F.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T.1 (constants.%T)] // CHECK:STDOUT: %U.loc4_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U (constants.%U)] -// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] -// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = %.loc4 (constants.%.1)] -// CHECK:STDOUT: @F.%return: ref %.1 = var +// CHECK:STDOUT: @F.%U.loc4: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U.1 (constants.%U)] +// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T.loc4 [symbolic = @F.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = @F.%.1 (constants.%.1)] +// CHECK:STDOUT: @F.%return: ref @F.%.1 (%.1) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %T.loc13_6.1: type = param T -// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = @.1.%T (constants.%T)] +// CHECK:STDOUT: @.1.%T.loc13: type = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = @.1.%T.1 (constants.%T)] // CHECK:STDOUT: %U.loc13_16.1: type = param U -// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 1, %U.loc13_16.1 [symbolic = @.1.%U (constants.%U)] -// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U [symbolic = @.1.%U (constants.%U)] -// CHECK:STDOUT: %.loc13: type = ptr_type %U [symbolic = %.loc13 (constants.%.3)] -// CHECK:STDOUT: @.1.%return: ref %.3 = var +// CHECK:STDOUT: @.1.%U.loc13: type = bind_symbolic_name U 1, %U.loc13_16.1 [symbolic = @.1.%U.1 (constants.%U)] +// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U.loc13 [symbolic = @.1.%U.1 (constants.%U)] +// CHECK:STDOUT: %.loc13: type = ptr_type %U [symbolic = @.1.%.1 (constants.%.3)] +// CHECK:STDOUT: @.1.%return: ref @.1.%.1 (%.3) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %U: type) -> %.1 -// CHECK:STDOUT: generic [%T: type, %U: type]; +// CHECK:STDOUT: generic fn @F(%T.loc4: type, %U.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc4: type, %U.loc4: type) -> @F.%.1 (%.1); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(%T.loc13: type, %U.loc13: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: %.1: type = ptr_type @.1.%U.1 (%U) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc13: type, %U.loc13: type) -> @.1.%.1 (%.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc13 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T, constants.%U) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %U.1 => constants.%U +// CHECK:STDOUT: %.1 => constants.%.1 +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1(%T: type, %U: type) -> %.3 -// CHECK:STDOUT: generic [%T: type, %U: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @.1(constants.%T, constants.%U) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: %U.1 => constants.%U +// CHECK:STDOUT: %.1 => constants.%.3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_reorder.carbon @@ -214,43 +260,77 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %.4: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T (constants.%T.1)] +// CHECK:STDOUT: @F.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T.1 (constants.%T.1)] // CHECK:STDOUT: %U.loc4_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U (constants.%U.1)] -// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T.1)] -// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = %.loc4 (constants.%.1)] -// CHECK:STDOUT: @F.%return: ref %.1 = var +// CHECK:STDOUT: @F.%U.loc4: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U.1 (constants.%U.1)] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, @F.%T.loc4 [symbolic = @F.%T.1 (constants.%T.1)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = @F.%.1 (constants.%.1)] +// CHECK:STDOUT: @F.%return: ref @F.%.1 (%.1) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %U.loc13_6.1: type = param U -// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = @.1.%U (constants.%U.2)] +// CHECK:STDOUT: @.1.%U.loc13: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = @.1.%U.1 (constants.%U.2)] // CHECK:STDOUT: %T.loc13_16.1: type = param T -// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = @.1.%T (constants.%T.2)] -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, @.1.%T [symbolic = @.1.%T (constants.%T.2)] -// CHECK:STDOUT: %.loc13: type = ptr_type %T.2 [symbolic = %.loc13 (constants.%.3)] -// CHECK:STDOUT: @.1.%return: ref %.3 = var +// CHECK:STDOUT: @.1.%T.loc13: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = @.1.%T.1 (constants.%T.2)] +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, @.1.%T.loc13 [symbolic = @.1.%T.1 (constants.%T.2)] +// CHECK:STDOUT: %.loc13: type = ptr_type %T.2 [symbolic = @.1.%.1 (constants.%.3)] +// CHECK:STDOUT: @.1.%return: ref @.1.%.1 (%.3) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %U: type) -> %.1 -// CHECK:STDOUT: generic [%T: type, %U: type]; +// CHECK:STDOUT: generic fn @F(%T.loc4: type, %U.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.1)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U.1)] +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T.1) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc4: type, %U.loc4: type) -> @F.%.1 (%.1); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(%U.loc13: type, %T.loc13: type) { +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 0 [symbolic = %U.1 (constants.%U.2)] +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 1 [symbolic = %T.1 (constants.%T.2)] +// CHECK:STDOUT: %.1: type = ptr_type @.1.%T.1 (%T.2) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%U.loc13: type, %T.loc13: type) -> @.1.%.1 (%.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc13 [symbolic = %T.1 (constants.%T.2)] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T.1, constants.%U.1) { +// CHECK:STDOUT: %T.1 => constants.%T.1 +// CHECK:STDOUT: %U.1 => constants.%U.1 +// CHECK:STDOUT: %.1 => constants.%.1 +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1(%U: type, %T: type) -> %.3 -// CHECK:STDOUT: generic [%U: type, %T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T.2] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @.1(constants.%U.2, constants.%T.2) { +// CHECK:STDOUT: %U.1 => constants.%U.2 +// CHECK:STDOUT: %T.1 => constants.%T.2 +// CHECK:STDOUT: %.1 => constants.%.3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_rename.carbon @@ -269,42 +349,76 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %.4: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T (constants.%T.1)] +// CHECK:STDOUT: @F.%T.loc4: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T.1 (constants.%T.1)] // CHECK:STDOUT: %U.loc4_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U (constants.%U.1)] -// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T.1)] -// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = %.loc4 (constants.%.1)] -// CHECK:STDOUT: @F.%return: ref %.1 = var +// CHECK:STDOUT: @F.%U.loc4: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U.1 (constants.%U.1)] +// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T.loc4 [symbolic = @F.%T.1 (constants.%T.1)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = @F.%.1 (constants.%.1)] +// CHECK:STDOUT: @F.%return: ref @F.%.1 (%.1) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %U.loc13_6.1: type = param U -// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = @.1.%U (constants.%U.2)] +// CHECK:STDOUT: @.1.%U.loc13: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = @.1.%U.1 (constants.%U.2)] // CHECK:STDOUT: %T.loc13_16.1: type = param T -// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = @.1.%T (constants.%T.2)] -// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U [symbolic = @.1.%U (constants.%U.2)] -// CHECK:STDOUT: %.loc13: type = ptr_type %U.2 [symbolic = %.loc13 (constants.%.3)] -// CHECK:STDOUT: @.1.%return: ref %.3 = var +// CHECK:STDOUT: @.1.%T.loc13: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = @.1.%T.1 (constants.%T.2)] +// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U.loc13 [symbolic = @.1.%U.1 (constants.%U.2)] +// CHECK:STDOUT: %.loc13: type = ptr_type %U.2 [symbolic = @.1.%.1 (constants.%.3)] +// CHECK:STDOUT: @.1.%return: ref @.1.%.1 (%.3) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %U: type) -> %.1 -// CHECK:STDOUT: generic [%T: type, %U: type]; +// CHECK:STDOUT: generic fn @F(%T.loc4: type, %U.loc4: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.1)] +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U.1)] +// CHECK:STDOUT: %.1: type = ptr_type @F.%T.1 (%T.1) [symbolic = %.1 (constants.%.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc4: type, %U.loc4: type) -> @F.%.1 (%.1); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(%U.loc13: type, %T.loc13: type) { +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 0 [symbolic = %U.1 (constants.%U.2)] +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 1 [symbolic = %T.1 (constants.%T.2)] +// CHECK:STDOUT: %.1: type = ptr_type @.1.%U.1 (%U.2) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%U.loc13: type, %T.loc13: type) -> @.1.%.1 (%.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc13 [symbolic = %T.1 (constants.%T.2)] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T.1, constants.%U.1) { +// CHECK:STDOUT: %T.1 => constants.%T.1 +// CHECK:STDOUT: %U.1 => constants.%U.1 +// CHECK:STDOUT: %.1 => constants.%.1 +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1(%U: type, %T: type) -> %.3 -// CHECK:STDOUT: generic [%U: type, %T: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T.2] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @.1(constants.%U.2, constants.%T.2) { +// CHECK:STDOUT: %U.1 => constants.%U.2 +// CHECK:STDOUT: %T.1 => constants.%T.2 +// CHECK:STDOUT: %.1 => constants.%.3 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/return_slot.carbon b/toolchain/check/testdata/function/generic/return_slot.carbon new file mode 100644 index 0000000000000..c44afeff79b56 --- /dev/null +++ b/toolchain/check/testdata/function/generic/return_slot.carbon @@ -0,0 +1,217 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/return_slot.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/return_slot.carbon + +class Wrap(T:! type) { + fn Make() -> T; +} + +class C { var arr: [i32; 100]; } + +fn G() { + var a: i32 = Wrap(i32).Make(); + var b: () = Wrap(()).Make(); + var c: C = Wrap(C).Make(); +} + +// CHECK:STDOUT: --- return_slot.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %Wrap.type: type = generic_class_type @Wrap [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Wrap.1: %Wrap.type = struct_value () [template] +// CHECK:STDOUT: %Wrap.2: type = class_type @Wrap, @Wrap(%T) [symbolic] +// CHECK:STDOUT: %Make.type.1: type = fn_type @Make, @Wrap(%T) [symbolic] +// CHECK:STDOUT: %Make.1: %Make.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.3: i32 = int_literal 100 [template] +// CHECK:STDOUT: %.4: type = array_type %.3, i32 [template] +// CHECK:STDOUT: %.5: type = ptr_type %.4 [template] +// CHECK:STDOUT: %.6: type = unbound_element_type %C, %.4 [template] +// CHECK:STDOUT: %.7: type = struct_type {.arr: %.4} [template] +// CHECK:STDOUT: %G.type: type = fn_type @G [template] +// CHECK:STDOUT: %G: %G.type = struct_value () [template] +// CHECK:STDOUT: %Wrap.3: type = class_type @Wrap, @Wrap(i32) [template] +// CHECK:STDOUT: %Make.type.2: type = fn_type @Make, @Wrap(i32) [template] +// CHECK:STDOUT: %Make.2: %Make.type.2 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %.2 [template] +// CHECK:STDOUT: %Wrap.4: type = class_type @Wrap, @Wrap(%.1) [template] +// CHECK:STDOUT: %Make.type.3: type = fn_type @Make, @Wrap(%.1) [template] +// CHECK:STDOUT: %Make.3: %Make.type.3 = struct_value () [template] +// CHECK:STDOUT: %.9: type = struct_type {.arr: %.5} [template] +// CHECK:STDOUT: %.10: type = ptr_type %.7 [template] +// CHECK:STDOUT: %Wrap.5: type = class_type @Wrap, @Wrap(%C) [template] +// CHECK:STDOUT: %Make.type.4: type = fn_type @Make, @Wrap(%C) [template] +// CHECK:STDOUT: %Make.4: %Make.type.4 = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Wrap = %Wrap.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Wrap.decl: %Wrap.type = class_decl @Wrap [template = constants.%Wrap.1] { +// CHECK:STDOUT: %T.loc11_12.1: type = param T +// CHECK:STDOUT: %T.loc11_12.2: type = bind_symbolic_name T 0, %T.loc11_12.1 [symbolic = @Wrap.%T (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @Wrap(file.%T.loc11_12.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type: type = fn_type @Make, @Wrap(%T) [symbolic = %Make.type (constants.%Make.type.1)] +// CHECK:STDOUT: %Make: @Wrap.%Make.type (%Make.type.1) = struct_value () [symbolic = %Make (constants.%Make.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %Make.decl: @Wrap.%Make.type (%Make.type.1) = fn_decl @Make [symbolic = %Make (constants.%Make.1)] { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_12.2 [symbolic = @Make.%T (constants.%T)] +// CHECK:STDOUT: %return.var: ref @Make.%T (%T) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%Wrap.2 +// CHECK:STDOUT: .Make = %Make.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc15_26: i32 = int_literal 100 [template = constants.%.3] +// CHECK:STDOUT: %.loc15_21.1: type = value_of_initializer %int.make_type_32 [template = i32] +// CHECK:STDOUT: %.loc15_21.2: type = converted %int.make_type_32, %.loc15_21.1 [template = i32] +// CHECK:STDOUT: %.loc15_29: type = array_type %.loc15_26, i32 [template = constants.%.4] +// CHECK:STDOUT: %.loc15_18: %.6 = field_decl arr, element0 [template] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: .arr = %.loc15_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Make(file.%T.loc11_12.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Make.%T (%T); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %int.make_type_32.loc18_10: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc18_10.1: type = value_of_initializer %int.make_type_32.loc18_10 [template = i32] +// CHECK:STDOUT: %.loc18_10.2: type = converted %int.make_type_32.loc18_10, %.loc18_10.1 [template = i32] +// CHECK:STDOUT: %a.var: ref i32 = var a +// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var +// CHECK:STDOUT: %Wrap.ref.loc18: %Wrap.type = name_ref Wrap, file.%Wrap.decl [template = constants.%Wrap.1] +// CHECK:STDOUT: %int.make_type_32.loc18_21: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc18_20.1: type = value_of_initializer %int.make_type_32.loc18_21 [template = i32] +// CHECK:STDOUT: %.loc18_20.2: type = converted %int.make_type_32.loc18_21, %.loc18_20.1 [template = i32] +// CHECK:STDOUT: %.loc18_20.3: init type = call %Wrap.ref.loc18(%.loc18_20.2) [template = constants.%Wrap.3] +// CHECK:STDOUT: %.loc18_25: %Make.type.2 = specific_constant @Wrap.%Make.decl, @Wrap(i32) [template = constants.%Make.2] +// CHECK:STDOUT: %Make.ref.loc18: %Make.type.2 = name_ref Make, %.loc18_25 [template = constants.%Make.2] +// CHECK:STDOUT: %Make.call.loc18: init i32 = call %Make.ref.loc18() +// CHECK:STDOUT: assign %a.var, %Make.call.loc18 +// CHECK:STDOUT: %.loc19_11.1: %.1 = tuple_literal () +// CHECK:STDOUT: %.loc19_11.2: type = converted %.loc19_11.1, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %b.var: ref %.1 = var b +// CHECK:STDOUT: %b: ref %.1 = bind_name b, %b.var +// CHECK:STDOUT: %Wrap.ref.loc19: %Wrap.type = name_ref Wrap, file.%Wrap.decl [template = constants.%Wrap.1] +// CHECK:STDOUT: %.loc19_21: %.1 = tuple_literal () +// CHECK:STDOUT: %.loc19_19.1: type = converted %.loc19_21, constants.%.1 [template = constants.%.1] +// CHECK:STDOUT: %.loc19_19.2: init type = call %Wrap.ref.loc19(%.loc19_19.1) [template = constants.%Wrap.4] +// CHECK:STDOUT: %.loc19_23: %Make.type.3 = specific_constant @Wrap.%Make.decl, @Wrap(constants.%.1) [template = constants.%Make.3] +// CHECK:STDOUT: %Make.ref.loc19: %Make.type.3 = name_ref Make, %.loc19_23 [template = constants.%Make.3] +// CHECK:STDOUT: %Make.call.loc19: init %.1 = call %Make.ref.loc19() +// CHECK:STDOUT: assign %b.var, %Make.call.loc19 +// CHECK:STDOUT: %C.ref.loc20_10: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: %Wrap.ref.loc20: %Wrap.type = name_ref Wrap, file.%Wrap.decl [template = constants.%Wrap.1] +// CHECK:STDOUT: %C.ref.loc20_19: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc20_18: init type = call %Wrap.ref.loc20(%C.ref.loc20_19) [template = constants.%Wrap.5] +// CHECK:STDOUT: %.loc20_21: %Make.type.4 = specific_constant @Wrap.%Make.decl, @Wrap(constants.%C) [template = constants.%Make.4] +// CHECK:STDOUT: %Make.ref.loc20: %Make.type.4 = name_ref Make, %.loc20_21 [template = constants.%Make.4] +// CHECK:STDOUT: %.loc20_7: ref %C = splice_block %c.var {} +// CHECK:STDOUT: %Make.call.loc20: init %C = call %Make.ref.loc20() to %.loc20_7 +// CHECK:STDOUT: assign %c.var, %Make.call.loc20 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Wrap(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Make(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Wrap(@Wrap.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Wrap(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type => constants.%Make.type.2 +// CHECK:STDOUT: %Make => constants.%Make.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Make(i32) { +// CHECK:STDOUT: %T => i32 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Wrap(constants.%.1) { +// CHECK:STDOUT: %T => constants.%.1 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type => constants.%Make.type.3 +// CHECK:STDOUT: %Make => constants.%Make.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Make(constants.%.1) { +// CHECK:STDOUT: %T => constants.%.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Wrap(constants.%C) { +// CHECK:STDOUT: %T => constants.%C +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Make.type => constants.%Make.type.4 +// CHECK:STDOUT: %Make => constants.%Make.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Make(constants.%C) { +// CHECK:STDOUT: %T => constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/global/class_obj.carbon b/toolchain/check/testdata/global/class_obj.carbon index be2b448e406ef..82affc49417d1 100644 --- a/toolchain/check/testdata/global/class_obj.carbon +++ b/toolchain/check/testdata/global/class_obj.carbon @@ -21,14 +21,25 @@ var a: A = {}; // CHECK:STDOUT: %struct: %A = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A] // CHECK:STDOUT: %a.var: ref %A = var a diff --git a/toolchain/check/testdata/global/class_with_fun.carbon b/toolchain/check/testdata/global/class_with_fun.carbon index 1ce1dee940606..06070c59f55ab 100644 --- a/toolchain/check/testdata/global/class_with_fun.carbon +++ b/toolchain/check/testdata/global/class_with_fun.carbon @@ -27,15 +27,26 @@ var a: A = {}; // CHECK:STDOUT: %struct: %A = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .ret_a = %ret_a.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %ret_a.decl: %ret_a.type = fn_decl @ret_a [template = constants.%ret_a] { // CHECK:STDOUT: %A.ref.loc12: type = name_ref A, %A.decl [template = constants.%A] diff --git a/toolchain/check/testdata/global/decl.carbon b/toolchain/check/testdata/global/decl.carbon index fd33c419349c0..983b54d4f9933 100644 --- a/toolchain/check/testdata/global/decl.carbon +++ b/toolchain/check/testdata/global/decl.carbon @@ -18,16 +18,25 @@ var a: i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc10_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc10_8.2: type = converted %int.make_type_32, %.loc10_8.1 [template = i32] diff --git a/toolchain/check/testdata/global/simple_init.carbon b/toolchain/check/testdata/global/simple_init.carbon index 9215ceae62a91..70a06e2c15c77 100644 --- a/toolchain/check/testdata/global/simple_init.carbon +++ b/toolchain/check/testdata/global/simple_init.carbon @@ -19,16 +19,25 @@ var a: i32 = 0; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc10_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc10_8.2: type = converted %int.make_type_32, %.loc10_8.1 [template = i32] diff --git a/toolchain/check/testdata/global/simple_with_fun.carbon b/toolchain/check/testdata/global/simple_with_fun.carbon index e3b795c4d9be0..4ea7d9ee14acb 100644 --- a/toolchain/check/testdata/global/simple_with_fun.carbon +++ b/toolchain/check/testdata/global/simple_with_fun.carbon @@ -26,18 +26,26 @@ var a: i32 = test_a(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_a = %test_a.decl // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %test_a.decl: %test_a.type = fn_decl @test_a [template = constants.%test_a] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_16.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/if/else.carbon b/toolchain/check/testdata/if/else.carbon index 83a0344ca916b..e70f29f04573e 100644 --- a/toolchain/check/testdata/if/else.carbon +++ b/toolchain/check/testdata/if/else.carbon @@ -38,19 +38,28 @@ fn If(b: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .H = %H.decl // CHECK:STDOUT: .If = %If.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} diff --git a/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon index 3b4e730c52f48..1b2733094bd25 100644 --- a/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon @@ -58,23 +58,29 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .If1 = %If1.decl // CHECK:STDOUT: .If2 = %If2.decl // CHECK:STDOUT: .If3 = %If3.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %If1.decl: %If1.type = fn_decl @If1 [template = constants.%If1] { // CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type.loc11 [template = bool] diff --git a/toolchain/check/testdata/if/fail_scope.carbon b/toolchain/check/testdata/if/fail_scope.carbon index dacae25f040ae..c81be781ac871 100644 --- a/toolchain/check/testdata/if/fail_scope.carbon +++ b/toolchain/check/testdata/if/fail_scope.carbon @@ -33,18 +33,27 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .VarScope = %VarScope.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %VarScope.decl: %VarScope.type = fn_decl @VarScope [template = constants.%VarScope] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_16.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/if/no_else.carbon b/toolchain/check/testdata/if/no_else.carbon index 740db8c5317cb..3039e7cb5ddfd 100644 --- a/toolchain/check/testdata/if/no_else.carbon +++ b/toolchain/check/testdata/if/no_else.carbon @@ -33,18 +33,27 @@ fn If(b: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .If = %If.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} // CHECK:STDOUT: %If.decl: %If.type = fn_decl @If [template = constants.%If] { diff --git a/toolchain/check/testdata/if/unreachable_fallthrough.carbon b/toolchain/check/testdata/if/unreachable_fallthrough.carbon index 85d53fc478dbd..0ee3c10dd7446 100644 --- a/toolchain/check/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/check/testdata/if/unreachable_fallthrough.carbon @@ -32,17 +32,27 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .If = %If.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %If.decl: %If.type = fn_decl @If [template = constants.%If] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_10.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/if_expr/basic.carbon b/toolchain/check/testdata/if_expr/basic.carbon index f0e0c7237edcb..527d7d248c109 100644 --- a/toolchain/check/testdata/if_expr/basic.carbon +++ b/toolchain/check/testdata/if_expr/basic.carbon @@ -32,20 +32,27 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/if_expr/constant_condition.carbon b/toolchain/check/testdata/if_expr/constant_condition.carbon index 3be623bb9fd4a..a4812b8a5a84c 100644 --- a/toolchain/check/testdata/if_expr/constant_condition.carbon +++ b/toolchain/check/testdata/if_expr/constant_condition.carbon @@ -57,23 +57,22 @@ fn PartiallyConstant(t: type) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .F = %F.decl @@ -82,7 +81,6 @@ fn PartiallyConstant(t: type) -> i32 { // CHECK:STDOUT: .PartiallyConstant = %PartiallyConstant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/if_expr/control_flow.carbon b/toolchain/check/testdata/if_expr/control_flow.carbon index 6de4d6466252a..f901651284459 100644 --- a/toolchain/check/testdata/if_expr/control_flow.carbon +++ b/toolchain/check/testdata/if_expr/control_flow.carbon @@ -34,21 +34,29 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon index 0653948d1eabc..6cb00b8f788b0 100644 --- a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon +++ b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon @@ -55,19 +55,28 @@ class C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .x = +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .x = .inst+12.loc23_5 // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc23_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc23_8.2: type = converted %int.make_type_32, %.loc23_8.1 [template = i32] @@ -80,7 +89,7 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .n = +// CHECK:STDOUT: .n = .inst+48.loc37_8 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/if_expr/fail_partial_constant.carbon b/toolchain/check/testdata/if_expr/fail_partial_constant.carbon index 306a278885181..9248fcc9587db 100644 --- a/toolchain/check/testdata/if_expr/fail_partial_constant.carbon +++ b/toolchain/check/testdata/if_expr/fail_partial_constant.carbon @@ -53,18 +53,27 @@ fn ChosenBranchIsNonConstant(t: type) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .ConditionIsNonConstant = %ConditionIsNonConstant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ConditionIsNonConstant.decl: %ConditionIsNonConstant.type = fn_decl @ConditionIsNonConstant [template = constants.%ConditionIsNonConstant] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc4_30.1: type = value_of_initializer %bool.make_type [template = bool] @@ -118,17 +127,25 @@ fn ChosenBranchIsNonConstant(t: type) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .ChosenBranchIsNonConstant = %ChosenBranchIsNonConstant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ChosenBranchIsNonConstant.decl: %ChosenBranchIsNonConstant.type = fn_decl @ChosenBranchIsNonConstant [template = constants.%ChosenBranchIsNonConstant] { // CHECK:STDOUT: %t.loc4_30.1: type = param t // CHECK:STDOUT: @ChosenBranchIsNonConstant.%t: type = bind_name t, %t.loc4_30.1 diff --git a/toolchain/check/testdata/if_expr/nested.carbon b/toolchain/check/testdata/if_expr/nested.carbon index f0f54f793fb38..e8b94acd105ea 100644 --- a/toolchain/check/testdata/if_expr/nested.carbon +++ b/toolchain/check/testdata/if_expr/nested.carbon @@ -29,19 +29,27 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %bool.make_type.loc11_9: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %bool.make_type.loc11_9 [template = bool] diff --git a/toolchain/check/testdata/if_expr/struct.carbon b/toolchain/check/testdata/if_expr/struct.carbon index 765a3f5979153..56b53c657fa3c 100644 --- a/toolchain/check/testdata/if_expr/struct.carbon +++ b/toolchain/check/testdata/if_expr/struct.carbon @@ -35,21 +35,28 @@ fn F(cond: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32.loc11_14 [template = i32] diff --git a/toolchain/check/testdata/impl/compound.carbon b/toolchain/check/testdata/impl/compound.carbon index 110a5d37bd533..8d5f3303482ac 100644 --- a/toolchain/check/testdata/impl/compound.carbon +++ b/toolchain/check/testdata/impl/compound.carbon @@ -67,17 +67,22 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Simple = %Simple.decl // CHECK:STDOUT: .NonInstanceCall = %NonInstanceCall.decl // CHECK:STDOUT: .InstanceCall = %InstanceCall.decl @@ -85,7 +90,6 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: .InstanceCallIndirect = %InstanceCallIndirect.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32.loc16: init type = call constants.%Int32() [template = i32] @@ -130,11 +134,11 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: %G.decl: %G.type.1 = fn_decl @G.1 [template = constants.%G.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc13_14.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc13_14.2: type = converted %Self.ref, %.loc13_14.1 [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %self.loc13_8.1: @Simple.%Self.ref (%Self) = param self -// CHECK:STDOUT: %self.loc13_8.2: @Simple.%Self.ref (%Self) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = @G.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.1: type = facet_type_access %Self.ref [symbolic = @G.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.2: type = converted %Self.ref, %.loc13_14.1 [symbolic = @G.1.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc13_8.1: @G.1.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc13_8.2: @G.1.%Self (%Self) = bind_name self, %self.loc13_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc13_21: %.5 = assoc_entity element1, %G.decl [template = constants.%.6] // CHECK:STDOUT: @@ -162,11 +166,16 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G.1(@Simple.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @G.1[@Simple.%self.loc13_8.2: @Simple.%Self.ref (%Self)]() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: fn[@Simple.%self.loc13_8.2: @G.1.%Self (%Self)](); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: @@ -219,3 +228,9 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/declaration.carbon b/toolchain/check/testdata/impl/declaration.carbon index 09e0d6f5facac..74330c46af203 100644 --- a/toolchain/check/testdata/impl/declaration.carbon +++ b/toolchain/check/testdata/impl/declaration.carbon @@ -23,16 +23,25 @@ impl i32 as I; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/impl/empty.carbon b/toolchain/check/testdata/impl/empty.carbon index f67cb7a815652..ee82e9ce61617 100644 --- a/toolchain/check/testdata/impl/empty.carbon +++ b/toolchain/check/testdata/impl/empty.carbon @@ -26,16 +26,25 @@ impl i32 as Empty { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Empty = %Empty.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/impl/extend_impl.carbon b/toolchain/check/testdata/impl/extend_impl.carbon index 0148e9341ae13..641c2fa173c9d 100644 --- a/toolchain/check/testdata/impl/extend_impl.carbon +++ b/toolchain/check/testdata/impl/extend_impl.carbon @@ -43,15 +43,26 @@ fn G(c: C) { // CHECK:STDOUT: %.7: type = ptr_type %.6 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .HasF = %HasF.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { @@ -91,8 +102,10 @@ fn G(c: C) { // CHECK:STDOUT: extend name_scope2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@HasF.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@HasF.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: @@ -112,3 +125,5 @@ fn G(c: C) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_call_invalid.carbon b/toolchain/check/testdata/impl/fail_call_invalid.carbon index be616325efc4e..213c4d21a5593 100644 --- a/toolchain/check/testdata/impl/fail_call_invalid.carbon +++ b/toolchain/check/testdata/impl/fail_call_invalid.carbon @@ -42,18 +42,26 @@ fn InstanceCall(n: i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Simple = %Simple.decl // CHECK:STDOUT: .InstanceCall = %InstanceCall.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] @@ -73,11 +81,11 @@ fn InstanceCall(n: i32) { // CHECK:STDOUT: interface @Simple { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %G.decl: %G.type.1 = fn_decl @G.1 [template = constants.%G.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref, %.loc12_14.1 [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %self.loc12_8.1: @Simple.%Self.ref (%Self) = param self -// CHECK:STDOUT: %self.loc12_8.2: @Simple.%Self.ref (%Self) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = @G.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref [symbolic = @G.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref, %.loc12_14.1 [symbolic = @G.1.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc12_8.1: @G.1.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc12_8.2: @G.1.%Self (%Self) = bind_name self, %self.loc12_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_21: %.3 = assoc_entity element0, %G.decl [template = constants.%.4] // CHECK:STDOUT: @@ -100,8 +108,11 @@ fn InstanceCall(n: i32) { // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G.1[@Simple.%self.loc12_8.2: @Simple.%Self.ref (%Self)]() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: generic fn @G.1(@Simple.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Simple.%self.loc12_8.2: @G.1.%Self (%Self)](); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: @@ -117,3 +128,7 @@ fn InstanceCall(n: i32) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon b/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon index 2a383b9cbf841..c831663e34bb5 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon @@ -28,12 +28,12 @@ class C { // CHECK:STDOUT: %GenericInterface.type: type = generic_interface_type @GenericInterface [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %GenericInterface: %GenericInterface.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = interface_type @GenericInterface, (%T) [symbolic] +// CHECK:STDOUT: %.2: type = interface_type @GenericInterface, @GenericInterface(%T) [symbolic] // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic] -// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] -// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] -// CHECK:STDOUT: %.3: type = assoc_entity_type @GenericInterface, %F.type.1 [template] -// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @GenericInterface.%F.decl [template] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @GenericInterface(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = assoc_entity_type @GenericInterface, %F.type.1 [symbolic] +// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @GenericInterface.%F.decl [symbolic] // CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] @@ -41,42 +41,64 @@ class C { // CHECK:STDOUT: %.6: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .GenericInterface = %GenericInterface.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type = interface_decl @GenericInterface [template = constants.%GenericInterface] { // CHECK:STDOUT: %T.loc11_28.1: type = param T -// CHECK:STDOUT: %T.loc11_28.2: type = bind_symbolic_name T 0, %T.loc11_28.1 [symbolic = %T.loc11_28.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_28.2: type = bind_symbolic_name T 0, %T.loc11_28.1 [symbolic = @GenericInterface.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @GenericInterface -// CHECK:STDOUT: generic [file.%T.loc11_28.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] -// CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = %T.ref (constants.%T)] -// CHECK:STDOUT: %x.loc12_8.1: @GenericInterface.%T.ref (%T) = param x -// CHECK:STDOUT: %x.loc12_8.2: @GenericInterface.%T.ref (%T) = bind_name x, %x.loc12_8.1 -// CHECK:STDOUT: } -// CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] +// CHECK:STDOUT: generic interface @GenericInterface(file.%T.loc11_28.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc12 -// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @GenericInterface, @GenericInterface(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @GenericInterface(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @GenericInterface.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.2: type = assoc_entity_type @GenericInterface, @GenericInterface.%F.type (%F.type.1) [symbolic = %.2 (constants.%.3)] +// CHECK:STDOUT: %.3: @GenericInterface.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @GenericInterface.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.decl: @GenericInterface.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = @F.1.%T (constants.%T)] +// CHECK:STDOUT: %x.loc12_8.1: @F.1.%T (%T) = param x +// CHECK:STDOUT: %x.loc12_8.2: @F.1.%T (%T) = bind_name x, %x.loc12_8.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc12: @GenericInterface.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .F = %.loc12 +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %C as %.2 { // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { -// CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc19_23.2 [symbolic = %T.ref (constants.%T)] -// CHECK:STDOUT: %x.loc20_10.1: @impl.%T.ref (%T) = param x -// CHECK:STDOUT: %x.loc20_10.2: @impl.%T.ref (%T) = bind_name x, %x.loc20_10.1 +// CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc19_23.2 [symbolic = @F.2.%T (constants.%T)] +// CHECK:STDOUT: %x.loc20_10.1: @F.2.%T (%T) = param x +// CHECK:STDOUT: %x.loc20_10.2: @F.2.%T (%T) = bind_name x, %x.loc20_10.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.1: = interface_witness (%F.decl) [template = constants.%.5] // CHECK:STDOUT: @@ -101,12 +123,36 @@ class C { // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1(@GenericInterface.%x.loc12_8.2: @GenericInterface.%T.ref (%T)) -// CHECK:STDOUT: generic [file.%T.loc11_28.2: type, @GenericInterface.%Self: %.2]; +// CHECK:STDOUT: generic fn @F.1(file.%T.loc11_28.2: type, @GenericInterface.%Self.1: @GenericInterface.%.1 (%.2)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@GenericInterface.%x.loc12_8.2: @F.1.%T (%T)); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.2(@C.%T.loc19_23.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@impl.%x.loc20_10.2: @F.2.%T (%T)) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GenericInterface(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GenericInterface(@GenericInterface.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2(@impl.%x.loc20_10.2: @impl.%T.ref (%T)) -// CHECK:STDOUT: generic [@C.%T.loc19_23.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @F.2(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_extend_impl_scope.carbon b/toolchain/check/testdata/impl/fail_extend_impl_scope.carbon index a89ad2f9f5be8..c1824f324f8d0 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_scope.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_scope.carbon @@ -27,16 +27,25 @@ extend impl i32 as I {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon b/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon index a80a00815fd96..c602ecf2872b8 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_type_as.carbon @@ -55,19 +55,28 @@ class E { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .E = %E.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} diff --git a/toolchain/check/testdata/impl/fail_extend_non_interface.carbon b/toolchain/check/testdata/impl/fail_extend_non_interface.carbon index a3363d6aad141..654fe7692f0da 100644 --- a/toolchain/check/testdata/impl/fail_extend_non_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_non_interface.carbon @@ -26,16 +26,25 @@ class C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon b/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon index 88dccc80511ad..4b5bb43068b5d 100644 --- a/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_partially_defined_interface.carbon @@ -29,13 +29,24 @@ interface I { // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -51,14 +62,19 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %C as %.1; // CHECK:STDOUT: -// CHECK:STDOUT: class @C -// CHECK:STDOUT: generic [@I.%Self: %.1] { -// CHECK:STDOUT: impl_decl @impl { -// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1] -// CHECK:STDOUT: } +// CHECK:STDOUT: generic class @C(@I.%Self: %.1) { +// CHECK:STDOUT: !definition: // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: has_error +// CHECK:STDOUT: class { +// CHECK:STDOUT: impl_decl @impl { +// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: has_error +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon b/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon index 43e3cfda87dc1..a5a5fd7635a85 100644 --- a/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon +++ b/toolchain/check/testdata/impl/fail_extend_undefined_interface.carbon @@ -28,14 +28,25 @@ class C { // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/impl/fail_impl_as_scope.carbon b/toolchain/check/testdata/impl/fail_impl_as_scope.carbon index 8724b532dccea..d7da357b5da9a 100644 --- a/toolchain/check/testdata/impl/fail_impl_as_scope.carbon +++ b/toolchain/check/testdata/impl/fail_impl_as_scope.carbon @@ -34,13 +34,24 @@ impl as Simple { // CHECK:STDOUT: %.5: = interface_witness (%F.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Simple = %Simple.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [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] @@ -67,11 +78,15 @@ impl as Simple { // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon b/toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon index fc03ea5f14c18..8ae59cae32ce5 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_assoc_const.carbon @@ -28,16 +28,25 @@ impl bool as I {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] diff --git a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon index 8c59808a3a5eb..4bdad4b1479e2 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon @@ -301,35 +301,24 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.5: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.11: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.12: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.13: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.14: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.15: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.16: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.17: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.18: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.19: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.20: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.21: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.22: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.23: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.24: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .NoF = %NoF.decl // CHECK:STDOUT: .FNotFunction = %FNotFunction.decl @@ -351,7 +340,6 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: .SelfNestedBadReturnType = %SelfNestedBadReturnType.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %NoF.decl: type = class_decl @NoF [template = constants.%NoF] {} // CHECK:STDOUT: %FNotFunction.decl: type = class_decl @FNotFunction [template = constants.%FNotFunction] {} @@ -413,27 +401,27 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: interface @SelfNested { // CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 0 [symbolic = constants.%Self.3] // CHECK:STDOUT: %F.decl: %F.type.13 = fn_decl @F.13 [template = constants.%F.14] { -// CHECK:STDOUT: %Self.ref.loc188_12: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_16.1: type = facet_type_access %Self.ref.loc188_12 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_16.2: type = converted %Self.ref.loc188_12, %.loc188_16.1 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_16.3: type = ptr_type %Self.3 [symbolic = %.loc188_16.3 (constants.%.10)] -// CHECK:STDOUT: %Self.ref.loc188_24: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_24.1: type = facet_type_access %Self.ref.loc188_24 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_24.2: type = converted %Self.ref.loc188_24, %.loc188_24.1 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %Self.ref.loc188_12: %.9 = name_ref Self, %Self [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_16.1: type = facet_type_access %Self.ref.loc188_12 [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_16.2: type = converted %Self.ref.loc188_12, %.loc188_16.1 [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_16.3: type = ptr_type %Self.3 [symbolic = @F.13.%.1 (constants.%.10)] +// CHECK:STDOUT: %Self.ref.loc188_24: %.9 = name_ref Self, %Self [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_24.1: type = facet_type_access %Self.ref.loc188_24 [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_24.2: type = converted %Self.ref.loc188_24, %.loc188_24.1 [symbolic = @F.13.%Self (constants.%Self.3)] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc188_34.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc188_34.2: type = converted %int.make_type_32, %.loc188_34.1 [template = i32] -// CHECK:STDOUT: %.loc188_37: type = struct_type {.x: %Self.3, .y: i32} [symbolic = %.loc188_37 (constants.%.11)] +// CHECK:STDOUT: %.loc188_37: type = struct_type {.x: %Self.3, .y: i32} [symbolic = @F.13.%.2 (constants.%.11)] // CHECK:STDOUT: %.loc188_38.1: %.12 = tuple_literal (%.loc188_16.3, %.loc188_37) -// CHECK:STDOUT: %.loc188_38.2: type = converted %.loc188_38.1, constants.%.13 [symbolic = %.loc188_38.2 (constants.%.13)] -// CHECK:STDOUT: %x.loc188_8.1: @SelfNested.%.loc188_38.2 (%.13) = param x -// CHECK:STDOUT: %x.loc188_8.2: @SelfNested.%.loc188_38.2 (%.13) = bind_name x, %x.loc188_8.1 -// CHECK:STDOUT: %Self.ref.loc188_45: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_38.2: type = converted %.loc188_38.1, constants.%.13 [symbolic = @F.13.%.3 (constants.%.13)] +// CHECK:STDOUT: %x.loc188_8.1: @F.13.%.3 (%.13) = param x +// CHECK:STDOUT: %x.loc188_8.2: @F.13.%.3 (%.13) = bind_name x, %x.loc188_8.1 +// CHECK:STDOUT: %Self.ref.loc188_45: %.9 = name_ref Self, %Self [symbolic = @F.13.%Self (constants.%Self.3)] // CHECK:STDOUT: %.loc188_51: i32 = int_literal 4 [template = constants.%.14] -// CHECK:STDOUT: %.loc188_45.1: type = facet_type_access %Self.ref.loc188_45 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_45.2: type = converted %Self.ref.loc188_45, %.loc188_45.1 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] -// CHECK:STDOUT: %.loc188_52: type = array_type %.loc188_51, %Self.3 [symbolic = %.loc188_52 (constants.%.15)] -// CHECK:STDOUT: %return.var: ref %.15 = var +// CHECK:STDOUT: %.loc188_45.1: type = facet_type_access %Self.ref.loc188_45 [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_45.2: type = converted %Self.ref.loc188_45, %.loc188_45.1 [symbolic = @F.13.%Self (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_52: type = array_type %.loc188_51, %Self.3 [symbolic = @F.13.%.4 (constants.%.15)] +// CHECK:STDOUT: %return.var: ref @F.13.%.4 (%.15) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc188_53: %.16 = assoc_entity element0, %F.decl [template = constants.%.17] // CHECK:STDOUT: @@ -848,8 +836,10 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: .Self = constants.%SelfNestedBadReturnType // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@I.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @PossiblyF(); // CHECK:STDOUT: @@ -861,8 +851,10 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.4() -> bool; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.5[@J.%self.loc93_20.2: bool](@J.%b.loc93_32.2: bool) -> bool -// CHECK:STDOUT: generic [@J.%Self: %.6]; +// CHECK:STDOUT: generic fn @F.5(@J.%Self: %.6) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@J.%self.loc93_20.2: bool](@J.%b.loc93_32.2: bool) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.6[@impl.7.%self.loc104_10.2: bool]() -> bool; // CHECK:STDOUT: @@ -880,10 +872,29 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.13(@SelfNested.%x.loc188_8.2: @SelfNested.%.loc188_38.2 (%.13)) -> %.15 -// CHECK:STDOUT: generic [@SelfNested.%Self: %.9]; +// CHECK:STDOUT: generic fn @F.13(@SelfNested.%Self: %.9) { +// CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.3)] +// CHECK:STDOUT: %.1: type = ptr_type @F.13.%Self (%Self.3) [symbolic = %.1 (constants.%.10)] +// CHECK:STDOUT: %.2: type = struct_type {.x: @F.13.%Self (%Self.3), .y: i32} [symbolic = %.2 (constants.%.11)] +// CHECK:STDOUT: %.3: type = tuple_type (@F.13.%.1 (%.10), @F.13.%.2 (%.11)) [symbolic = %.3 (constants.%.13)] +// CHECK:STDOUT: %.4: type = array_type constants.%.14, @F.13.%Self (%Self.3) [symbolic = %.4 (constants.%.15)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@SelfNested.%x.loc188_8.2: @F.13.%.3 (%.13)) -> @F.13.%.4 (%.15); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.14(@impl.14.%x.loc200_10.2: %.20) -> %.21; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.15(@impl.15.%x.loc212_10.2: %.26) -> %.21; // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.5(constants.%Self.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.13(constants.%Self.3) { +// CHECK:STDOUT: %Self => constants.%Self.3 +// CHECK:STDOUT: %.1 => constants.%.10 +// CHECK:STDOUT: %.2 => constants.%.11 +// CHECK:STDOUT: %.3 => constants.%.13 +// CHECK:STDOUT: %.4 => constants.%.15 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/fail_impl_bad_interface.carbon b/toolchain/check/testdata/impl/fail_impl_bad_interface.carbon index 6c4598e466b38..08d94220771af 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_interface.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_interface.carbon @@ -27,15 +27,24 @@ impl i32 as false {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc18_6.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/impl/fail_impl_bad_type.carbon b/toolchain/check/testdata/impl/fail_impl_bad_type.carbon index cfa48079fec67..61b453fe63e42 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_type.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_type.carbon @@ -24,13 +24,24 @@ impl true as I {} // CHECK:STDOUT: %.3: = interface_witness () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %.loc16: bool = bool_literal true [template = constants.%.2] diff --git a/toolchain/check/testdata/impl/fail_redefinition.carbon b/toolchain/check/testdata/impl/fail_redefinition.carbon index c5b4564238b2b..91ddbee26111b 100644 --- a/toolchain/check/testdata/impl/fail_redefinition.carbon +++ b/toolchain/check/testdata/impl/fail_redefinition.carbon @@ -32,17 +32,25 @@ impl i32 as I {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32] @@ -68,7 +76,7 @@ impl i32 as I {} // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: i32 as %.1 { // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = +// CHECK:STDOUT: witness = .inst+18 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon index 6a6b7ea3c9d44..99edf20a80bf0 100644 --- a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon +++ b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon @@ -28,16 +28,25 @@ impl bool as I where .T = bool {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] diff --git a/toolchain/check/testdata/impl/impl_as.carbon b/toolchain/check/testdata/impl/impl_as.carbon index a73ea5a710e6c..ef5b10d4880e5 100644 --- a/toolchain/check/testdata/impl/impl_as.carbon +++ b/toolchain/check/testdata/impl/impl_as.carbon @@ -40,14 +40,25 @@ class C { // CHECK:STDOUT: %struct: %C = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Simple = %Simple.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -81,8 +92,10 @@ class C { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: @@ -96,3 +109,5 @@ class C { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/impl_forall.carbon b/toolchain/check/testdata/impl/impl_forall.carbon index 964b602900515..e3857625a3a79 100644 --- a/toolchain/check/testdata/impl/impl_forall.carbon +++ b/toolchain/check/testdata/impl/impl_forall.carbon @@ -32,13 +32,24 @@ impl forall [T:! type] T as Simple { // CHECK:STDOUT: %.5: = interface_witness (%F.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Simple = %Simple.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %T.loc15_14.1: type = param T @@ -68,12 +79,21 @@ impl forall [T:! type] T as Simple { // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %.1) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2() -// CHECK:STDOUT: generic [file.%T.loc15_14.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.2(file.%T.loc15_14.2: type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.2(constants.%T) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/alias.carbon b/toolchain/check/testdata/impl/lookup/alias.carbon index e1e5d6836e9c8..4089fe02e1241 100644 --- a/toolchain/check/testdata/impl/lookup/alias.carbon +++ b/toolchain/check/testdata/impl/lookup/alias.carbon @@ -45,15 +45,26 @@ fn G(c: C) { // CHECK:STDOUT: %.7: type = ptr_type %.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .HasF = %HasF.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { @@ -97,8 +108,10 @@ fn G(c: C) { // CHECK:STDOUT: .G = %G // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@HasF.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@HasF.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: @@ -118,3 +131,5 @@ fn G(c: C) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/fail_alias_impl_not_found.carbon b/toolchain/check/testdata/impl/lookup/fail_alias_impl_not_found.carbon index eb4a8cf98db6d..963ebc9bd26cf 100644 --- a/toolchain/check/testdata/impl/lookup/fail_alias_impl_not_found.carbon +++ b/toolchain/check/testdata/impl/lookup/fail_alias_impl_not_found.carbon @@ -45,15 +45,26 @@ fn F(c: C) { // CHECK:STDOUT: %.6: type = ptr_type %.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { @@ -84,8 +95,10 @@ fn F(c: C) { // CHECK:STDOUT: .F = %F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@I.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2(%c: %C) { // CHECK:STDOUT: !entry: @@ -96,3 +109,5 @@ fn F(c: C) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon b/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon index 93f5aeb8a89a9..68f439ab97531 100644 --- a/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon +++ b/toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon @@ -51,18 +51,27 @@ impl C as I { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { @@ -107,8 +116,10 @@ impl C as I { // CHECK:STDOUT: extend name_scope2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@I.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: @@ -124,3 +135,5 @@ impl C as I { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/import.carbon b/toolchain/check/testdata/impl/lookup/import.carbon index d776b1392b80b..36919722e9b51 100644 --- a/toolchain/check/testdata/impl/lookup/import.carbon +++ b/toolchain/check/testdata/impl/lookup/import.carbon @@ -47,14 +47,25 @@ fn G(c: Impl.C) { // CHECK:STDOUT: %.6: = interface_witness (%F.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .HasF = %HasF.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.1] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { @@ -88,14 +99,18 @@ fn G(c: Impl.C) { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@HasF.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@HasF.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: // CHECK:STDOUT: --- use.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -117,28 +132,40 @@ fn G(c: Impl.C) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir8, inst+15, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir8, inst+5, unloaded -// CHECK:STDOUT: %import_ref.3: %.5 = import_ref ir8, inst+12, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.4 = import_ref ir8, inst+7, unloaded -// CHECK:STDOUT: %import_ref.5: = import_ref ir8, inst+23, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.6: type = import_ref ir8, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.7: type = import_ref ir8, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.8 = import_ref ir8, inst+7, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Impl: = namespace file.%Impl.import, [template] { +// CHECK:STDOUT: .C = %import_ref.6 +// CHECK:STDOUT: .HasF = %import_ref.7 +// CHECK:STDOUT: import Impl//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1 = import_ref Impl//default, inst+15, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Impl//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.3: %.5 = import_ref Impl//default, inst+12, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.4 = import_ref Impl//default, inst+7, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Impl//default, inst+23, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.6: type = import_ref Impl//default, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.7: type = import_ref Impl//default, inst+3, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.8 = import_ref Impl//default, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Impl = %Impl +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Impl = imports.%Impl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Impl.import = import Impl -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Impl: = namespace %Impl.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { -// CHECK:STDOUT: %Impl.ref: = name_ref Impl, %Impl [template = %Impl] +// CHECK:STDOUT: %Impl.ref: = name_ref Impl, imports.%Impl [template = imports.%Impl] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.6 [template = constants.%C] // CHECK:STDOUT: %c.loc4_6.1: %C = param c // CHECK:STDOUT: @G.%c: %C = bind_name c, %c.loc4_6.1 @@ -162,7 +189,7 @@ fn G(c: Impl.C) { // CHECK:STDOUT: fn @G(%c: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %Impl.ref: = name_ref Impl, file.%Impl [template = file.%Impl] +// CHECK:STDOUT: %Impl.ref: = name_ref Impl, imports.%Impl [template = imports.%Impl] // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.7 [template = constants.%.2] // CHECK:STDOUT: %F.ref: %.5 = name_ref F, imports.%import_ref.3 [template = constants.%.6] // CHECK:STDOUT: %.1: %F.type.1 = interface_witness_access imports.%import_ref.5, element0 [template = constants.%F.2] @@ -170,7 +197,10 @@ fn G(c: Impl.C) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1(); +// CHECK:STDOUT: generic fn @F.1(constants.%Self: %.2) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2(); // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/instance_method.carbon b/toolchain/check/testdata/impl/lookup/instance_method.carbon index bcdc189de8c40..0b251faefdf6e 100644 --- a/toolchain/check/testdata/impl/lookup/instance_method.carbon +++ b/toolchain/check/testdata/impl/lookup/instance_method.carbon @@ -47,20 +47,27 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl.loc11 // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl.loc11: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: %C.decl.loc17: type = class_decl @C [template = constants.%C] {} @@ -78,11 +85,11 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc14_14.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc14_14.2: type = converted %Self.ref, %.loc14_14.1 [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %self.loc14_8.1: @I.%Self.ref (%Self) = param self -// CHECK:STDOUT: %self.loc14_8.2: @I.%Self.ref (%Self) = bind_name self, %self.loc14_8.1 +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc14_14.1: type = facet_type_access %Self.ref [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc14_14.2: type = converted %Self.ref, %.loc14_14.1 [symbolic = @F.1.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc14_8.1: @F.1.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc14_8.2: @F.1.%Self (%Self) = bind_name self, %self.loc14_8.1 // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_25.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_25.2: type = converted %int.make_type_32, %.loc14_25.1 [template = i32] @@ -125,8 +132,11 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1[@I.%self.loc14_8.2: @I.%Self.ref (%Self)]() -> i32 -// CHECK:STDOUT: generic [@I.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@I.%self.loc14_8.2: @F.1.%Self (%Self)]() -> i32; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2[@impl.%self.loc19_10.2: %C]() -> i32; // CHECK:STDOUT: @@ -142,3 +152,7 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: return %.loc24_15.2 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon index 347dadd6ed4fb..e9afabf5dff2e 100644 --- a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon +++ b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon @@ -85,14 +85,18 @@ fn G(c: Impl.C) { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@HasF.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@HasF.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: // CHECK:STDOUT: --- use.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -114,25 +118,29 @@ fn G(c: Impl.C) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %.5 = import_ref ir1, inst+10, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+5, unloaded -// CHECK:STDOUT: %import_ref.5: = import_ref ir1, inst+21, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.6: type = import_ref ir1, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.7: type = import_ref ir1, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.8 = import_ref ir1, inst+5, unloaded +// CHECK:STDOUT: %Impl: = namespace file.%Impl.import, [template] { +// CHECK:STDOUT: .C = %import_ref.6 +// CHECK:STDOUT: .HasF = %import_ref.7 +// CHECK:STDOUT: import Impl//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1 = import_ref Impl//default, inst+13, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Impl//default, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.5 = import_ref Impl//default, inst+10, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.4 = import_ref Impl//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.5: = import_ref Impl//default, inst+21, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.6: type = import_ref Impl//default, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.7: type = import_ref Impl//default, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.8 = import_ref Impl//default, inst+5, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Impl = %Impl +// CHECK:STDOUT: .Impl = imports.%Impl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Impl.import = import Impl -// CHECK:STDOUT: %Impl: = namespace %Impl.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { -// CHECK:STDOUT: %Impl.ref: = name_ref Impl, %Impl [template = %Impl] +// CHECK:STDOUT: %Impl.ref: = name_ref Impl, imports.%Impl [template = imports.%Impl] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.6 [template = constants.%C] // CHECK:STDOUT: %c.loc4_6.1: %C = param c // CHECK:STDOUT: @G.%c: %C = bind_name c, %c.loc4_6.1 @@ -156,7 +164,7 @@ fn G(c: Impl.C) { // CHECK:STDOUT: fn @G(%c: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %Impl.ref: = name_ref Impl, file.%Impl [template = file.%Impl] +// CHECK:STDOUT: %Impl.ref: = name_ref Impl, imports.%Impl [template = imports.%Impl] // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.7 [template = constants.%.2] // CHECK:STDOUT: %F.ref: %.5 = name_ref F, imports.%import_ref.3 [template = constants.%.6] // CHECK:STDOUT: %.1: %F.type.1 = interface_witness_access imports.%import_ref.5, element0 [template = constants.%F.2] @@ -164,7 +172,10 @@ fn G(c: Impl.C) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1(); +// CHECK:STDOUT: generic fn @F.1(constants.%Self: %.2) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2(); // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/basic.carbon b/toolchain/check/testdata/impl/no_prelude/basic.carbon index fb28ac8afcdcd..ee870b2f65b1e 100644 --- a/toolchain/check/testdata/impl/no_prelude/basic.carbon +++ b/toolchain/check/testdata/impl/no_prelude/basic.carbon @@ -73,11 +73,15 @@ impl C as Simple { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Simple.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/import_self.carbon b/toolchain/check/testdata/impl/no_prelude/import_self.carbon index 3fe431134afb5..081b1639f01d4 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_self.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_self.carbon @@ -52,20 +52,20 @@ fn F(x: (), y: ()) -> () { // CHECK:STDOUT: interface @Add { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %Op.decl: %Op.type = fn_decl @Op [template = constants.%Op] { -// CHECK:STDOUT: %Self.ref.loc5_15: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %self.loc5_9.1: @Add.%Self.ref.loc5_15 (%Self) = param self -// CHECK:STDOUT: %self.loc5_9.2: @Add.%Self.ref.loc5_15 (%Self) = bind_name self, %self.loc5_9.1 -// CHECK:STDOUT: %Self.ref.loc5_28: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %other.loc5_21.1: @Add.%Self.ref.loc5_15 (%Self) = param other -// CHECK:STDOUT: %other.loc5_21.2: @Add.%Self.ref.loc5_15 (%Self) = bind_name other, %other.loc5_21.1 -// CHECK:STDOUT: %Self.ref.loc5_37: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = %Self.ref.loc5_15 (constants.%Self)] -// CHECK:STDOUT: %return.var: ref %Self = var +// CHECK:STDOUT: %Self.ref.loc5_15: %.1 = name_ref Self, %Self [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc5_9.1: @Op.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc5_9.2: @Op.%Self (%Self) = bind_name self, %self.loc5_9.1 +// CHECK:STDOUT: %Self.ref.loc5_28: %.1 = name_ref Self, %Self [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %other.loc5_21.1: @Op.%Self (%Self) = param other +// CHECK:STDOUT: %other.loc5_21.2: @Op.%Self (%Self) = bind_name other, %other.loc5_21.1 +// CHECK:STDOUT: %Self.ref.loc5_37: %.1 = name_ref Self, %Self [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = @Op.%Self (constants.%Self)] +// CHECK:STDOUT: %return.var: ref @Op.%Self (%Self) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc5_41: %.3 = assoc_entity element0, %Op.decl [template = constants.%.4] // CHECK:STDOUT: @@ -75,8 +75,15 @@ fn F(x: (), y: ()) -> () { // CHECK:STDOUT: witness = (%Op.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[@Add.%self.loc5_9.2: @Add.%Self.ref.loc5_15 (%Self)](@Add.%other.loc5_21.2: @Add.%Self.ref.loc5_15 (%Self)) -> %Self -// CHECK:STDOUT: generic [@Add.%Self: %.1]; +// CHECK:STDOUT: generic fn @Op(@Add.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@Add.%self.loc5_9.2: @Op.%Self (%Self)](@Add.%other.loc5_21.2: @Op.%Self (%Self)) -> @Op.%Self (%Self); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Op(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: @@ -97,11 +104,11 @@ fn F(x: (), y: ()) -> () { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %.4 = import_ref ir1, inst+24, loaded [template = constants.%.5] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir1, inst+19, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+19, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.4 = import_ref Main//a, inst+25, loaded [template = constants.%.5] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Main//a, inst+19, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//a, inst+19, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -163,7 +170,11 @@ fn F(x: (), y: ()) -> () { // CHECK:STDOUT: return %.loc7_53 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%x: %.1, %y: %.1) -> %.1 { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon b/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon index e0fdfbf3111aa..997a48e127086 100644 --- a/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/impl/no_prelude/no_definition_in_impl_file.carbon @@ -119,8 +119,8 @@ impl () as D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//decl_in_api_definition_in_impl, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//decl_in_api_definition_in_impl, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -169,8 +169,8 @@ impl () as D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//decl_in_api_definition_in_impl, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//decl_in_api_definition_in_impl, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -228,8 +228,8 @@ impl () as D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//decl_only_in_api, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//decl_only_in_api, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -287,8 +287,8 @@ impl () as D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//decl_in_api_decl_in_impl, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//decl_in_api_decl_in_impl, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon b/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon index b5cbd8724e78c..2ccedab473830 100644 --- a/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon +++ b/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon @@ -56,10 +56,10 @@ class A { // CHECK:STDOUT: interface @DefaultConstructible { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %Make.decl: %Make.type.1 = fn_decl @Make.1 [template = constants.%Make.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc12_16.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %.loc12_16.2: type = converted %Self.ref, %.loc12_16.1 [symbolic = %Self.ref (constants.%Self)] -// CHECK:STDOUT: %return.var: ref %Self = var +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = @Make.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_16.1: type = facet_type_access %Self.ref [symbolic = @Make.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_16.2: type = converted %Self.ref, %.loc12_16.1 [symbolic = @Make.1.%Self (constants.%Self)] +// CHECK:STDOUT: %return.var: ref @Make.1.%Self (%Self) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_20: %.3 = assoc_entity element0, %Make.decl [template = constants.%.4] // CHECK:STDOUT: @@ -96,8 +96,11 @@ class A { // CHECK:STDOUT: .Self = constants.%A // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Make.1() -> %Self -// CHECK:STDOUT: generic [@DefaultConstructible.%Self: %.1]; +// CHECK:STDOUT: generic fn @Make.1(@DefaultConstructible.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @Make.1.%Self (%Self); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Make.2() -> @impl.%return.var: %C { // CHECK:STDOUT: !entry: @@ -107,3 +110,7 @@ class A { // CHECK:STDOUT: return %.loc21_34 to @impl.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @Make.1(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon b/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon index ebf60e7a25b0c..92f41a22edd1a 100644 --- a/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon +++ b/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon @@ -114,20 +114,20 @@ impl D as SelfNested { // CHECK:STDOUT: interface @UseSelf { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %self.loc12_8.1: @UseSelf.%Self.ref.loc12_14 (%Self.1) = param self -// CHECK:STDOUT: %self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self.1) = bind_name self, %self.loc12_8.1 -// CHECK:STDOUT: %Self.ref.loc12_23: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %.loc12_23.1: type = facet_type_access %Self.ref.loc12_23 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %.loc12_23.2: type = converted %Self.ref.loc12_23, %.loc12_23.1 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %x.loc12_20.1: @UseSelf.%Self.ref.loc12_14 (%Self.1) = param x -// CHECK:STDOUT: %x.loc12_20.2: @UseSelf.%Self.ref.loc12_14 (%Self.1) = bind_name x, %x.loc12_20.1 -// CHECK:STDOUT: %Self.ref.loc12_32: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %.loc12_32.1: type = facet_type_access %Self.ref.loc12_32 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %.loc12_32.2: type = converted %Self.ref.loc12_32, %.loc12_32.1 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] -// CHECK:STDOUT: %return.var: ref %Self.1 = var +// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %self.loc12_8.1: @F.1.%Self (%Self.1) = param self +// CHECK:STDOUT: %self.loc12_8.2: @F.1.%Self (%Self.1) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref.loc12_23: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_23.1: type = facet_type_access %Self.ref.loc12_23 [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_23.2: type = converted %Self.ref.loc12_23, %.loc12_23.1 [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %x.loc12_20.1: @F.1.%Self (%Self.1) = param x +// CHECK:STDOUT: %x.loc12_20.2: @F.1.%Self (%Self.1) = bind_name x, %x.loc12_20.1 +// CHECK:STDOUT: %Self.ref.loc12_32: %.1 = name_ref Self, %Self [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_32.1: type = facet_type_access %Self.ref.loc12_32 [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_32.2: type = converted %Self.ref.loc12_32, %.loc12_32.1 [symbolic = @F.1.%Self (constants.%Self.1)] +// CHECK:STDOUT: %return.var: ref @F.1.%Self (%Self.1) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_36: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: @@ -140,20 +140,20 @@ impl D as SelfNested { // CHECK:STDOUT: interface @SelfNested { // CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2] // CHECK:STDOUT: %F.decl: %F.type.4 = fn_decl @F.4 [template = constants.%F.4] { -// CHECK:STDOUT: %Self.ref.loc28_12: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] -// CHECK:STDOUT: %.loc28_16.1: type = facet_type_access %Self.ref.loc28_12 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] -// CHECK:STDOUT: %.loc28_16.2: type = converted %Self.ref.loc28_12, %.loc28_16.1 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] -// CHECK:STDOUT: %.loc28_16.3: type = ptr_type %Self.2 [symbolic = %.loc28_16.3 (constants.%.10)] -// CHECK:STDOUT: %Self.ref.loc28_24: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] -// CHECK:STDOUT: %.loc28_24.1: type = facet_type_access %Self.ref.loc28_24 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] -// CHECK:STDOUT: %.loc28_24.2: type = converted %Self.ref.loc28_24, %.loc28_24.1 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] +// CHECK:STDOUT: %Self.ref.loc28_12: %.9 = name_ref Self, %Self [symbolic = @F.4.%Self (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_16.1: type = facet_type_access %Self.ref.loc28_12 [symbolic = @F.4.%Self (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_16.2: type = converted %Self.ref.loc28_12, %.loc28_16.1 [symbolic = @F.4.%Self (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_16.3: type = ptr_type %Self.2 [symbolic = @F.4.%.1 (constants.%.10)] +// CHECK:STDOUT: %Self.ref.loc28_24: %.9 = name_ref Self, %Self [symbolic = @F.4.%Self (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_24.1: type = facet_type_access %Self.ref.loc28_24 [symbolic = @F.4.%Self (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_24.2: type = converted %Self.ref.loc28_24, %.loc28_24.1 [symbolic = @F.4.%Self (constants.%Self.2)] // CHECK:STDOUT: %.loc28_35.1: %.2 = tuple_literal () // CHECK:STDOUT: %.loc28_35.2: type = converted %.loc28_35.1, constants.%.2 [template = constants.%.2] -// CHECK:STDOUT: %.loc28_36: type = struct_type {.x: %Self.2, .y: %.2} [symbolic = %.loc28_36 (constants.%.11)] +// CHECK:STDOUT: %.loc28_36: type = struct_type {.x: %Self.2, .y: %.2} [symbolic = @F.4.%.2 (constants.%.11)] // CHECK:STDOUT: %.loc28_37.1: %.12 = tuple_literal (%.loc28_16.3, %.loc28_36) -// CHECK:STDOUT: %.loc28_37.2: type = converted %.loc28_37.1, constants.%.13 [symbolic = %.loc28_37.2 (constants.%.13)] -// CHECK:STDOUT: %x.loc28_8.1: @SelfNested.%.loc28_37.2 (%.13) = param x -// CHECK:STDOUT: %x.loc28_8.2: @SelfNested.%.loc28_37.2 (%.13) = bind_name x, %x.loc28_8.1 +// CHECK:STDOUT: %.loc28_37.2: type = converted %.loc28_37.1, constants.%.13 [symbolic = @F.4.%.3 (constants.%.13)] +// CHECK:STDOUT: %x.loc28_8.1: @F.4.%.3 (%.13) = param x +// CHECK:STDOUT: %x.loc28_8.2: @F.4.%.3 (%.13) = bind_name x, %x.loc28_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc28_39: %.14 = assoc_entity element0, %F.decl [template = constants.%.15] // CHECK:STDOUT: @@ -249,8 +249,11 @@ impl D as SelfNested { // CHECK:STDOUT: .Self = constants.%D // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1[@UseSelf.%self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self.1)](@UseSelf.%x.loc12_20.2: @UseSelf.%Self.ref.loc12_14 (%Self.1)) -> %Self.1 -// CHECK:STDOUT: generic [@UseSelf.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@UseSelf.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@UseSelf.%self.loc12_8.2: @F.1.%Self (%Self.1)](@UseSelf.%x.loc12_20.2: @F.1.%Self (%Self.1)) -> @F.1.%Self (%Self.1); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2[@impl.1.%self.loc20_8.2: %C](@impl.1.%x.loc20_17.2: %C) -> @impl.1.%return.var: %C { // CHECK:STDOUT: !entry: @@ -268,10 +271,27 @@ impl D as SelfNested { // CHECK:STDOUT: return %.loc24_48 to @impl.2.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.4(@SelfNested.%x.loc28_8.2: @SelfNested.%.loc28_37.2 (%.13)) -// CHECK:STDOUT: generic [@SelfNested.%Self: %.9]; +// CHECK:STDOUT: generic fn @F.4(@SelfNested.%Self: %.9) { +// CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.1: type = ptr_type @F.4.%Self (%Self.2) [symbolic = %.1 (constants.%.10)] +// CHECK:STDOUT: %.2: type = struct_type {.x: @F.4.%Self (%Self.2), .y: %.2} [symbolic = %.2 (constants.%.11)] +// CHECK:STDOUT: %.3: type = tuple_type (@F.4.%.1 (%.10), @F.4.%.2 (%.11)) [symbolic = %.3 (constants.%.13)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@SelfNested.%x.loc28_8.2: @F.4.%.3 (%.13)); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.5(@impl.3.%x.loc32_8.2: %.18); // CHECK:STDOUT: // CHECK:STDOUT: fn @F.6(@impl.4.%x.loc36_8.2: %.22); // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.1) { +// CHECK:STDOUT: %Self => constants.%Self.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.4(constants.%Self.2) { +// CHECK:STDOUT: %Self => constants.%Self.2 +// CHECK:STDOUT: %.1 => constants.%.10 +// CHECK:STDOUT: %.2 => constants.%.11 +// CHECK:STDOUT: %.3 => constants.%.13 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/redeclaration.carbon b/toolchain/check/testdata/impl/redeclaration.carbon index 69e43d31eca39..dd48c35c3c2ec 100644 --- a/toolchain/check/testdata/impl/redeclaration.carbon +++ b/toolchain/check/testdata/impl/redeclaration.carbon @@ -32,19 +32,26 @@ impl i32 as I {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: .X = %X.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/index/array_element_access.carbon b/toolchain/check/testdata/index/array_element_access.carbon index b30b7438e0004..7d35871c361d3 100644 --- a/toolchain/check/testdata/index/array_element_access.carbon +++ b/toolchain/check/testdata/index/array_element_access.carbon @@ -31,22 +31,28 @@ var d: i32 = a[b]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 2 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/index/expr_category.carbon b/toolchain/check/testdata/index/expr_category.carbon index 8bc6e54d9c885..60edeb0eabff5 100644 --- a/toolchain/check/testdata/index/expr_category.carbon +++ b/toolchain/check/testdata/index/expr_category.carbon @@ -53,23 +53,27 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .ValueBinding = %ValueBinding.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17: i32 = int_literal 3 [template = constants.%.2] diff --git a/toolchain/check/testdata/index/fail_array_large_index.carbon b/toolchain/check/testdata/index/fail_array_large_index.carbon index d23006c9852f6..ba265c3c49743 100644 --- a/toolchain/check/testdata/index/fail_array_large_index.carbon +++ b/toolchain/check/testdata/index/fail_array_large_index.carbon @@ -38,20 +38,27 @@ var c: i32 = a[0x7FFF_FFFF]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon index 3076765839a39..a39aa0ec36d33 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -31,18 +31,26 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] @@ -71,7 +79,7 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: assign file.%a.var, %.loc11_24 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc15_16: f64 = float_literal 2.6000000000000001 [template = constants.%.8] -// CHECK:STDOUT: %.loc15_19.1: ref i32 = array_index %a.ref, +// CHECK:STDOUT: %.loc15_19.1: ref i32 = array_index %a.ref, [template = ] // CHECK:STDOUT: %.loc15_19.2: i32 = bind_value %.loc15_19.1 // CHECK:STDOUT: assign file.%b.var, %.loc15_19.2 // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon index b3632d7412c87..4cde618a09a02 100644 --- a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon @@ -30,18 +30,26 @@ var b: i32 = a[1]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 [template = constants.%.2] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/index/fail_empty_tuple_access.carbon b/toolchain/check/testdata/index/fail_empty_tuple_access.carbon index bc59ee29addf1..dfaaf654a712a 100644 --- a/toolchain/check/testdata/index/fail_empty_tuple_access.carbon +++ b/toolchain/check/testdata/index/fail_empty_tuple_access.carbon @@ -12,9 +12,9 @@ fn F() {} fn Run() { // CHECK:STDERR: fail_empty_tuple_access.carbon:[[@LINE+3]]:3: ERROR: Tuple element index `0` is past the end of type `()`. - // CHECK:STDERR: F()[0]; - // CHECK:STDERR: ^~~~~~ - F()[0]; + // CHECK:STDERR: F().0; + // CHECK:STDERR: ^~~~~ + F().0; } // CHECK:STDOUT: --- fail_empty_tuple_access.carbon @@ -28,14 +28,25 @@ fn Run() { // CHECK:STDOUT: %.2: i32 = int_literal 0 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } @@ -52,7 +63,7 @@ fn Run() { // CHECK:STDOUT: %.loc17_7: i32 = int_literal 0 [template = constants.%.2] // CHECK:STDOUT: %.loc17_4.1: ref %.1 = temporary_storage // CHECK:STDOUT: %.loc17_4.2: ref %.1 = temporary %.loc17_4.1, %F.call -// CHECK:STDOUT: %.loc17_8: ref = tuple_index %.loc17_4.2, +// CHECK:STDOUT: %.loc17_6: ref = tuple_index %.loc17_4.2, [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_expr_category.carbon b/toolchain/check/testdata/index/fail_expr_category.carbon index ae0e1c843408b..946349ab2b678 100644 --- a/toolchain/check/testdata/index/fail_expr_category.carbon +++ b/toolchain/check/testdata/index/fail_expr_category.carbon @@ -55,20 +55,26 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17: i32 = int_literal 3 [template = constants.%.2] diff --git a/toolchain/check/testdata/index/fail_invalid_base.carbon b/toolchain/check/testdata/index/fail_invalid_base.carbon index cc0d5ba1dea3b..d699173531b3d 100644 --- a/toolchain/check/testdata/index/fail_invalid_base.carbon +++ b/toolchain/check/testdata/index/fail_invalid_base.carbon @@ -50,17 +50,22 @@ var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .N = %N // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .F = %F.decl @@ -69,7 +74,6 @@ var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %N: = namespace [template] {} // CHECK:STDOUT: %int.make_type_32.loc16: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc16_8.1: type = value_of_initializer %int.make_type_32.loc16 [template = i32] diff --git a/toolchain/check/testdata/index/fail_name_not_found.carbon b/toolchain/check/testdata/index/fail_name_not_found.carbon index f1237ebe89182..9f60f7c8dbdf2 100644 --- a/toolchain/check/testdata/index/fail_name_not_found.carbon +++ b/toolchain/check/testdata/index/fail_name_not_found.carbon @@ -27,16 +27,25 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_negative_indexing.carbon b/toolchain/check/testdata/index/fail_negative_indexing.carbon index 70fc42e8c64f8..eb2ca5550acba 100644 --- a/toolchain/check/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/index/fail_negative_indexing.carbon @@ -8,96 +8,149 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_negative_indexing.carbon -var a: (i32, i32) = (12, 6); -// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+3]]:16: ERROR: Cannot access member of interface Negate in type i32 that does not implement that interface. +let a: [i32; 2] = (12, 6); +// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+4]]:16: ERROR: Cannot access member of interface Negate in type i32 that does not implement that interface. // CHECK:STDERR: var b: i32 = a[-10]; // CHECK:STDERR: ^~~ +// CHECK:STDERR: var b: i32 = a[-10]; +let c: (i32, i32) = (1, 2); +// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+7]]:14: ERROR: Member name of type `` in compound member access is not an instance member or an interface member. +// CHECK:STDERR: let d: i32 = a.(-1); +// CHECK:STDERR: ^~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+3]]:17: ERROR: Cannot access member of interface Negate in type i32 that does not implement that interface. +// CHECK:STDERR: let d: i32 = a.(-1); +// CHECK:STDERR: ^~ +let d: i32 = a.(-1); + // CHECK:STDOUT: --- fail_negative_indexing.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = tuple_type (type, type) [template] -// CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template] +// CHECK:STDOUT: %.2: i32 = int_literal 2 [template] +// CHECK:STDOUT: %.3: type = array_type %.2, i32 [template] // CHECK:STDOUT: %.4: type = ptr_type %.3 [template] // CHECK:STDOUT: %.5: i32 = int_literal 12 [template] // CHECK:STDOUT: %.6: i32 = int_literal 6 [template] -// CHECK:STDOUT: %tuple: %.3 = tuple_value (%.5, %.6) [template] -// CHECK:STDOUT: %.7: i32 = int_literal 10 [template] -// CHECK:STDOUT: %.8: type = interface_type @Negate [template] -// CHECK:STDOUT: %Self: %.8 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %.7: type = tuple_type (i32, i32) [template] +// CHECK:STDOUT: %.8: i32 = int_literal 0 [template] +// CHECK:STDOUT: %.9: i32 = int_literal 1 [template] +// CHECK:STDOUT: %array: %.3 = tuple_value (%.5, %.6) [template] +// CHECK:STDOUT: %.10: i32 = int_literal 10 [template] +// CHECK:STDOUT: %.11: type = interface_type @Negate [template] +// CHECK:STDOUT: %Self: %.11 = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: %Op.type: type = fn_type @Op [template] // CHECK:STDOUT: %Op: %Op.type = struct_value () [template] -// CHECK:STDOUT: %.9: type = assoc_entity_type @Negate, %Op.type [template] -// CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.8 [template] +// CHECK:STDOUT: %.12: type = assoc_entity_type @Negate, %Op.type [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.6 [template] +// CHECK:STDOUT: %.14: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %.15: type = ptr_type %.7 [template] +// CHECK:STDOUT: %tuple: %.7 = tuple_value (%.9, %.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: type = import_ref ir4, inst+67, loaded [template = constants.%.8] -// CHECK:STDOUT: %import_ref.5 = import_ref ir4, inst+69, unloaded -// CHECK:STDOUT: %import_ref.6: %.9 = import_ref ir4, inst+84, loaded [template = constants.%.10] -// CHECK:STDOUT: %import_ref.7 = import_ref ir4, inst+80, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir4, inst+80, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Negate = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/arithmetic, inst+72, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/arithmetic, inst+74, unloaded +// CHECK:STDOUT: %import_ref.4: %.12 = import_ref Core//prelude/operators/arithmetic, inst+90, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+85, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+85, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .c = @__global_init.%c +// CHECK:STDOUT: .d = @__global_init.%d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) -// CHECK:STDOUT: %.loc11_17.2: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32] -// CHECK:STDOUT: %.loc11_17.3: type = converted %int.make_type_32.loc11_9, %.loc11_17.2 [template = i32] -// CHECK:STDOUT: %.loc11_17.4: type = value_of_initializer %int.make_type_32.loc11_14 [template = i32] -// CHECK:STDOUT: %.loc11_17.5: type = converted %int.make_type_32.loc11_14, %.loc11_17.4 [template = i32] -// CHECK:STDOUT: %.loc11_17.6: type = converted %.loc11_17.1, constants.%.3 [template = constants.%.3] -// CHECK:STDOUT: %a.var: ref %.3 = var a -// CHECK:STDOUT: %a: ref %.3 = bind_name a, %a.var -// CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] -// CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32.loc15, %.loc15_8.1 [template = i32] +// CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc11_14: i32 = int_literal 2 [template = constants.%.2] +// CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] +// CHECK:STDOUT: %.loc11_9.2: type = converted %int.make_type_32.loc11, %.loc11_9.1 [template = i32] +// CHECK:STDOUT: %.loc11_15: type = array_type %.loc11_14, i32 [template = constants.%.3] +// CHECK:STDOUT: %int.make_type_32.loc16: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc16_8.1: type = value_of_initializer %int.make_type_32.loc16 [template = i32] +// CHECK:STDOUT: %.loc16_8.2: type = converted %int.make_type_32.loc16, %.loc16_8.1 [template = i32] // CHECK:STDOUT: %b.var: ref i32 = var b // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var +// CHECK:STDOUT: %int.make_type_32.loc18_9: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %int.make_type_32.loc18_14: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc18_17.1: %.14 = tuple_literal (%int.make_type_32.loc18_9, %int.make_type_32.loc18_14) +// CHECK:STDOUT: %.loc18_17.2: type = value_of_initializer %int.make_type_32.loc18_9 [template = i32] +// CHECK:STDOUT: %.loc18_17.3: type = converted %int.make_type_32.loc18_9, %.loc18_17.2 [template = i32] +// CHECK:STDOUT: %.loc18_17.4: type = value_of_initializer %int.make_type_32.loc18_14 [template = i32] +// CHECK:STDOUT: %.loc18_17.5: type = converted %int.make_type_32.loc18_14, %.loc18_17.4 [template = i32] +// CHECK:STDOUT: %.loc18_17.6: type = converted %.loc18_17.1, constants.%.7 [template = constants.%.7] +// CHECK:STDOUT: %int.make_type_32.loc26: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc26_8.1: type = value_of_initializer %int.make_type_32.loc26 [template = i32] +// CHECK:STDOUT: %.loc26_8.2: type = converted %int.make_type_32.loc26, %.loc26_8.1 [template = i32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @Negate { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .Op = imports.%import_ref.6 -// CHECK:STDOUT: witness = (imports.%import_ref.7) +// CHECK:STDOUT: .Self = imports.%import_ref.3 +// CHECK:STDOUT: .Op = imports.%import_ref.4 +// CHECK:STDOUT: witness = (imports.%import_ref.5) // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[%self: %Self]() -> %Self; +// CHECK:STDOUT: generic fn @Op(constants.%Self: %.11) { +// CHECK:STDOUT: %Self: %.11 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self]() -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_22: i32 = int_literal 12 [template = constants.%.5] -// CHECK:STDOUT: %.loc11_26: i32 = int_literal 6 [template = constants.%.6] -// CHECK:STDOUT: %.loc11_27.1: %.3 = tuple_literal (%.loc11_22, %.loc11_26) -// CHECK:STDOUT: %.loc11_27.2: ref i32 = tuple_access file.%a.var, element0 -// CHECK:STDOUT: %.loc11_27.3: init i32 = initialize_from %.loc11_22 to %.loc11_27.2 [template = constants.%.5] -// CHECK:STDOUT: %.loc11_27.4: ref i32 = tuple_access file.%a.var, element1 -// CHECK:STDOUT: %.loc11_27.5: init i32 = initialize_from %.loc11_26 to %.loc11_27.4 [template = constants.%.6] -// CHECK:STDOUT: %.loc11_27.6: init %.3 = tuple_init (%.loc11_27.3, %.loc11_27.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_28: init %.3 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 -// CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a -// CHECK:STDOUT: %.loc15_17: i32 = int_literal 10 [template = constants.%.7] -// CHECK:STDOUT: %.loc15_19: ref = tuple_index %a.ref, -// CHECK:STDOUT: assign file.%b.var, +// CHECK:STDOUT: %.loc11_20: i32 = int_literal 12 [template = constants.%.5] +// CHECK:STDOUT: %.loc11_24: i32 = int_literal 6 [template = constants.%.6] +// CHECK:STDOUT: %.loc11_25.1: %.7 = tuple_literal (%.loc11_20, %.loc11_24) +// CHECK:STDOUT: %.loc11_25.2: ref %.3 = temporary_storage +// CHECK:STDOUT: %.loc11_25.3: i32 = int_literal 0 [template = constants.%.8] +// CHECK:STDOUT: %.loc11_25.4: ref i32 = array_index %.loc11_25.2, %.loc11_25.3 +// CHECK:STDOUT: %.loc11_25.5: init i32 = initialize_from %.loc11_20 to %.loc11_25.4 [template = constants.%.5] +// CHECK:STDOUT: %.loc11_25.6: i32 = int_literal 1 [template = constants.%.9] +// CHECK:STDOUT: %.loc11_25.7: ref i32 = array_index %.loc11_25.2, %.loc11_25.6 +// CHECK:STDOUT: %.loc11_25.8: init i32 = initialize_from %.loc11_24 to %.loc11_25.7 [template = constants.%.6] +// CHECK:STDOUT: %.loc11_25.9: init %.3 = array_init (%.loc11_25.5, %.loc11_25.8) to %.loc11_25.2 [template = constants.%array] +// CHECK:STDOUT: %.loc11_26.1: init %.3 = converted %.loc11_25.1, %.loc11_25.9 [template = constants.%array] +// CHECK:STDOUT: %.loc11_26.2: ref %.3 = temporary %.loc11_25.2, %.loc11_26.1 +// CHECK:STDOUT: %.loc11_26.3: %.3 = bind_value %.loc11_26.2 +// CHECK:STDOUT: %a: %.3 = bind_name a, %.loc11_26.3 +// CHECK:STDOUT: %a.ref.loc16: %.3 = name_ref a, %a +// CHECK:STDOUT: %.loc16_17: i32 = int_literal 10 [template = constants.%.10] +// CHECK:STDOUT: %.loc16_19.1: ref %.3 = value_as_ref %a.ref.loc16 +// CHECK:STDOUT: %.loc16_19.2: ref i32 = array_index %.loc16_19.1, [template = ] +// CHECK:STDOUT: %.loc16_19.3: i32 = bind_value %.loc16_19.2 +// CHECK:STDOUT: assign file.%b.var, %.loc16_19.3 +// CHECK:STDOUT: %.loc18_22: i32 = int_literal 1 [template = constants.%.9] +// CHECK:STDOUT: %.loc18_25: i32 = int_literal 2 [template = constants.%.2] +// CHECK:STDOUT: %.loc18_26: %.7 = tuple_literal (%.loc18_22, %.loc18_25) +// CHECK:STDOUT: %tuple: %.7 = tuple_value (%.loc18_22, %.loc18_25) [template = constants.%tuple] +// CHECK:STDOUT: %.loc18_27: %.7 = converted %.loc18_26, %tuple [template = constants.%tuple] +// CHECK:STDOUT: %c: %.7 = bind_name c, %.loc18_27 +// CHECK:STDOUT: %a.ref.loc26: %.3 = name_ref a, %a +// CHECK:STDOUT: %.loc26: i32 = int_literal 1 [template = constants.%.9] +// CHECK:STDOUT: %d: i32 = bind_name d, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_non_deterministic_type.carbon b/toolchain/check/testdata/index/fail_non_deterministic_type.carbon index de137b145690c..4bd346ca657e0 100644 --- a/toolchain/check/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/check/testdata/index/fail_non_deterministic_type.carbon @@ -11,9 +11,9 @@ var a: (i32, i32) = (2, 3); var b: i32 = 0; // CHECK:STDERR: fail_non_deterministic_type.carbon:[[@LINE+3]]:14: ERROR: Tuple index must be a constant. -// CHECK:STDERR: var c: i32 = a[b]; -// CHECK:STDERR: ^~~~ -var c: i32 = a[b]; +// CHECK:STDERR: var c: i32 = a.(b); +// CHECK:STDERR: ^~~~~ +var c: i32 = a.(b); // CHECK:STDOUT: --- fail_non_deterministic_type.carbon // CHECK:STDOUT: @@ -31,21 +31,27 @@ var c: i32 = a[b]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) @@ -86,8 +92,8 @@ var c: i32 = a[b]; // CHECK:STDOUT: assign file.%b.var, %.loc12 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %b.ref: ref i32 = name_ref b, file.%b -// CHECK:STDOUT: %.loc16_16: i32 = bind_value %b.ref -// CHECK:STDOUT: %.loc16_17: ref = tuple_index %a.ref, +// CHECK:STDOUT: %.loc16_17: i32 = bind_value %b.ref +// CHECK:STDOUT: %.loc16_15: ref = tuple_index %a.ref, [template = ] // CHECK:STDOUT: assign file.%c.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_non_tuple_access.carbon b/toolchain/check/testdata/index/fail_non_tuple_access.carbon index 95e116341cfce..77adf89c12cf5 100644 --- a/toolchain/check/testdata/index/fail_non_tuple_access.carbon +++ b/toolchain/check/testdata/index/fail_non_tuple_access.carbon @@ -9,10 +9,11 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_non_tuple_access.carbon fn Main() { - // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+3]]:3: ERROR: Type `i32` does not support indexing. - // CHECK:STDERR: 0[1]; - // CHECK:STDERR: ^~~~ - 0[1]; + var non_tuple: [i32; 1] = (1,); + // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+3]]:20: ERROR: Type `[i32; 1]` does not support tuple indexing. Only tuples can be indexed that way. + // CHECK:STDERR: var first: i32 = non_tuple.0; + // CHECK:STDERR: ^~~~~~~~~~~ + var first: i32 = non_tuple.0; } // CHECK:STDOUT: --- fail_non_tuple_access.carbon @@ -21,24 +22,66 @@ fn Main() { // CHECK:STDOUT: %Main.type: type = fn_type @Main [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Main: %Main.type = struct_value () [template] -// CHECK:STDOUT: %.2: i32 = int_literal 0 [template] -// CHECK:STDOUT: %.3: i32 = int_literal 1 [template] +// CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] +// CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.2: i32 = int_literal 1 [template] +// CHECK:STDOUT: %.3: type = array_type %.2, i32 [template] +// CHECK:STDOUT: %.4: type = ptr_type %.3 [template] +// CHECK:STDOUT: %.5: type = tuple_type (i32) [template] +// CHECK:STDOUT: %.6: i32 = int_literal 0 [template] +// CHECK:STDOUT: %array: %.3 = tuple_value (%.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc15_3: i32 = int_literal 0 [template = constants.%.2] -// CHECK:STDOUT: %.loc15_5: i32 = int_literal 1 [template = constants.%.3] +// CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc12_24: i32 = int_literal 1 [template = constants.%.2] +// CHECK:STDOUT: %.loc12_19.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32] +// CHECK:STDOUT: %.loc12_19.2: type = converted %int.make_type_32.loc12, %.loc12_19.1 [template = i32] +// CHECK:STDOUT: %.loc12_25: type = array_type %.loc12_24, i32 [template = constants.%.3] +// CHECK:STDOUT: %non_tuple.var: ref %.3 = var non_tuple +// CHECK:STDOUT: %non_tuple: ref %.3 = bind_name non_tuple, %non_tuple.var +// CHECK:STDOUT: %.loc12_30: i32 = int_literal 1 [template = constants.%.2] +// CHECK:STDOUT: %.loc12_32.1: %.5 = tuple_literal (%.loc12_30) +// CHECK:STDOUT: %.loc12_32.2: i32 = int_literal 0 [template = constants.%.6] +// CHECK:STDOUT: %.loc12_32.3: ref i32 = array_index %non_tuple.var, %.loc12_32.2 +// CHECK:STDOUT: %.loc12_32.4: init i32 = initialize_from %.loc12_30 to %.loc12_32.3 [template = constants.%.2] +// CHECK:STDOUT: %.loc12_32.5: init %.3 = array_init (%.loc12_32.4) to %non_tuple.var [template = constants.%array] +// CHECK:STDOUT: %.loc12_33: init %.3 = converted %.loc12_32.1, %.loc12_32.5 [template = constants.%array] +// CHECK:STDOUT: assign %non_tuple.var, %.loc12_33 +// CHECK:STDOUT: %int.make_type_32.loc16: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc16_14.1: type = value_of_initializer %int.make_type_32.loc16 [template = i32] +// CHECK:STDOUT: %.loc16_14.2: type = converted %int.make_type_32.loc16, %.loc16_14.1 [template = i32] +// CHECK:STDOUT: %first.var: ref i32 = var first +// CHECK:STDOUT: %first: ref i32 = bind_name first, %first.var +// CHECK:STDOUT: %non_tuple.ref: ref %.3 = name_ref non_tuple, %non_tuple +// CHECK:STDOUT: %.loc16_30: i32 = int_literal 0 [template = constants.%.6] +// CHECK:STDOUT: assign %first.var, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_out_of_bound_not_literal.carbon b/toolchain/check/testdata/index/fail_out_of_bound_not_literal.carbon index 039154ed17a7c..526c1df9d0595 100644 --- a/toolchain/check/testdata/index/fail_out_of_bound_not_literal.carbon +++ b/toolchain/check/testdata/index/fail_out_of_bound_not_literal.carbon @@ -10,9 +10,9 @@ var a: (i32, i32) = (12, 34); // CHECK:STDERR: fail_out_of_bound_not_literal.carbon:[[@LINE+3]]:14: ERROR: Tuple element index `2` is past the end of type `(i32, i32)`. -// CHECK:STDERR: var b: i32 = a[{.index = 2}.index]; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ -var b: i32 = a[{.index = 2}.index]; +// CHECK:STDERR: var b: i32 = a.({.index = 2}.index); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ +var b: i32 = a.({.index = 2}.index); // CHECK:STDOUT: --- fail_out_of_bound_not_literal.carbon // CHECK:STDOUT: @@ -32,19 +32,26 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) @@ -77,12 +84,12 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: %.loc11_29: init %.3 = converted %.loc11_28.1, %.loc11_28.6 [template = constants.%tuple] // CHECK:STDOUT: assign file.%a.var, %.loc11_29 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a -// CHECK:STDOUT: %.loc15_26: i32 = int_literal 2 [template = constants.%.7] -// CHECK:STDOUT: %.loc15_27.1: %.8 = struct_literal (%.loc15_26) -// CHECK:STDOUT: %struct: %.8 = struct_value (%.loc15_26) [template = constants.%struct] -// CHECK:STDOUT: %.loc15_27.2: %.8 = converted %.loc15_27.1, %struct [template = constants.%struct] -// CHECK:STDOUT: %.loc15_28: i32 = struct_access %.loc15_27.2, element0 [template = constants.%.7] -// CHECK:STDOUT: %.loc15_34: ref = tuple_index %a.ref, +// CHECK:STDOUT: %.loc15_27: i32 = int_literal 2 [template = constants.%.7] +// CHECK:STDOUT: %.loc15_28.1: %.8 = struct_literal (%.loc15_27) +// CHECK:STDOUT: %struct: %.8 = struct_value (%.loc15_27) [template = constants.%struct] +// CHECK:STDOUT: %.loc15_28.2: %.8 = converted %.loc15_28.1, %struct [template = constants.%struct] +// CHECK:STDOUT: %.loc15_29: i32 = struct_access %.loc15_28.2, element0 [template = constants.%.7] +// CHECK:STDOUT: %.loc15_15: ref = tuple_index %a.ref, [template = ] // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_index_error.carbon b/toolchain/check/testdata/index/fail_tuple_index_error.carbon index 6b624499962c7..5ef3e21700cf2 100644 --- a/toolchain/check/testdata/index/fail_tuple_index_error.carbon +++ b/toolchain/check/testdata/index/fail_tuple_index_error.carbon @@ -9,10 +9,10 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_tuple_index_error.carbon var a: (i32, i32) = (12, 6); -// CHECK:STDERR: fail_tuple_index_error.carbon:[[@LINE+3]]:16: ERROR: Name `oops` not found. -// CHECK:STDERR: var b: i32 = a[oops]; -// CHECK:STDERR: ^~~~ -var b: i32 = a[oops]; +// CHECK:STDERR: fail_tuple_index_error.carbon:[[@LINE+3]]:17: ERROR: Name `oops` not found. +// CHECK:STDERR: var b: i32 = a.(oops); +// CHECK:STDERR: ^~~~ +var b: i32 = a.(oops); // CHECK:STDOUT: --- fail_tuple_index_error.carbon // CHECK:STDOUT: @@ -29,19 +29,26 @@ var b: i32 = a[oops]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) @@ -75,7 +82,7 @@ var b: i32 = a[oops]; // CHECK:STDOUT: assign file.%a.var, %.loc11_28 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %oops.ref: = name_ref oops, [template = ] -// CHECK:STDOUT: %.loc15: ref = tuple_index %a.ref, +// CHECK:STDOUT: %.loc15: ref = tuple_index %a.ref, [template = ] // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_large_index.carbon b/toolchain/check/testdata/index/fail_tuple_large_index.carbon index 5541f996cd7c4..bec42ac1d210a 100644 --- a/toolchain/check/testdata/index/fail_tuple_large_index.carbon +++ b/toolchain/check/testdata/index/fail_tuple_large_index.carbon @@ -11,14 +11,14 @@ var a: (i32,) = (12,); var b: (i32,) = a; // CHECK:STDERR: fail_tuple_large_index.carbon:[[@LINE+4]]:14: ERROR: Tuple element index `1` is past the end of type `(i32,)`. -// CHECK:STDERR: var c: i32 = b[1]; -// CHECK:STDERR: ^~~~ +// CHECK:STDERR: var c: i32 = b.(1); +// CHECK:STDERR: ^~~~~ // CHECK:STDERR: -var c: i32 = b[1]; +var c: i32 = b.(1); // CHECK:STDERR: fail_tuple_large_index.carbon:[[@LINE+3]]:14: ERROR: Tuple element index `2147483647` is past the end of type `(i32,)`. -// CHECK:STDERR: var d: i32 = b[0x7FFF_FFFF]; -// CHECK:STDERR: ^~~~~~~~~~~~~~ -var d: i32 = b[0x7FFF_FFFF]; +// CHECK:STDERR: var d: i32 = b.(0x7FFF_FFFF); +// CHECK:STDERR: ^~~~~~~~~~~~~~~ +var d: i32 = b.(0x7FFF_FFFF); // CHECK:STDOUT: --- fail_tuple_large_index.carbon // CHECK:STDOUT: @@ -35,22 +35,28 @@ var d: i32 = b[0x7FFF_FFFF]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: %.2 = tuple_literal (%int.make_type_32.loc11) // CHECK:STDOUT: %.loc11_13.2: type = value_of_initializer %int.make_type_32.loc11 [template = i32] @@ -93,12 +99,12 @@ var d: i32 = b[0x7FFF_FFFF]; // CHECK:STDOUT: %.loc12_18: init %.3 = converted %a.ref, %.loc12_17.3 // CHECK:STDOUT: assign file.%b.var, %.loc12_18 // CHECK:STDOUT: %b.ref.loc17: ref %.3 = name_ref b, file.%b -// CHECK:STDOUT: %.loc17_16: i32 = int_literal 1 [template = constants.%.5] -// CHECK:STDOUT: %.loc17_17: ref = tuple_index %b.ref.loc17, +// CHECK:STDOUT: %.loc17_17: i32 = int_literal 1 [template = constants.%.5] +// CHECK:STDOUT: %.loc17_15: ref = tuple_index %b.ref.loc17, [template = ] // CHECK:STDOUT: assign file.%c.var, // CHECK:STDOUT: %b.ref.loc21: ref %.3 = name_ref b, file.%b -// CHECK:STDOUT: %.loc21_16: i32 = int_literal 2147483647 [template = constants.%.6] -// CHECK:STDOUT: %.loc21_27: ref = tuple_index %b.ref.loc21, +// CHECK:STDOUT: %.loc21_17: i32 = int_literal 2147483647 [template = constants.%.6] +// CHECK:STDOUT: %.loc21_15: ref = tuple_index %b.ref.loc21, [template = ] // CHECK:STDOUT: assign file.%d.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon index c4f1a715de874..9a0a710b32130 100644 --- a/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon @@ -9,10 +9,10 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon var a: (i32, i32) = (12, 6); -// CHECK:STDERR: fail_tuple_non_int_indexing.carbon:[[@LINE+3]]:16: ERROR: Cannot implicitly convert from `f64` to `i32`. -// CHECK:STDERR: var b: i32 = a[2.6]; -// CHECK:STDERR: ^~~ -var b: i32 = a[2.6]; +// CHECK:STDERR: fail_tuple_non_int_indexing.carbon:[[@LINE+3]]:17: ERROR: Cannot implicitly convert from `f64` to `i32`. +// CHECK:STDERR: var b: i32 = a.(2.6); +// CHECK:STDERR: ^~~ +var b: i32 = a.(2.6); // CHECK:STDOUT: --- fail_tuple_non_int_indexing.carbon // CHECK:STDOUT: @@ -30,19 +30,26 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) @@ -75,8 +82,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc11_28: init %.3 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] // CHECK:STDOUT: assign file.%a.var, %.loc11_28 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a -// CHECK:STDOUT: %.loc15_16: f64 = float_literal 2.6000000000000001 [template = constants.%.7] -// CHECK:STDOUT: %.loc15_19: ref = tuple_index %a.ref, +// CHECK:STDOUT: %.loc15_17: f64 = float_literal 2.6000000000000001 [template = constants.%.7] +// CHECK:STDOUT: %.loc15_15: ref = tuple_index %a.ref, [template = ] // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon index d0416affb0ebd..562f926793cf2 100644 --- a/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon @@ -10,9 +10,9 @@ var a: (i32, i32) = (12, 6); // CHECK:STDERR: fail_tuple_out_of_bound_access.carbon:[[@LINE+3]]:14: ERROR: Tuple element index `2` is past the end of type `(i32, i32)`. -// CHECK:STDERR: var b: i32 = a[2]; -// CHECK:STDERR: ^~~~ -var b: i32 = a[2]; +// CHECK:STDERR: var b: i32 = a.2; +// CHECK:STDERR: ^~~ +var b: i32 = a.2; // CHECK:STDOUT: --- fail_tuple_out_of_bound_access.carbon // CHECK:STDOUT: @@ -30,19 +30,26 @@ var b: i32 = a[2]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) @@ -76,7 +83,7 @@ var b: i32 = a[2]; // CHECK:STDOUT: assign file.%a.var, %.loc11_28 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a // CHECK:STDOUT: %.loc15_16: i32 = int_literal 2 [template = constants.%.7] -// CHECK:STDOUT: %.loc15_17: ref = tuple_index %a.ref, +// CHECK:STDOUT: %.loc15_15: ref = tuple_index %a.ref, [template = ] // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/index_not_literal.carbon b/toolchain/check/testdata/index/index_not_literal.carbon index b22b01fe12808..2adc4a81e5cdb 100644 --- a/toolchain/check/testdata/index/index_not_literal.carbon +++ b/toolchain/check/testdata/index/index_not_literal.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/index_not_literal.carbon var a: (i32, i32) = (12, 34); -var b: i32 = a[{.index = 1}.index]; +var b: i32 = a.({.index = 1}.index); // CHECK:STDOUT: --- index_not_literal.carbon // CHECK:STDOUT: @@ -29,19 +29,26 @@ var b: i32 = a[{.index = 1}.index]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) @@ -74,14 +81,14 @@ var b: i32 = a[{.index = 1}.index]; // CHECK:STDOUT: %.loc11_29: init %.3 = converted %.loc11_28.1, %.loc11_28.6 [template = constants.%tuple] // CHECK:STDOUT: assign file.%a.var, %.loc11_29 // CHECK:STDOUT: %a.ref: ref %.3 = name_ref a, file.%a -// CHECK:STDOUT: %.loc12_26: i32 = int_literal 1 [template = constants.%.7] -// CHECK:STDOUT: %.loc12_27.1: %.8 = struct_literal (%.loc12_26) -// CHECK:STDOUT: %struct: %.8 = struct_value (%.loc12_26) [template = constants.%struct] -// CHECK:STDOUT: %.loc12_27.2: %.8 = converted %.loc12_27.1, %struct [template = constants.%struct] -// CHECK:STDOUT: %.loc12_28: i32 = struct_access %.loc12_27.2, element0 [template = constants.%.7] -// CHECK:STDOUT: %.loc12_34.1: ref i32 = tuple_index %a.ref, %.loc12_28 -// CHECK:STDOUT: %.loc12_34.2: i32 = bind_value %.loc12_34.1 -// CHECK:STDOUT: assign file.%b.var, %.loc12_34.2 +// CHECK:STDOUT: %.loc12_27: i32 = int_literal 1 [template = constants.%.7] +// CHECK:STDOUT: %.loc12_28.1: %.8 = struct_literal (%.loc12_27) +// CHECK:STDOUT: %struct: %.8 = struct_value (%.loc12_27) [template = constants.%struct] +// CHECK:STDOUT: %.loc12_28.2: %.8 = converted %.loc12_28.1, %struct [template = constants.%struct] +// CHECK:STDOUT: %.loc12_29: i32 = struct_access %.loc12_28.2, element0 [template = constants.%.7] +// CHECK:STDOUT: %.loc12_15.1: ref i32 = tuple_index %a.ref, %.loc12_29 +// CHECK:STDOUT: %.loc12_15.2: i32 = bind_value %.loc12_15.1 +// CHECK:STDOUT: assign file.%b.var, %.loc12_15.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/tuple_element_access.carbon b/toolchain/check/testdata/index/tuple_element_access.carbon index 9da4ce3d7bbed..3183c82440c74 100644 --- a/toolchain/check/testdata/index/tuple_element_access.carbon +++ b/toolchain/check/testdata/index/tuple_element_access.carbon @@ -10,7 +10,7 @@ var a: (i32,) = (12,); var b: (i32,) = a; -var c: i32 = b[0]; +var c: i32 = b.0; // CHECK:STDOUT: --- tuple_element_access.carbon // CHECK:STDOUT: @@ -26,20 +26,27 @@ var c: i32 = b[0]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: %.2 = tuple_literal (%int.make_type_32.loc11) // CHECK:STDOUT: %.loc11_13.2: type = value_of_initializer %int.make_type_32.loc11 [template = i32] @@ -78,9 +85,9 @@ var c: i32 = b[0]; // CHECK:STDOUT: assign file.%b.var, %.loc12_18 // CHECK:STDOUT: %b.ref: ref %.3 = name_ref b, file.%b // CHECK:STDOUT: %.loc13_16: i32 = int_literal 0 [template = constants.%.5] -// CHECK:STDOUT: %.loc13_17.1: ref i32 = tuple_index %b.ref, %.loc13_16 -// CHECK:STDOUT: %.loc13_17.2: i32 = bind_value %.loc13_17.1 -// CHECK:STDOUT: assign file.%c.var, %.loc13_17.2 +// CHECK:STDOUT: %.loc13_15.1: ref i32 = tuple_index %b.ref, %.loc13_16 +// CHECK:STDOUT: %.loc13_15.2: i32 = bind_value %.loc13_15.1 +// CHECK:STDOUT: assign file.%c.var, %.loc13_15.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/tuple_return_value_access.carbon b/toolchain/check/testdata/index/tuple_return_value_access.carbon index 42be5bdc1c87d..84266ffa10815 100644 --- a/toolchain/check/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/check/testdata/index/tuple_return_value_access.carbon @@ -11,7 +11,7 @@ fn F() -> (i32,) { return (0,); } fn Run() -> i32 { - return F()[0]; + return F().0; } // CHECK:STDOUT: --- tuple_return_value_access.carbon @@ -31,18 +31,26 @@ fn Run() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_16.1: %.2 = tuple_literal (%int.make_type_32.loc11) @@ -77,8 +85,8 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc14_14: i32 = int_literal 0 [template = constants.%.4] // CHECK:STDOUT: %.loc14_11.1: ref %.3 = temporary_storage // CHECK:STDOUT: %.loc14_11.2: ref %.3 = temporary %.loc14_11.1, %F.call -// CHECK:STDOUT: %.loc14_15.1: ref i32 = tuple_index %.loc14_11.2, %.loc14_14 -// CHECK:STDOUT: %.loc14_15.2: i32 = bind_value %.loc14_15.1 -// CHECK:STDOUT: return %.loc14_15.2 +// CHECK:STDOUT: %.loc14_13.1: ref i32 = tuple_index %.loc14_11.2, %.loc14_14 +// CHECK:STDOUT: %.loc14_13.2: i32 = bind_value %.loc14_13.1 +// CHECK:STDOUT: return %.loc14_13.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/assoc_const.carbon b/toolchain/check/testdata/interface/assoc_const.carbon index 1f45882b1e5a4..0e010f9e69222 100644 --- a/toolchain/check/testdata/interface/assoc_const.carbon +++ b/toolchain/check/testdata/interface/assoc_const.carbon @@ -28,16 +28,25 @@ interface I { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon b/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon index 9e8b28980b0fc..a1e6c6708a199 100644 --- a/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon +++ b/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon @@ -25,13 +25,24 @@ interface I { // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%T [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon b/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon index c22a31d1ae02b..c79ef3cda91ef 100644 --- a/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon +++ b/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon @@ -38,18 +38,25 @@ interface I { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_todo_define_default_fn_inline.carbon b/toolchain/check/testdata/interface/fail_todo_define_default_fn_inline.carbon index a8880bf523d7a..f146b42693cd6 100644 --- a/toolchain/check/testdata/interface/fail_todo_define_default_fn_inline.carbon +++ b/toolchain/check/testdata/interface/fail_todo_define_default_fn_inline.carbon @@ -40,18 +40,25 @@ interface Interface { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Interface = %Interface.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -84,14 +91,23 @@ interface Interface { // CHECK:STDOUT: witness = (%F.decl, %G.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [@Interface.%Self: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F(@Interface.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(@Interface.%a.loc21_16.2: i32, @Interface.%b.loc21_24.2: i32) -> i32 = "int.sadd" -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: generic fn @G(@Interface.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@Interface.%a.loc21_16.2: i32, @Interface.%b.loc21_24.2: i32) -> i32 = "int.sadd"; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%Self) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_todo_define_default_fn_out_of_line.carbon b/toolchain/check/testdata/interface/fail_todo_define_default_fn_out_of_line.carbon index 03d44dd4915f8..45fa1976a8d64 100644 --- a/toolchain/check/testdata/interface/fail_todo_define_default_fn_out_of_line.carbon +++ b/toolchain/check/testdata/interface/fail_todo_define_default_fn_out_of_line.carbon @@ -8,6 +8,8 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_todo_define_default_fn_out_of_line.carbon +// --- fail_todo_define_default_fn_out_of_line.carbon + interface Interface { // CHECK:STDERR: fail_todo_define_default_fn_out_of_line.carbon:[[@LINE+4]]:3: ERROR: Semantics TODO: `interface modifier`. // CHECK:STDERR: default fn F(); @@ -39,6 +41,28 @@ fn Interface.F() {} // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fn Interface.G(a: i32, b: i32) -> i32 = "int.sadd"; +// --- dependent_return_type.carbon + +library "dependent_return_type.carbon"; + +// Ensure that a dependent return type matches between an interface definition +// and an out-of-line member. This requires `Self` to be properly reintroduced +// into the list of generic parameters. + +interface Interface { + // TODO: This should be + // default fn F[self: Self](U:! type, u: U) -> U; + // rather than a class member, but we don't currently accept that due to the + // TODOs above. + class C { + fn F[self: Self](U:! type, u: U) -> U; + } +} + +// TODO: This should be +// fn Interface.F[self: Self](U:! type, u: U) -> U { return u; } +fn Interface.C.F[self: Self](U:! type, u: U) -> U { return u; } + // CHECK:STDOUT: --- fail_todo_define_default_fn_out_of_line.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -62,37 +86,41 @@ fn Interface.G(a: i32, b: i32) -> i32 = "int.sadd"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Interface = %Interface.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} -// CHECK:STDOUT: %.decl.loc32: %.type.1 = fn_decl @.1 [template = constants.%.7] {} -// CHECK:STDOUT: %.decl.loc40: %.type.2 = fn_decl @.2 [template = constants.%.8] { -// CHECK:STDOUT: %int.make_type_32.loc40_19: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc40_19.1: type = value_of_initializer %int.make_type_32.loc40_19 [template = i32] -// CHECK:STDOUT: %.loc40_19.2: type = converted %int.make_type_32.loc40_19, %.loc40_19.1 [template = i32] -// CHECK:STDOUT: %a.loc40_16.1: i32 = param a -// CHECK:STDOUT: @.2.%a: i32 = bind_name a, %a.loc40_16.1 -// CHECK:STDOUT: %int.make_type_32.loc40_27: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc40_27.1: type = value_of_initializer %int.make_type_32.loc40_27 [template = i32] -// CHECK:STDOUT: %.loc40_27.2: type = converted %int.make_type_32.loc40_27, %.loc40_27.1 [template = i32] -// CHECK:STDOUT: %b.loc40_24.1: i32 = param b -// CHECK:STDOUT: @.2.%b: i32 = bind_name b, %b.loc40_24.1 -// CHECK:STDOUT: %int.make_type_32.loc40_35: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc40_35.1: type = value_of_initializer %int.make_type_32.loc40_35 [template = i32] -// CHECK:STDOUT: %.loc40_35.2: type = converted %int.make_type_32.loc40_35, %.loc40_35.1 [template = i32] +// CHECK:STDOUT: %.decl.loc23: %.type.1 = fn_decl @.1 [template = constants.%.7] {} +// CHECK:STDOUT: %.decl.loc31: %.type.2 = fn_decl @.2 [template = constants.%.8] { +// CHECK:STDOUT: %int.make_type_32.loc31_19: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc31_19.1: type = value_of_initializer %int.make_type_32.loc31_19 [template = i32] +// CHECK:STDOUT: %.loc31_19.2: type = converted %int.make_type_32.loc31_19, %.loc31_19.1 [template = i32] +// CHECK:STDOUT: %a.loc31_16.1: i32 = param a +// CHECK:STDOUT: @.2.%a: i32 = bind_name a, %a.loc31_16.1 +// CHECK:STDOUT: %int.make_type_32.loc31_27: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc31_27.1: type = value_of_initializer %int.make_type_32.loc31_27 [template = i32] +// CHECK:STDOUT: %.loc31_27.2: type = converted %int.make_type_32.loc31_27, %.loc31_27.1 [template = i32] +// CHECK:STDOUT: %b.loc31_24.1: i32 = param b +// CHECK:STDOUT: @.2.%b: i32 = bind_name b, %b.loc31_24.1 +// CHECK:STDOUT: %int.make_type_32.loc31_35: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc31_35.1: type = value_of_initializer %int.make_type_32.loc31_35 [template = i32] +// CHECK:STDOUT: %.loc31_35.2: type = converted %int.make_type_32.loc31_35, %.loc31_35.1 [template = i32] // CHECK:STDOUT: @.2.%return: ref i32 = var // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -100,44 +128,172 @@ fn Interface.G(a: i32, b: i32) -> i32 = "int.sadd"; // CHECK:STDOUT: interface @Interface { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} -// CHECK:STDOUT: %.loc16: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] +// CHECK:STDOUT: %.loc7: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { -// CHECK:STDOUT: %int.make_type_32.loc22_19: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc22_19.1: type = value_of_initializer %int.make_type_32.loc22_19 [template = i32] -// CHECK:STDOUT: %.loc22_19.2: type = converted %int.make_type_32.loc22_19, %.loc22_19.1 [template = i32] -// CHECK:STDOUT: %a.loc22_16.1: i32 = param a -// CHECK:STDOUT: %a.loc22_16.2: i32 = bind_name a, %a.loc22_16.1 -// CHECK:STDOUT: %int.make_type_32.loc22_27: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc22_27.1: type = value_of_initializer %int.make_type_32.loc22_27 [template = i32] -// CHECK:STDOUT: %.loc22_27.2: type = converted %int.make_type_32.loc22_27, %.loc22_27.1 [template = i32] -// CHECK:STDOUT: %b.loc22_24.1: i32 = param b -// CHECK:STDOUT: %b.loc22_24.2: i32 = bind_name b, %b.loc22_24.1 -// CHECK:STDOUT: %int.make_type_32.loc22_35: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc22_35.1: type = value_of_initializer %int.make_type_32.loc22_35 [template = i32] -// CHECK:STDOUT: %.loc22_35.2: type = converted %int.make_type_32.loc22_35, %.loc22_35.1 [template = i32] +// CHECK:STDOUT: %int.make_type_32.loc13_19: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc13_19.1: type = value_of_initializer %int.make_type_32.loc13_19 [template = i32] +// CHECK:STDOUT: %.loc13_19.2: type = converted %int.make_type_32.loc13_19, %.loc13_19.1 [template = i32] +// CHECK:STDOUT: %a.loc13_16.1: i32 = param a +// CHECK:STDOUT: %a.loc13_16.2: i32 = bind_name a, %a.loc13_16.1 +// CHECK:STDOUT: %int.make_type_32.loc13_27: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc13_27.1: type = value_of_initializer %int.make_type_32.loc13_27 [template = i32] +// CHECK:STDOUT: %.loc13_27.2: type = converted %int.make_type_32.loc13_27, %.loc13_27.1 [template = i32] +// CHECK:STDOUT: %b.loc13_24.1: i32 = param b +// CHECK:STDOUT: %b.loc13_24.2: i32 = bind_name b, %b.loc13_24.1 +// CHECK:STDOUT: %int.make_type_32.loc13_35: init type = call constants.%Int32() [template = i32] +// CHECK:STDOUT: %.loc13_35.1: type = value_of_initializer %int.make_type_32.loc13_35 [template = i32] +// CHECK:STDOUT: %.loc13_35.2: type = converted %int.make_type_32.loc13_35, %.loc13_35.1 [template = i32] // CHECK:STDOUT: %return.var: ref i32 = var // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc22_38: %.5 = assoc_entity element1, %G.decl [template = constants.%.6] +// CHECK:STDOUT: %.loc13_38: %.5 = assoc_entity element1, %G.decl [template = constants.%.6] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc16 -// CHECK:STDOUT: .G = %.loc22_38 +// CHECK:STDOUT: .F = %.loc7 +// CHECK:STDOUT: .G = %.loc13_38 // CHECK:STDOUT: witness = (%F.decl, %G.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: generic fn @F(@Interface.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(@Interface.%a.loc22_16.2: i32, @Interface.%b.loc22_24.2: i32) -> i32 -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: generic fn @G(@Interface.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@Interface.%a.loc13_16.2: i32, @Interface.%b.loc13_24.2: i32) -> i32; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(@Interface.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.2(@Interface.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%a: i32, %b: i32) -> i32 = "int.sadd"; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.2(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- dependent_return_type.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = interface_type @Interface [template] +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F, @C(%Self) [symbolic] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = struct_type {} [template] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %.4: type = ptr_type %.3 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Interface = %Interface.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [symbolic = constants.%F.1] { +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C] +// CHECK:STDOUT: %self.loc20_18.1: %C = param self +// CHECK:STDOUT: @F.%self: %C = bind_name self, %self.loc20_18.1 +// CHECK:STDOUT: %U.loc20_30.1: type = param U +// CHECK:STDOUT: @F.%U.loc20: type = bind_symbolic_name U 1, %U.loc20_30.1 [symbolic = constants.%U] +// CHECK:STDOUT: %U.ref.loc20_43: type = name_ref U, @F.%U.loc20 [symbolic = constants.%U] +// CHECK:STDOUT: %u.loc20_40.1: %U = param u +// CHECK:STDOUT: @F.%u: %U = bind_name u, %u.loc20_40.1 +// CHECK:STDOUT: %U.ref.loc20_49: type = name_ref U, @F.%U.loc20 [symbolic = constants.%U] +// CHECK:STDOUT: @F.%return: ref %U = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Interface { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(@Interface.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @C(%Self) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @C.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %F.decl: @C.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C] +// CHECK:STDOUT: %self.loc14_10.1: %C = param self +// CHECK:STDOUT: %self.loc14_10.2: %C = bind_name self, %self.loc14_10.1 +// CHECK:STDOUT: %U.loc14_22.1: type = param U +// CHECK:STDOUT: %U.loc14_22.2: type = bind_symbolic_name U 1, %U.loc14_22.1 [symbolic = @F.%U.1 (constants.%U)] +// CHECK:STDOUT: %U.ref.loc14_35: type = name_ref U, %U.loc14_22.2 [symbolic = @F.%U.1 (constants.%U)] +// CHECK:STDOUT: %u.loc14_32.1: @F.%U.1 (%U) = param u +// CHECK:STDOUT: %u.loc14_32.2: @F.%U.1 (%U) = bind_name u, %u.loc14_32.1 +// CHECK:STDOUT: %U.ref.loc14_41: type = name_ref U, %U.loc14_22.2 [symbolic = @F.%U.1 (constants.%U)] +// CHECK:STDOUT: %return.var: ref @F.%U.1 (%U) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(@Interface.%Self: %.1, @C.%U.loc14_22.2: type) { +// CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %C](%U.loc20: type, %u: %U) -> %U { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %u.ref: @F.%U.1 (%U) = name_ref u, %u +// CHECK:STDOUT: return %u.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%Self) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: specific @F(constants.%Self, constants.%U) { +// CHECK:STDOUT: %U.1 => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.2(%a: i32, %b: i32) -> i32 = "int.sadd"; +// CHECK:STDOUT: specific @C(@C.%Self) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon index 56a74642efdbd..412a346df82fa 100644 --- a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon @@ -34,7 +34,7 @@ fn F(T:! Empty) { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, %Empty.decl [template = constants.%.1] // CHECK:STDOUT: %T.loc13_6.1: %.1 = param T -// CHECK:STDOUT: @F.%T: %.1 = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: @F.%T.loc13: %.1 = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = @F.%T.1 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -46,14 +46,23 @@ fn F(T:! Empty) { // CHECK:STDOUT: witness = () // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: %.1) -// CHECK:STDOUT: generic [%T: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc14_10.1: type = facet_type_access %T.ref [symbolic = constants.%T] -// CHECK:STDOUT: %.loc14_10.2: type = converted %T.ref, %.loc14_10.1 [symbolic = constants.%T] -// CHECK:STDOUT: %x.var: ref %T = var x -// CHECK:STDOUT: %x: ref %T = bind_name x, %x.var -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F(%T.loc13: %.1) { +// CHECK:STDOUT: %T.1: %.1 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc13: %.1) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T.loc13 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc14_10.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %.loc14_10.2: type = converted %T.ref, %.loc14_10.1 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %x.var: ref @F.%T.1 (%T) = var x +// CHECK:STDOUT: %x: ref @F.%T.1 (%T) = bind_name x, %x.var +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/basic.carbon b/toolchain/check/testdata/interface/no_prelude/basic.carbon index 43a1a6d443f6e..3563bc296170f 100644 --- a/toolchain/check/testdata/interface/no_prelude/basic.carbon +++ b/toolchain/check/testdata/interface/no_prelude/basic.carbon @@ -60,6 +60,10 @@ interface ForwardDeclared { // CHECK:STDOUT: witness = (%F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [@ForwardDeclared.%Self: %.2]; +// CHECK:STDOUT: generic fn @F(@ForwardDeclared.%Self: %.2) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self.2) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/default_fn.carbon b/toolchain/check/testdata/interface/no_prelude/default_fn.carbon index 379b338fdb1f9..9f5f7b578967b 100644 --- a/toolchain/check/testdata/interface/no_prelude/default_fn.carbon +++ b/toolchain/check/testdata/interface/no_prelude/default_fn.carbon @@ -81,22 +81,25 @@ class C { // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@I.%Self: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] -// CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var -// CHECK:STDOUT: %.loc16_19.1: %.6 = struct_literal () -// CHECK:STDOUT: %.loc16_19.2: init %C = class_init (), %c.var [template = constants.%struct] -// CHECK:STDOUT: %.loc16_20: init %C = converted %.loc16_19.1, %.loc16_19.2 [template = constants.%struct] -// CHECK:STDOUT: assign %c.var, %.loc16_20 -// CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c -// CHECK:STDOUT: %I.ref: type = name_ref I, @C.%I.decl [template = constants.%.1] -// CHECK:STDOUT: %F.ref: %.3 = name_ref F, @I.%.loc14 [template = constants.%.4] -// CHECK:STDOUT: %.1: %F.type.1 = interface_witness_access @impl.%.1, element0 [template = constants.%F.2] -// CHECK:STDOUT: %F.call: init %.2 = call %.1() -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F.1(@I.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: %.loc16_19.1: %.6 = struct_literal () +// CHECK:STDOUT: %.loc16_19.2: init %C = class_init (), %c.var [template = constants.%struct] +// CHECK:STDOUT: %.loc16_20: init %C = converted %.loc16_19.1, %.loc16_19.2 [template = constants.%struct] +// CHECK:STDOUT: assign %c.var, %.loc16_20 +// CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c +// CHECK:STDOUT: %I.ref: type = name_ref I, @C.%I.decl [template = constants.%.1] +// CHECK:STDOUT: %F.ref: %.3 = name_ref F, @I.%.loc14 [template = constants.%.4] +// CHECK:STDOUT: %.1: %F.type.1 = interface_witness_access @impl.%.1, element0 [template = constants.%F.2] +// CHECK:STDOUT: %F.call: init %.2 = call %.1() +// CHECK:STDOUT: return +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { @@ -104,3 +107,5 @@ class C { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/export_name.carbon b/toolchain/check/testdata/interface/no_prelude/export_name.carbon index 85785004f62f1..f887b2e6ed944 100644 --- a/toolchain/check/testdata/interface/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/interface/no_prelude/export_name.carbon @@ -68,8 +68,8 @@ fn UseEmpty(i: I) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%.1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%.1] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -97,8 +97,8 @@ fn UseEmpty(i: I) {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+7, loaded [template = constants.%.1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+6, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+7, loaded [template = constants.%.1] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export, inst+6, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon b/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon index 45b6df4987498..e88b08f031737 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon @@ -43,10 +43,11 @@ interface Outer { // CHECK:STDOUT: %Self.2: %.3 = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: %.4: type = interface_type @Inner [template] // CHECK:STDOUT: %Self.3: %.4 = bind_symbolic_name Self 1 [symbolic] -// CHECK:STDOUT: %.type: type = fn_type @.1 [template] -// CHECK:STDOUT: %.5: %.type = struct_value () [template] -// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] -// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %.type: type = fn_type @.1, @Inner(%Self.2) [symbolic] +// CHECK:STDOUT: %.5: %.type = struct_value () [symbolic] +// CHECK:STDOUT: %.6: %.type = struct_value () [symbolic] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.2, @Inner(%Self.2) [symbolic] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -71,7 +72,7 @@ interface Outer { // CHECK:STDOUT: interface @Outer { // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2] // CHECK:STDOUT: %Inner.decl: type = interface_decl @Inner [template = constants.%.4] {} -// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} +// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [symbolic = constants.%F.2] {} // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self @@ -79,25 +80,56 @@ interface Outer { // CHECK:STDOUT: witness = () // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @Inner -// CHECK:STDOUT: generic [@Outer.%Self: %.3] { -// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.5] {} +// CHECK:STDOUT: generic interface @Inner(@Outer.%Self: %.3) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.3)] +// CHECK:STDOUT: %Self.3: %.3 = bind_symbolic_name Self 0 [symbolic = %Self.3 (constants.%Self.2)] +// CHECK:STDOUT: %.type: type = fn_type @.1, @Inner(%Self.3) [symbolic = %.type (constants.%.type)] +// CHECK:STDOUT: %.1: @Inner.%.type (%.type) = struct_value () [symbolic = %.1 (constants.%.5)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = @Outer.%F.decl -// CHECK:STDOUT: witness = () +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: %.4 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.3)] +// CHECK:STDOUT: %.decl: @Inner.%.type (%.type) = fn_decl @.1 [symbolic = %.1 (constants.%.5)] {} +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .F = @Outer.%F.decl +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F.1(@Interface.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() -// CHECK:STDOUT: generic [@Outer.%Self: %.3, @Inner.%Self: %.4]; +// CHECK:STDOUT: generic fn @.1(@Outer.%Self: %.3, @Inner.%Self.1: %.4) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.2(@Outer.%Self: %.3, @Inner.%Self.1: %.4) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(constants.%Self.2) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %Self.2 => constants.%Self.3 +// CHECK:STDOUT: %Self.3 => constants.%Self.2 +// CHECK:STDOUT: %.type => constants.%.type +// CHECK:STDOUT: %.1 => constants.%.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%Self.2, constants.%Self.3) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Inner(@Inner.%Self.3) {} // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2() -// CHECK:STDOUT: generic [@Outer.%Self: %.3]; +// CHECK:STDOUT: specific @F.2(constants.%Self.2, constants.%Self.3) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon index 7da0a1ced2557..386e094720c7b 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon @@ -28,7 +28,7 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = +// CHECK:STDOUT: .Self = .inst+3 // CHECK:STDOUT: witness = invalid // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon index 6168a278b042a..497f29f65d535 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon @@ -26,7 +26,7 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = +// CHECK:STDOUT: .Self = .inst+3 // CHECK:STDOUT: witness = invalid // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_definition_imported.carbon b/toolchain/check/testdata/interface/no_prelude/fail_definition_imported.carbon new file mode 100644 index 0000000000000..9d12af0de493a --- /dev/null +++ b/toolchain/check/testdata/interface/no_prelude/fail_definition_imported.carbon @@ -0,0 +1,77 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/fail_definition_imported.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_definition_imported.carbon + +// --- a.carbon + +library "a"; + +interface I; + +// --- fail_b.carbon + +library "b"; +import library "a"; + +// CHECK:STDERR: fail_b.carbon:[[@LINE+9]]:1: ERROR: Duplicate name being declared in the same scope. +// CHECK:STDERR: interface I {} +// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: fail_b.carbon:[[@LINE-5]]:1: In import. +// CHECK:STDERR: import library "a"; +// CHECK:STDERR: ^~~~~~ +// CHECK:STDERR: a.carbon:4:1: Name is previously declared here. +// CHECK:STDERR: interface I; +// CHECK:STDERR: ^~~~~~~~~~~~ +interface I {} + +// CHECK:STDOUT: --- a.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = interface_type @I [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I; +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_b.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = interface_type @I [template] +// CHECK:STDOUT: %.2: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref: type = import_ref Main//a, inst+1, loaded [template = constants.%.1] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = imports.%import_ref +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: %.decl: type = interface_decl @.1 [template = constants.%.2] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon b/toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon index 0e002468e4565..355d6fc31ae58 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_duplicate.carbon @@ -76,7 +76,7 @@ interface Class { } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = +// CHECK:STDOUT: .Self = .inst+3 // CHECK:STDOUT: .F = // CHECK:STDOUT: witness = () // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon b/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon index ce50b4cbaef14..999fa270858fb 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon @@ -45,7 +45,7 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: %.type.1: type = generic_interface_type @.1 [template] // CHECK:STDOUT: %.2: type = tuple_type () [template] // CHECK:STDOUT: %.3: %.type.1 = struct_value () [template] -// CHECK:STDOUT: %.4: type = interface_type @.1, (%T.1) [symbolic] +// CHECK:STDOUT: %.4: type = interface_type @.1, @.1(%T.1) [symbolic] // CHECK:STDOUT: %Self.1: %.4 = bind_symbolic_name Self 1 [symbolic] // CHECK:STDOUT: %Generic.type: type = generic_interface_type @Generic [template] // CHECK:STDOUT: %Generic: %Generic.type = struct_value () [template] @@ -56,7 +56,7 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: %T.2: %.2 = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %.type.2: type = generic_interface_type @.3 [template] // CHECK:STDOUT: %.6: %.type.2 = struct_value () [template] -// CHECK:STDOUT: %.7: type = interface_type @.3, (%T.2) [symbolic] +// CHECK:STDOUT: %.7: type = interface_type @.3, @.3(%T.2) [symbolic] // CHECK:STDOUT: %Self.3: %.7 = bind_symbolic_name Self 1 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -69,38 +69,48 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: %NotGeneric.decl: type = interface_decl @NotGeneric [template = constants.%.1] {} // CHECK:STDOUT: %.decl.loc19: %.type.1 = interface_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %T.loc19_22.1: type = param T -// CHECK:STDOUT: %T.loc19_22.2: type = bind_symbolic_name T 0, %T.loc19_22.1 [symbolic = %T.loc19_22.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc19_22.2: type = bind_symbolic_name T 0, %T.loc19_22.1 [symbolic = @.1.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %Generic.decl: %Generic.type = interface_decl @Generic [template = constants.%Generic] { // CHECK:STDOUT: %T.loc21_19.1: type = param T -// CHECK:STDOUT: %T.loc21_19.2: type = bind_symbolic_name T 0, %T.loc21_19.1 [symbolic = %T.loc21_19.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc21_19.2: type = bind_symbolic_name T 0, %T.loc21_19.1 [symbolic = @Generic.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl.loc29: type = interface_decl @.2 [template = constants.%.5] {} // CHECK:STDOUT: %DifferentParams.decl: %DifferentParams.type = interface_decl @DifferentParams [template = constants.%DifferentParams] { // CHECK:STDOUT: %T.loc31_27.1: type = param T -// CHECK:STDOUT: %T.loc31_27.2: type = bind_symbolic_name T 0, %T.loc31_27.1 [symbolic = %T.loc31_27.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc31_27.2: type = bind_symbolic_name T 0, %T.loc31_27.1 [symbolic = @DifferentParams.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl.loc38: %.type.2 = interface_decl @.3 [template = constants.%.6] { // CHECK:STDOUT: %.loc38_32.1: %.2 = tuple_literal () // CHECK:STDOUT: %.loc38_32.2: type = converted %.loc38_32.1, constants.%.2 [template = constants.%.2] // CHECK:STDOUT: %T.loc38_27.1: %.2 = param T -// CHECK:STDOUT: %T.loc38_27.2: %.2 = bind_symbolic_name T 0, %T.loc38_27.1 [symbolic = %T.loc38_27.2 (constants.%T.2)] +// CHECK:STDOUT: %T.loc38_27.2: %.2 = bind_symbolic_name T 0, %T.loc38_27.1 [symbolic = @.3.%T (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @NotGeneric; // CHECK:STDOUT: -// CHECK:STDOUT: interface @.1 -// CHECK:STDOUT: generic [file.%T.loc19_22.2: type] { -// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = constants.%Self.1] +// CHECK:STDOUT: generic interface @.1(file.%T.loc19_22.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: witness = () +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @.1, @.1(%T) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @.1.%.1 (%.4) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @Generic -// CHECK:STDOUT: generic [file.%T.loc21_19.2: type]; +// CHECK:STDOUT: generic interface @Generic(file.%T.loc21_19.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @.2 { // CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2] @@ -110,15 +120,49 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: witness = () // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @DifferentParams -// CHECK:STDOUT: generic [file.%T.loc31_27.2: type]; +// CHECK:STDOUT: generic interface @DifferentParams(file.%T.loc31_27.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] // CHECK:STDOUT: -// CHECK:STDOUT: interface @.3 -// CHECK:STDOUT: generic [file.%T.loc38_27.2: %.2] { -// CHECK:STDOUT: %Self: %.7 = bind_symbolic_name Self 1 [symbolic = constants.%Self.3] +// CHECK:STDOUT: interface; +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: witness = () +// CHECK:STDOUT: generic interface @.3(file.%T.loc38_27.2: %.2) { +// CHECK:STDOUT: %T: %.2 = bind_symbolic_name T 0 [symbolic = %T (constants.%T.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @.3, @.3(%T) [symbolic = %.1 (constants.%.7)] +// CHECK:STDOUT: %Self.2: %.7 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @.3.%.1 (%.7) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(@.1.%T) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @DifferentParams(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.3(constants.%T.2) { +// CHECK:STDOUT: %T => constants.%T.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.3(@.3.%T) { +// CHECK:STDOUT: %T => constants.%T.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon b/toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon index 861dab742c617..d057858dd8cea 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon @@ -107,9 +107,17 @@ interface BeingDefined { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @H() -> -// CHECK:STDOUT: generic [@BeingDefined.%Self: %.4]; +// CHECK:STDOUT: generic fn @H(@BeingDefined.%Self: %.4) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @.2() -// CHECK:STDOUT: generic [@BeingDefined.%Self: %.4]; +// CHECK:STDOUT: fn() -> ; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.2(@BeingDefined.%Self: %.4) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @H(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.2(constants.%Self) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon index 20a7b938e731c..38b3648b78198 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon @@ -66,8 +66,10 @@ fn F() { // CHECK:STDOUT: witness = (%F.decl, %T) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: generic fn @F.1(@Interface.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: @@ -80,3 +82,5 @@ fn F() { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon b/toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon index 9030b048b359f..7810ec5d41ab7 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_redeclare_member.carbon @@ -52,9 +52,17 @@ interface Interface { // CHECK:STDOUT: witness = (%F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: generic fn @F(@Interface.%Self: %.1) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(@Interface.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%Self) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon index 8aff5758f3379..03ca2526d3b5a 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon @@ -52,17 +52,17 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: %CallStatic.decl: %CallStatic.type = fn_decl @CallStatic [template = constants.%CallStatic] { // CHECK:STDOUT: %Interface.ref.loc13: type = name_ref Interface, %Interface.decl [template = constants.%.1] // CHECK:STDOUT: %T.loc13_15.1: %.1 = param T -// CHECK:STDOUT: @CallStatic.%T: %.1 = bind_symbolic_name T 0, %T.loc13_15.1 [symbolic = @CallStatic.%T (constants.%T)] +// CHECK:STDOUT: @CallStatic.%T.loc13: %.1 = bind_symbolic_name T 0, %T.loc13_15.1 [symbolic = @CallStatic.%T.1 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %CallFacet.decl: %CallFacet.type = fn_decl @CallFacet [template = constants.%CallFacet] { // CHECK:STDOUT: %Interface.ref.loc21: type = name_ref Interface, %Interface.decl [template = constants.%.1] // CHECK:STDOUT: %T.loc21_14.1: %.1 = param T -// CHECK:STDOUT: @CallFacet.%T: %.1 = bind_symbolic_name T 0, %T.loc21_14.1 [symbolic = @CallFacet.%T (constants.%T)] -// CHECK:STDOUT: %T.ref: %.1 = name_ref T, @CallFacet.%T [symbolic = @CallFacet.%T (constants.%T)] -// CHECK:STDOUT: %.loc21_32.1: type = facet_type_access %T.ref [symbolic = @CallFacet.%T (constants.%T)] -// CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = @CallFacet.%T (constants.%T)] -// CHECK:STDOUT: %x.loc21_29.1: @CallFacet.%T (%T) = param x -// CHECK:STDOUT: @CallFacet.%x: @CallFacet.%T (%T) = bind_name x, %x.loc21_29.1 +// CHECK:STDOUT: @CallFacet.%T.loc21: %.1 = bind_symbolic_name T 0, %T.loc21_14.1 [symbolic = @CallFacet.%T.1 (constants.%T)] +// CHECK:STDOUT: %T.ref: %.1 = name_ref T, @CallFacet.%T.loc21 [symbolic = @CallFacet.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc21_32.1: type = facet_type_access %T.ref [symbolic = @CallFacet.%T.1 (constants.%T)] +// CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = @CallFacet.%T.1 (constants.%T)] +// CHECK:STDOUT: %x.loc21_29.1: @CallFacet.%T.1 (%T) = param x +// CHECK:STDOUT: @CallFacet.%x: @CallFacet.%T.1 (%T) = bind_name x, %x.loc21_29.1 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -77,21 +77,43 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: witness = (%F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [@Interface.%Self: %.1]; +// CHECK:STDOUT: generic fn @F(@Interface.%Self: %.1) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @CallStatic(%T: %.1) -// CHECK:STDOUT: generic [%T: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %F.ref: %.3 = name_ref F, @Interface.%.loc11 [template = constants.%.4] -// CHECK:STDOUT: return +// CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @CallFacet(%T: %.1, %x: @CallFacet.%T (%T)) -// CHECK:STDOUT: generic [%T: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.ref: %T = name_ref x, %x -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @CallStatic(%T.loc13: %.1) { +// CHECK:STDOUT: %T.1: %.1 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc13: %.1) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T.loc13 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: %F.ref: %.3 = name_ref F, @Interface.%.loc11 [template = constants.%.4] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @CallFacet(%T.loc21: %.1) { +// CHECK:STDOUT: %T.1: %.1 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc21: %.1, %x: @CallFacet.%T.1 (%T)) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: @CallFacet.%T.1 (%T) = name_ref x, %x +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CallStatic(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @CallFacet(constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon index 332e088138659..0f5fa7aed3764 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon @@ -28,14 +28,15 @@ fn I(T:! type).F[self: Self]() -> Self { return self; } // CHECK:STDOUT: %I.type: type = generic_interface_type @I [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %I: %I.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = interface_type @I, (%T) [symbolic] +// CHECK:STDOUT: %.2: type = interface_type @I, @I(%T) [symbolic] // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = assoc_entity_type @I, %F.type [template] -// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%F.decl [template] -// CHECK:STDOUT: %.type: type = fn_type @.1 [template] -// CHECK:STDOUT: %.5: %.type = struct_value () [template] +// CHECK:STDOUT: %F.type: type = fn_type @F, @I(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = assoc_entity_type @I, %F.type [symbolic] +// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%F.decl [symbolic] +// CHECK:STDOUT: %F.2: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %.type: type = fn_type @.1, @I(%T) [symbolic] +// CHECK:STDOUT: %.5: %.type = struct_value () [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -44,56 +45,115 @@ fn I(T:! type).F[self: Self]() -> Self { return self; } // CHECK:STDOUT: } // CHECK:STDOUT: %I.decl: %I.type = interface_decl @I [template = constants.%I] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = @I.%T (constants.%T)] // CHECK:STDOUT: } -// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.5] { +// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [symbolic = constants.%.5] { // CHECK:STDOUT: %T.loc22_6.1: type = param T -// CHECK:STDOUT: %T.loc22_6.2: type = bind_symbolic_name T 0, %T.loc22_6.1 [symbolic = %T.loc22_6.2 (constants.%T)] -// CHECK:STDOUT: %.loc22_24.1: (%.2) = specific_constant @I.%Self, (constants.%T) [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %Self.ref.loc22_24: (%.2) = name_ref Self, %.loc22_24.1 [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %.loc22_24.2: type = facet_type_access %Self.ref.loc22_24 [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %.loc22_24.3: type = converted %Self.ref.loc22_24, %.loc22_24.2 [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %self.loc22_18.1: file.%.loc22_24.1 (%Self) = param self -// CHECK:STDOUT: @.1.%self: file.%.loc22_24.1 (%Self) = bind_name self, %self.loc22_18.1 -// CHECK:STDOUT: %.loc22_35.1: (%.2) = specific_constant @I.%Self, (constants.%T) [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %Self.ref.loc22_35: (%.2) = name_ref Self, %.loc22_35.1 [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %.loc22_35.2: type = facet_type_access %Self.ref.loc22_35 [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: %.loc22_35.3: type = converted %Self.ref.loc22_35, %.loc22_35.2 [symbolic = %.loc22_24.1 (constants.%Self)] -// CHECK:STDOUT: @.1.%return: ref %Self = var +// CHECK:STDOUT: %T.loc22_6.2: type = bind_symbolic_name T 0, %T.loc22_6.1 [symbolic = @.1.%T (constants.%T)] +// CHECK:STDOUT: %.loc22_24.1: @.1.%.1 (%.2) = specific_constant @I.%Self.1, @I(constants.%T) [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %Self.ref.loc22_24: @.1.%.1 (%.2) = name_ref Self, %.loc22_24.1 [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc22_24.2: type = facet_type_access %Self.ref.loc22_24 [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc22_24.3: type = converted %Self.ref.loc22_24, %.loc22_24.2 [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc22_18.1: @.1.%Self (%Self) = param self +// CHECK:STDOUT: @.1.%self: @.1.%Self (%Self) = bind_name self, %self.loc22_18.1 +// CHECK:STDOUT: %.loc22_35.1: @.1.%.1 (%.2) = specific_constant @I.%Self.1, @I(constants.%T) [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %Self.ref.loc22_35: @.1.%.1 (%.2) = name_ref Self, %.loc22_35.1 [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc22_35.2: type = facet_type_access %Self.ref.loc22_35 [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc22_35.3: type = converted %Self.ref.loc22_35, %.loc22_35.2 [symbolic = @.1.%Self (constants.%Self)] +// CHECK:STDOUT: @.1.%return: ref @.1.%Self (%Self) = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @I -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %.loc13_14.1: %.2 = specific_constant %Self, (constants.%T) [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %Self.ref.loc13_14: %.2 = name_ref Self, %.loc13_14.1 [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %.loc13_14.2: type = facet_type_access %Self.ref.loc13_14 [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %.loc13_14.3: type = converted %Self.ref.loc13_14, %.loc13_14.2 [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %self.loc13_8.1: @I.%.loc13_14.1 (%Self) = param self -// CHECK:STDOUT: %self.loc13_8.2: @I.%.loc13_14.1 (%Self) = bind_name self, %self.loc13_8.1 -// CHECK:STDOUT: %.loc13_25.1: %.2 = specific_constant %Self, (constants.%T) [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %Self.ref.loc13_25: %.2 = name_ref Self, %.loc13_25.1 [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %.loc13_25.2: type = facet_type_access %Self.ref.loc13_25 [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %.loc13_25.3: type = converted %Self.ref.loc13_25, %.loc13_25.2 [symbolic = %.loc13_14.1 (constants.%Self)] -// CHECK:STDOUT: %return.var: ref %Self = var +// CHECK:STDOUT: generic interface @I(file.%T.loc11_13.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @I, @I(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @I(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @I.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.2: type = assoc_entity_type @I, @I.%F.type (%F.type) [symbolic = %.2 (constants.%.3)] +// CHECK:STDOUT: %.3: @I.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @I.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.decl: @I.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %.loc13_14.1: @F.%.1 (%.2) = specific_constant %Self.1, @I(constants.%T) [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %Self.ref.loc13_14: @F.%.1 (%.2) = name_ref Self, %.loc13_14.1 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.2: type = facet_type_access %Self.ref.loc13_14 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.3: type = converted %Self.ref.loc13_14, %.loc13_14.2 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc13_8.1: @F.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc13_8.2: @F.%Self (%Self) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %.loc13_25.1: @F.%.1 (%.2) = specific_constant %Self.1, @I(constants.%T) [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %Self.ref.loc13_25: @F.%.1 (%.2) = name_ref Self, %.loc13_25.1 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc13_25.2: type = facet_type_access %Self.ref.loc13_25 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc13_25.3: type = converted %Self.ref.loc13_25, %.loc13_25.2 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %return.var: ref @F.%Self (%Self) = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc13_29: @I.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .F = %.loc13_29 +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(file.%T.loc11_13.2: type, @I.%Self.1: @I.%.1 (%.2)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.1: type = interface_type @I, @I(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@I.%self.loc13_8.2: @F.%Self (%Self)]() -> @F.%Self (%Self); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @.1(file.%T.loc22_6.2: type, @I.%Self.1: @I.%.1 (%.2)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %.1: type = interface_type @I, @I(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: @.1.%Self (%Self)]() -> @.1.%Self (%Self) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %self.ref: @.1.%Self (%Self) = name_ref self, %self +// CHECK:STDOUT: return %self.ref // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc13_29: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: %Self.2 => constants.%Self +// CHECK:STDOUT: %F.type => constants.%F.type +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: %.2 => constants.%.3 +// CHECK:STDOUT: %.3 => constants.%.4 +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc13_29 -// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: specific @I(@F.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[@I.%self.loc13_8.2: @I.%.loc13_14.1 (%Self)]() -> %Self -// CHECK:STDOUT: generic [file.%T.loc11_13.2: type, @I.%Self: %.2]; +// CHECK:STDOUT: specific @F(constants.%T, constants.%Self) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(@I.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(@.1.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1[%self: file.%.loc22_24.1 (%Self)]() -> %Self -// CHECK:STDOUT: generic [file.%T.loc22_6.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %self.ref: %Self = name_ref self, %self -// CHECK:STDOUT: return %self.ref +// CHECK:STDOUT: specific @.1(constants.%T, constants.%Self) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %.1 => constants.%.2 +// CHECK:STDOUT: %Self => constants.%Self // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon index 2eae187451ae9..4c1181f35d3c4 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_modifiers.carbon @@ -57,15 +57,25 @@ interface Modifiers { // CHECK:STDOUT: witness = (%Final.decl, %Default.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Final() -// CHECK:STDOUT: generic [@Modifiers.%Self: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @Final(@Modifiers.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Default() -// CHECK:STDOUT: generic [@Modifiers.%Self: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @Default(@Modifiers.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @Final(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Default(constants.%Self) {} +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/generic.carbon b/toolchain/check/testdata/interface/no_prelude/generic.carbon index b71c38bba05a6..950fe4b56632a 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic.carbon @@ -65,22 +65,22 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %Simple.type: type = generic_interface_type @Simple [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Simple: %Simple.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = interface_type @Simple, (%T.1) [symbolic] +// CHECK:STDOUT: %.2: type = interface_type @Simple, @Simple(%T.1) [symbolic] // CHECK:STDOUT: %Self.1: %.2 = bind_symbolic_name Self 1 [symbolic] // CHECK:STDOUT: %X: type = class_type @X [template] // CHECK:STDOUT: %.3: type = struct_type {} [template] // CHECK:STDOUT: %WithAssocFn.type: type = generic_interface_type @WithAssocFn [template] // CHECK:STDOUT: %WithAssocFn: %WithAssocFn.type = struct_value () [template] -// CHECK:STDOUT: %.4: type = interface_type @WithAssocFn, (%T.1) [symbolic] +// CHECK:STDOUT: %.4: type = interface_type @WithAssocFn, @WithAssocFn(%T.1) [symbolic] // CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic] -// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] -// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] -// CHECK:STDOUT: %.5: type = assoc_entity_type @WithAssocFn, %F.type.1 [template] -// CHECK:STDOUT: %.6: %.5 = assoc_entity element0, @WithAssocFn.%F.decl [template] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @WithAssocFn(%T.1) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.5: type = assoc_entity_type @WithAssocFn, %F.type.1 [symbolic] +// CHECK:STDOUT: %.6: %.5 = assoc_entity element0, @WithAssocFn.%F.decl [symbolic] // CHECK:STDOUT: %C: type = class_type @C [template] -// CHECK:STDOUT: %.7: type = interface_type @Simple, (%C) [template] +// CHECK:STDOUT: %.7: type = interface_type @Simple, @Simple(%C) [template] // CHECK:STDOUT: %.8: = interface_witness () [template] -// CHECK:STDOUT: %.9: type = interface_type @WithAssocFn, (%C) [template] +// CHECK:STDOUT: %.9: type = interface_type @WithAssocFn, @WithAssocFn(%C) [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: %.10: = interface_witness (%F.2) [template] @@ -108,20 +108,20 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: } // CHECK:STDOUT: %Simple.decl: %Simple.type = interface_decl @Simple [template = constants.%Simple] { // CHECK:STDOUT: %T.loc4_18.1: type = param T -// CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T 0, %T.loc4_18.1 [symbolic = %T.loc4_18.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T 0, %T.loc4_18.1 [symbolic = @Simple.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} // CHECK:STDOUT: %WithAssocFn.decl: %WithAssocFn.type = interface_decl @WithAssocFn [template = constants.%WithAssocFn] { // CHECK:STDOUT: %T.loc8_23.1: type = param T -// CHECK:STDOUT: %T.loc8_23.2: type = bind_symbolic_name T 0, %T.loc8_23.1 [symbolic = %T.loc8_23.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc8_23.2: type = bind_symbolic_name T 0, %T.loc8_23.1 [symbolic = @WithAssocFn.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %WithImplicitArgs.decl: %WithImplicitArgs.type = interface_decl @WithImplicitArgs [template = constants.%WithImplicitArgs] { // CHECK:STDOUT: %T.loc22_28.1: type = param T -// CHECK:STDOUT: %T.loc22_28.2: type = bind_symbolic_name T 0, %T.loc22_28.1 [symbolic = %T.loc22_28.2 (constants.%T.1)] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc22_28.2 [symbolic = %T.loc22_28.2 (constants.%T.1)] -// CHECK:STDOUT: %N.loc22_38.1: file.%T.loc22_28.2 (%T.1) = param N -// CHECK:STDOUT: %N.loc22_38.2: file.%T.loc22_28.2 (%T.1) = bind_symbolic_name N 1, %N.loc22_38.1 [symbolic = %N.loc22_38.2 (constants.%N)] +// CHECK:STDOUT: %T.loc22_28.2: type = bind_symbolic_name T 0, %T.loc22_28.1 [symbolic = @WithImplicitArgs.%T (constants.%T.1)] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc22_28.2 [symbolic = @WithImplicitArgs.%T (constants.%T.1)] +// CHECK:STDOUT: %N.loc22_38.1: @WithImplicitArgs.%T (%T.1) = param N +// CHECK:STDOUT: %N.loc22_38.2: @WithImplicitArgs.%T (%T.1) = bind_symbolic_name N 1, %N.loc22_38.1 [symbolic = @WithImplicitArgs.%N (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Receive.decl: %Receive.type = fn_decl @Receive [template = constants.%Receive] { // CHECK:STDOUT: %Simple.ref.loc24: %Simple.type = name_ref Simple, %Simple.decl [template = constants.%Simple] @@ -130,7 +130,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc24_24.1: type = value_of_initializer %.loc24_22 [template = constants.%.7] // CHECK:STDOUT: %.loc24_24.2: type = converted %.loc24_22, %.loc24_24.1 [template = constants.%.7] // CHECK:STDOUT: %T.loc24_12.1: %.7 = param T -// CHECK:STDOUT: @Receive.%T: %.7 = bind_symbolic_name T 0, %T.loc24_12.1 [symbolic = @Receive.%T (constants.%T.2)] +// CHECK:STDOUT: @Receive.%T.loc24: %.7 = bind_symbolic_name T 0, %T.loc24_12.1 [symbolic = @Receive.%T.1 (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: %Pass.decl: %Pass.type = fn_decl @Pass [template = constants.%Pass] { // CHECK:STDOUT: %Simple.ref.loc25: %Simple.type = name_ref Simple, %Simple.decl [template = constants.%Simple] @@ -139,36 +139,58 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc25_21.1: type = value_of_initializer %.loc25_19 [template = constants.%.7] // CHECK:STDOUT: %.loc25_21.2: type = converted %.loc25_19, %.loc25_21.1 [template = constants.%.7] // CHECK:STDOUT: %T.loc25_9.1: %.7 = param T -// CHECK:STDOUT: @Pass.%T: %.7 = bind_symbolic_name T 0, %T.loc25_9.1 [symbolic = @Pass.%T (constants.%T.2)] +// CHECK:STDOUT: @Pass.%T.loc25: %.7 = bind_symbolic_name T 0, %T.loc25_9.1 [symbolic = @Pass.%T.1 (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @Simple -// CHECK:STDOUT: generic [file.%T.loc4_18.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self.1] +// CHECK:STDOUT: generic interface @Simple(file.%T.loc4_18.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: witness = () -// CHECK:STDOUT: } +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @Simple, @Simple(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)] // CHECK:STDOUT: -// CHECK:STDOUT: interface @WithAssocFn -// CHECK:STDOUT: generic [file.%T.loc8_23.2: type] { -// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = constants.%Self.2] -// CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X] -// CHECK:STDOUT: %return.var: ref %X = var +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @Simple.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: witness = () // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc10: %.5 = assoc_entity element0, %F.decl [template = constants.%.6] +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc10 -// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: generic interface @WithAssocFn(file.%T.loc8_23.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @WithAssocFn, @WithAssocFn(%T) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @WithAssocFn(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @WithAssocFn.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.2: type = assoc_entity_type @WithAssocFn, @WithAssocFn.%F.type (%F.type.1) [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: %.3: @WithAssocFn.%.2 (%.5) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.6)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @WithAssocFn.%.1 (%.4) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.2)] +// CHECK:STDOUT: %F.decl: @WithAssocFn.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = %F (constants.%F.1)] { +// CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %return.var: ref %X = var +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10: @WithAssocFn.%.2 (%.5) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.6)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .F = %.loc10 +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @WithImplicitArgs -// CHECK:STDOUT: generic [file.%T.loc22_28.2: type, file.%N.loc22_38.2: file.%T.loc22_28.2 (%T.1)]; +// CHECK:STDOUT: generic interface @WithImplicitArgs(file.%T.loc22_28.2: type, file.%N.loc22_38.2: @WithImplicitArgs.%T (%T.1)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] +// CHECK:STDOUT: %N: %T.1 = bind_symbolic_name N 1 [symbolic = %N (constants.%N)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.1: %C as %.7 { // CHECK:STDOUT: %.1: = interface_witness () [template = constants.%.8] @@ -214,8 +236,10 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -> %X -// CHECK:STDOUT: generic [file.%T.loc8_23.2: type, @WithAssocFn.%Self: %.4]; +// CHECK:STDOUT: generic fn @F.1(file.%T.loc8_23.2: type, @WithAssocFn.%Self.1: @WithAssocFn.%.1 (%.4)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> %X; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() -> @impl.2.%return.var: %X { // CHECK:STDOUT: !entry: @@ -225,16 +249,63 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: return %.loc17_16 to @impl.2.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Receive(%T: %.7) -// CHECK:STDOUT: generic [%T: %.7]; +// CHECK:STDOUT: generic fn @Receive(%T.loc24: %.7) { +// CHECK:STDOUT: %T.1: %.7 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @Pass(%T: %.7) -// CHECK:STDOUT: generic [%T: %.7] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Receive.ref: %Receive.type = name_ref Receive, file.%Receive.decl [template = constants.%Receive] -// CHECK:STDOUT: %T.ref: %.7 = name_ref T, %T [symbolic = constants.%T.2] -// CHECK:STDOUT: %Receive.call: init %.1 = call %Receive.ref(%T.ref) -// CHECK:STDOUT: return +// CHECK:STDOUT: fn(%T.loc24: %.7); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Pass(%T.loc25: %.7) { +// CHECK:STDOUT: %T.1: %.7 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc25: %.7) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Receive.ref: %Receive.type = name_ref Receive, file.%Receive.decl [template = constants.%Receive] +// CHECK:STDOUT: %T.ref: %.7 = name_ref T, %T.loc25 [symbolic = %T.1 (constants.%T.2)] +// CHECK:STDOUT: %Receive.call: init %.1 = call %Receive.ref(%T.ref) +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Simple(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Simple(@Simple.%T) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @WithAssocFn(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T.1, constants.%Self.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @WithAssocFn(@WithAssocFn.%T) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Simple(constants.%C) { +// CHECK:STDOUT: %T => constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @WithAssocFn(constants.%C) { +// CHECK:STDOUT: %T => constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @WithImplicitArgs(constants.%T.1, constants.%N) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: %N => constants.%N +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Receive(constants.%T.2) { +// CHECK:STDOUT: %T.1 => constants.%T.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Pass(constants.%T.2) { +// CHECK:STDOUT: %T.1 => constants.%T.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_mismatched_args.carbon @@ -244,16 +315,16 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %Generic.type: type = generic_interface_type @Generic [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Generic: %Generic.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = interface_type @Generic, (%T.1) [symbolic] +// CHECK:STDOUT: %.2: type = interface_type @Generic, @Generic(%T.1) [symbolic] // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic] // CHECK:STDOUT: %A: type = class_type @A [template] // CHECK:STDOUT: %.3: type = struct_type {} [template] // CHECK:STDOUT: %B: type = class_type @B [template] -// CHECK:STDOUT: %.4: type = interface_type @Generic, (%A) [template] +// CHECK:STDOUT: %.4: type = interface_type @Generic, @Generic(%A) [template] // CHECK:STDOUT: %T.2: %.4 = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.5: type = interface_type @Generic, (%B) [template] +// CHECK:STDOUT: %.5: type = interface_type @Generic, @Generic(%B) [template] // CHECK:STDOUT: %T.3: %.5 = bind_symbolic_name T 0 [symbolic] // CHECK:STDOUT: %G.type: type = fn_type @G [template] // CHECK:STDOUT: %G: %G.type = struct_value () [template] @@ -269,7 +340,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: } // CHECK:STDOUT: %Generic.decl: %Generic.type = interface_decl @Generic [template = constants.%Generic] { // CHECK:STDOUT: %T.loc4_19.1: type = param T -// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = %T.loc4_19.2 (constants.%T.1)] +// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = @Generic.%T (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} @@ -280,7 +351,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc9_19.1: type = value_of_initializer %.loc9_17 [template = constants.%.4] // CHECK:STDOUT: %.loc9_19.2: type = converted %.loc9_17, %.loc9_19.1 [template = constants.%.4] // CHECK:STDOUT: %T.loc9_6.1: %.4 = param T -// CHECK:STDOUT: @F.%T: %.4 = bind_symbolic_name T 0, %T.loc9_6.1 [symbolic = @F.%T (constants.%T.2)] +// CHECK:STDOUT: @F.%T.loc9: %.4 = bind_symbolic_name T 0, %T.loc9_6.1 [symbolic = @F.%T.1 (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %Generic.ref.loc10: %Generic.type = name_ref Generic, %Generic.decl [template = constants.%Generic] @@ -289,17 +360,24 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc10_19.1: type = value_of_initializer %.loc10_17 [template = constants.%.5] // CHECK:STDOUT: %.loc10_19.2: type = converted %.loc10_17, %.loc10_19.1 [template = constants.%.5] // CHECK:STDOUT: %T.loc10_6.1: %.5 = param T -// CHECK:STDOUT: @G.%T: %.5 = bind_symbolic_name T 0, %T.loc10_6.1 [symbolic = @G.%T (constants.%T.3)] +// CHECK:STDOUT: @G.%T.loc10: %.5 = bind_symbolic_name T 0, %T.loc10_6.1 [symbolic = @G.%T.1 (constants.%T.3)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @Generic -// CHECK:STDOUT: generic [file.%T.loc4_19.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] +// CHECK:STDOUT: generic interface @Generic(file.%T.loc4_19.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)] // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: witness = () +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @Generic, @Generic(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @Generic.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { @@ -312,15 +390,51 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: .Self = constants.%B // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: %.4) -// CHECK:STDOUT: generic [%T: %.4]; +// CHECK:STDOUT: generic fn @F(%T.loc9: %.4) { +// CHECK:STDOUT: %T.1: %.4 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%T: %.5) -// CHECK:STDOUT: generic [%T: %.5] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T [symbolic = constants.%T.3] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] -// CHECK:STDOUT: return +// CHECK:STDOUT: fn(%T.loc9: %.4); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G(%T.loc10: %.5) { +// CHECK:STDOUT: %T.1: %.5 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(%T.loc10: %.5) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] +// CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T.loc10 [symbolic = %T.1 (constants.%T.3)] +// CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%T.1) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(@Generic.%T) { +// CHECK:STDOUT: %T => constants.%T.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%A) { +// CHECK:STDOUT: %T => constants.%A +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T.2) { +// CHECK:STDOUT: %T.1 => constants.%T.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Generic(constants.%B) { +// CHECK:STDOUT: %T => constants.%B +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%T.3) { +// CHECK:STDOUT: %T.1 => constants.%T.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T.3) { +// CHECK:STDOUT: %T.1 => constants.%T.3 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon b/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon index 2a689eb58cd60..8543dd887cd57 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon @@ -46,14 +46,14 @@ interface I { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc12_8.1: type = param T -// CHECK:STDOUT: %T.loc12_8.2: type = bind_symbolic_name T 1, %T.loc12_8.1 [symbolic = %T.loc12_8.2 (constants.%T)] +// CHECK:STDOUT: %T.loc12_8.2: type = bind_symbolic_name T 1, %T.loc12_8.1 [symbolic = @F.%T.1 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: %U: type = assoc_const_decl U [template] // CHECK:STDOUT: %.loc13: %.5 = assoc_entity element1, %U [template = constants.%.6] // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %T.loc16_8.1: type = param T -// CHECK:STDOUT: %T.loc16_8.2: type = bind_symbolic_name T 1, %T.loc16_8.1 [symbolic = %T.loc16_8.2 (constants.%T)] +// CHECK:STDOUT: %T.loc16_8.2: type = bind_symbolic_name T 1, %T.loc16_8.1 [symbolic = @G.%T.1 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.loc16: %.7 = assoc_entity element2, %G.decl [template = constants.%.8] // CHECK:STDOUT: @@ -65,9 +65,23 @@ interface I { // CHECK:STDOUT: witness = (%F.decl, %U, %G.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(@I.%T.loc12_8.2: type) -// CHECK:STDOUT: generic [@I.%Self: %.1, @I.%T.loc12_8.2: type]; +// CHECK:STDOUT: generic fn @F(@I.%Self: %.1, @I.%T.loc12_8.2: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 1 [symbolic = %T.1 (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(@I.%T.loc16_8.2: type) -// CHECK:STDOUT: generic [@I.%Self: %.1, @I.%T.loc16_8.2: type]; +// CHECK:STDOUT: fn(@I.%T.loc12_8.2: type); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @G(@I.%Self: %.1, @I.%T.loc16_8.2: type) { +// CHECK:STDOUT: %T.1: type = bind_symbolic_name T 1 [symbolic = %T.1 (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@I.%T.loc16_8.2: type); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self, constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%Self, constants.%T) { +// CHECK:STDOUT: %T.1 => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/generic_import.carbon b/toolchain/check/testdata/interface/no_prelude/generic_import.carbon index 66f37982ee93c..3eb3de03f87b6 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic_import.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic_import.carbon @@ -34,12 +34,12 @@ impl C as AddWith(C) { // CHECK:STDOUT: %AddWith.type: type = generic_interface_type @AddWith [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %AddWith: %AddWith.type = struct_value () [template] -// CHECK:STDOUT: %.2: type = interface_type @AddWith, (%T) [symbolic] +// CHECK:STDOUT: %.2: type = interface_type @AddWith, @AddWith(%T) [symbolic] // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] -// CHECK:STDOUT: %.3: type = assoc_entity_type @AddWith, %F.type [template] -// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @AddWith.%F.decl [template] +// CHECK:STDOUT: %F.type: type = fn_type @F, @AddWith(%T) [symbolic] +// CHECK:STDOUT: %F: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = assoc_entity_type @AddWith, %F.type [symbolic] +// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @AddWith.%F.decl [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -48,24 +48,47 @@ impl C as AddWith(C) { // CHECK:STDOUT: } // CHECK:STDOUT: %AddWith.decl: %AddWith.type = interface_decl @AddWith [template = constants.%AddWith] { // CHECK:STDOUT: %T.loc4_19.1: type = param T -// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = %T.loc4_19.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = @AddWith.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @AddWith -// CHECK:STDOUT: generic [file.%T.loc4_19.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} -// CHECK:STDOUT: %.loc5: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] +// CHECK:STDOUT: generic interface @AddWith(file.%T.loc4_19.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @AddWith, @AddWith(%T) [symbolic = %.1 (constants.%.2)] +// CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @AddWith(%T) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @AddWith.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F)] +// CHECK:STDOUT: %.2: type = assoc_entity_type @AddWith, @AddWith.%F.type (%F.type) [symbolic = %.2 (constants.%.3)] +// CHECK:STDOUT: %.3: @AddWith.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @AddWith.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.decl: @AddWith.%F.type (%F.type) = fn_decl @F [symbolic = %F (constants.%F)] {} +// CHECK:STDOUT: %.loc5: @AddWith.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .F = %.loc5 +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc5 -// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: generic fn @F(file.%T.loc4_19.2: type, @AddWith.%Self.1: @AddWith.%.1 (%.2)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AddWith(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [file.%T.loc4_19.2: type, @AddWith.%Self: %.2]; +// CHECK:STDOUT: specific @F(constants.%T, constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AddWith(@AddWith.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: @@ -75,22 +98,27 @@ impl C as AddWith(C) { // CHECK:STDOUT: %AddWith.type: type = generic_interface_type @AddWith [template] // CHECK:STDOUT: %.2: type = tuple_type () [template] // CHECK:STDOUT: %AddWith: %AddWith.type = struct_value () [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] -// CHECK:STDOUT: %.3: type = interface_type @AddWith, (%T) [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %.3: type = interface_type @AddWith, @AddWith(%T) [symbolic] // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 1 [symbolic] -// CHECK:STDOUT: %.4: type = interface_type @AddWith, (%C) [template] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] -// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] -// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] -// CHECK:STDOUT: %.5: = interface_witness (%F.1) [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @AddWith(%T) [symbolic] +// CHECK:STDOUT: %.4: type = assoc_entity_type @AddWith, %F.type.2 [symbolic] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.2 [symbolic] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [symbolic] +// CHECK:STDOUT: %.6: type = interface_type @AddWith, @AddWith(%C) [template] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.7: = interface_witness (%F.3) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %AddWith.type = import_ref ir1, inst+4, loaded [template = constants.%AddWith] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+15, unloaded -// CHECK:STDOUT: %import_ref.4: %F.type.2 = import_ref ir1, inst+11, loaded [template = constants.%F.2] +// CHECK:STDOUT: %import_ref.1: %AddWith.type = import_ref Main//a, inst+4, loaded [template = constants.%AddWith] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+12, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+10, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//a, inst+16, unloaded +// CHECK:STDOUT: %import_ref.5: @AddWith.%F.type (%F.type.2) = import_ref Main//a, inst+12, loaded [symbolic = @AddWith.%F (constants.%F.1)] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -100,26 +128,38 @@ impl C as AddWith(C) { // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} -// CHECK:STDOUT: %.loc7_20.1: type = value_of_initializer %.loc7_18 [template = constants.%.4] -// CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_18, %.loc7_20.1 [template = constants.%.4] +// CHECK:STDOUT: %.loc7_20.1: type = value_of_initializer %.loc7_18 [template = constants.%.6] +// CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_18, %.loc7_20.1 [template = constants.%.6] // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref.loc7_6: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %AddWith.ref: %AddWith.type = name_ref AddWith, imports.%import_ref.1 [template = constants.%AddWith] // CHECK:STDOUT: %C.ref.loc7_19: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %.loc7_18: init type = call %AddWith.ref(%C.ref.loc7_19) [template = constants.%.4] +// CHECK:STDOUT: %.loc7_18: init type = call %AddWith.ref(%C.ref.loc7_19) [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @AddWith { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.2 -// CHECK:STDOUT: .F = imports.%import_ref.3 -// CHECK:STDOUT: witness = (imports.%import_ref.4) +// CHECK:STDOUT: generic interface @AddWith(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %.1: type = interface_type @AddWith, @AddWith(%T) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @AddWith(%T) [symbolic = %F.type (constants.%F.type.2)] +// CHECK:STDOUT: %F: @AddWith.%F.type (%F.type.2) = struct_value () [symbolic = %F (constants.%F.2)] +// CHECK:STDOUT: %.2: type = assoc_entity_type @AddWith, @AddWith.%F.type (%F.type.2) [symbolic = %.2 (constants.%.4)] +// CHECK:STDOUT: %.3: @AddWith.%.2 (%.4) = assoc_entity element0, imports.%import_ref.2 [symbolic = %.3 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.3 +// CHECK:STDOUT: .F = imports.%import_ref.4 +// CHECK:STDOUT: witness = (imports.%import_ref.5) +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl: %C as %.4 { -// CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} -// CHECK:STDOUT: %.1: = interface_witness (%F.decl) [template = constants.%.5] +// CHECK:STDOUT: impl @impl: %C as %.6 { +// CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.2 [template = constants.%F.3] {} +// CHECK:STDOUT: %.1: = interface_witness (%F.decl) [template = constants.%.7] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .F = %F.decl @@ -131,10 +171,25 @@ impl C as AddWith(C) { // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() { +// CHECK:STDOUT: generic fn @F.1(constants.%T: type, constants.%Self: %.3) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: specific @AddWith(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AddWith(@AddWith.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AddWith(constants.%C) { +// CHECK:STDOUT: %T => constants.%C +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/import.carbon b/toolchain/check/testdata/interface/no_prelude/import.carbon index 9ae96e4caa77e..11bc5f8beb281 100644 --- a/toolchain/check/testdata/interface/no_prelude/import.carbon +++ b/toolchain/check/testdata/interface/no_prelude/import.carbon @@ -126,11 +126,19 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: witness = (%T, %F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1() -// CHECK:STDOUT: generic [@Basic.%Self: %.2]; +// CHECK:STDOUT: generic fn @F.1(@Basic.%Self: %.2) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2() -// CHECK:STDOUT: generic [@ForwardDeclared.%Self: %.8]; +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.2(@ForwardDeclared.%Self: %.8) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.2(constants.%Self.3) {} // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: @@ -166,25 +174,25 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%.1] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+5, loaded [template = constants.%.3] -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+20, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.4: ref %.14 = import_ref ir1, inst+42, loaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+7, unloaded -// CHECK:STDOUT: %import_ref.7: %.5 = import_ref ir1, inst+11, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.8: %.7 = import_ref ir1, inst+18, loaded [template = constants.%.8] -// CHECK:STDOUT: %import_ref.9 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.11 = import_ref ir1, inst+22, unloaded -// CHECK:STDOUT: %import_ref.12: %.9 = import_ref ir1, inst+26, loaded [template = constants.%.10] -// CHECK:STDOUT: %import_ref.13: %.11 = import_ref ir1, inst+32, loaded [template = constants.%.12] -// CHECK:STDOUT: %import_ref.14 = import_ref ir1, inst+24, unloaded -// CHECK:STDOUT: %import_ref.15 = import_ref ir1, inst+28, unloaded -// CHECK:STDOUT: %import_ref.16 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.17 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.18 = import_ref ir1, inst+24, unloaded -// CHECK:STDOUT: %import_ref.19 = import_ref ir1, inst+28, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+1, loaded [template = constants.%.1] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//a, inst+5, loaded [template = constants.%.3] +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//a, inst+20, loaded [template = constants.%.4] +// CHECK:STDOUT: %import_ref.4: ref %.14 = import_ref Main//a, inst+42, loaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//a, inst+3, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//a, inst+7, unloaded +// CHECK:STDOUT: %import_ref.7: %.5 = import_ref Main//a, inst+11, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.8: %.7 = import_ref Main//a, inst+18, loaded [template = constants.%.8] +// CHECK:STDOUT: %import_ref.9 = import_ref Main//a, inst+9, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Main//a, inst+13, unloaded +// CHECK:STDOUT: %import_ref.11 = import_ref Main//a, inst+22, unloaded +// CHECK:STDOUT: %import_ref.12: %.9 = import_ref Main//a, inst+26, loaded [template = constants.%.10] +// CHECK:STDOUT: %import_ref.13: %.11 = import_ref Main//a, inst+32, loaded [template = constants.%.12] +// CHECK:STDOUT: %import_ref.14 = import_ref Main//a, inst+24, unloaded +// CHECK:STDOUT: %import_ref.15 = import_ref Main//a, inst+28, unloaded +// CHECK:STDOUT: %import_ref.16 = import_ref Main//a, inst+9, unloaded +// CHECK:STDOUT: %import_ref.17 = import_ref Main//a, inst+13, unloaded +// CHECK:STDOUT: %import_ref.18 = import_ref Main//a, inst+24, unloaded +// CHECK:STDOUT: %import_ref.19 = import_ref Main//a, inst+28, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -273,9 +281,15 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1(); +// CHECK:STDOUT: generic fn @F.1(constants.%Self.2: %.3) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: generic fn @F.2(constants.%Self.3: %.4) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/interface/no_prelude/import_access.carbon b/toolchain/check/testdata/interface/no_prelude/import_access.carbon index 1b4de06936495..508e65a8af664 100644 --- a/toolchain/check/testdata/interface/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/interface/no_prelude/import_access.carbon @@ -202,8 +202,8 @@ private interface Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%.1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Test//def, inst+1, loaded [template = constants.%.1] +// CHECK:STDOUT: %import_ref.2 = import_ref Test//def, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -264,15 +264,20 @@ private interface Redecl {} // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Test.ref: = name_ref Test, %Test [template = %Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %Def.ref: = name_ref Def, [template = ] // CHECK:STDOUT: %i.loc10_6.1: = param i // CHECK:STDOUT: @F.%i: = bind_name i, %i.loc10_6.1 @@ -295,8 +300,8 @@ private interface Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+1, loaded [template = constants.%.1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Test//forward_with_def, inst+1, loaded [template = constants.%.1] +// CHECK:STDOUT: %import_ref.2 = import_ref Test//forward_with_def, inst+4, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -357,15 +362,20 @@ private interface Redecl {} // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//forward_with_def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Test.ref: = name_ref Test, %Test [template = %Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %ForwardWithDef.ref: = name_ref ForwardWithDef, [template = ] // CHECK:STDOUT: %i.loc10_6.1: = param i // CHECK:STDOUT: @F.%i: = bind_name i, %i.loc10_6.1 @@ -450,13 +460,18 @@ private interface Redecl {} // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//forward +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Forward.ref: = name_ref Forward, [template = ] // CHECK:STDOUT: %.loc9: type = ptr_type [template = ] diff --git a/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon b/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon new file mode 100644 index 0000000000000..4d91fdb329768 --- /dev/null +++ b/toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon @@ -0,0 +1,65 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/import_interface_decl.carbon + +// --- a.carbon +library "a"; +interface A; +impl () as A; + + +// --- a.impl.carbon +impl library "a"; + +// CHECK:STDOUT: --- a.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = interface_type @A [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %A.decl: type = interface_decl @A [template = constants.%.1] {} +// CHECK:STDOUT: impl_decl @impl { +// CHECK:STDOUT: %.loc3_7.1: %.2 = tuple_literal () +// CHECK:STDOUT: %.loc3_7.2: type = converted %.loc3_7.1, constants.%.2 [template = constants.%.2] +// CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%.1] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @A; +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.2 as %.1; +// CHECK:STDOUT: +// CHECK:STDOUT: --- a.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %.2: type = interface_type @A [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref = import_ref Main//a, inst+1, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .A = imports.%import_ref +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc1_6.1 = import +// CHECK:STDOUT: %default.import.loc1_6.2 = import +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @A; +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.1 as %.2; +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/self.carbon b/toolchain/check/testdata/interface/no_prelude/self.carbon index 343b646a2caf4..f26031ba296e9 100644 --- a/toolchain/check/testdata/interface/no_prelude/self.carbon +++ b/toolchain/check/testdata/interface/no_prelude/self.carbon @@ -34,15 +34,15 @@ interface UseSelf { // CHECK:STDOUT: interface @UseSelf { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %self.loc12_8.1: @UseSelf.%Self.ref.loc12_14 (%Self) = param self -// CHECK:STDOUT: %self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self) = bind_name self, %self.loc12_8.1 -// CHECK:STDOUT: %Self.ref.loc12_25: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_25.1: type = facet_type_access %Self.ref.loc12_25 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %.loc12_25.2: type = converted %Self.ref.loc12_25, %.loc12_25.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] -// CHECK:STDOUT: %return.var: ref %Self = var +// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %self.loc12_8.1: @F.%Self (%Self) = param self +// CHECK:STDOUT: %self.loc12_8.2: @F.%Self (%Self) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref.loc12_25: %.1 = name_ref Self, %Self [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_25.1: type = facet_type_access %Self.ref.loc12_25 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %.loc12_25.2: type = converted %Self.ref.loc12_25, %.loc12_25.1 [symbolic = @F.%Self (constants.%Self)] +// CHECK:STDOUT: %return.var: ref @F.%Self (%Self) = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_29: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: @@ -52,6 +52,13 @@ interface UseSelf { // CHECK:STDOUT: witness = (%F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[@UseSelf.%self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self)]() -> %Self -// CHECK:STDOUT: generic [@UseSelf.%Self: %.1]; +// CHECK:STDOUT: generic fn @F(@UseSelf.%Self: %.1) { +// CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[@UseSelf.%self.loc12_8.2: @F.%Self (%Self)]() -> @F.%Self (%Self); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) { +// CHECK:STDOUT: %Self => constants.%Self +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/syntactic_merge.carbon b/toolchain/check/testdata/interface/no_prelude/syntactic_merge.carbon new file mode 100644 index 0000000000000..2b74b35a2266a --- /dev/null +++ b/toolchain/check/testdata/interface/no_prelude/syntactic_merge.carbon @@ -0,0 +1,795 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/syntactic_merge.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/syntactic_merge.carbon + +// --- basic.carbon + +library "basic"; + +class C {} +alias D = C; + +interface Foo(a: C); +interface Foo(a: C) {} + +interface Bar(a: D); +interface Bar(a: D) {} + +// --- spacing.carbon + +library "spacing"; + +class C {} + +interface Foo [ ] ( a : C ); +interface Foo[](a: C) {} + +// --- fail_parens.carbon + +library "parens"; + +class C {} + +interface Foo(a: C); +// CHECK:STDERR: fail_parens.carbon:[[@LINE+7]]:18: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: interface Foo(a: (C)) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_parens.carbon:[[@LINE-4]]:18: Comparing with previous declaration here. +// CHECK:STDERR: interface Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +interface Foo(a: (C)) {} + +// --- todo_fail_raw_identifier.carbon + +library "raw_identifier"; + +class C {} + +interface Foo(a: C); +interface Foo(a: r#C) {} + +// --- two_file.carbon + +library "two_file"; + +class C {} +alias D = C; + +interface Foo(a: C); +interface Bar(a: D); + +// --- fail_todo_two_file.impl.carbon + +impl library "two_file"; + +// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope. +// CHECK:STDERR: interface Foo(a: C) {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE-5]]:6: In import. +// CHECK:STDERR: impl library "two_file"; +// CHECK:STDERR: ^~~~~~~ +// CHECK:STDERR: two_file.carbon:7:1: Name is previously declared here. +// CHECK:STDERR: interface Foo(a: C); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +interface Foo(a: C) {} +// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope. +// CHECK:STDERR: interface Bar(a: D) {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE-16]]:6: In import. +// CHECK:STDERR: impl library "two_file"; +// CHECK:STDERR: ^~~~~~~ +// CHECK:STDERR: two_file.carbon:8:1: Name is previously declared here. +// CHECK:STDERR: interface Bar(a: D); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +interface Bar(a: D) {} + +// --- fail_name_mismatch.carbon + +library "name_mismatch"; + +class C {} +alias D = C; + +interface Foo(a: C); +// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE+7]]:15: ERROR: Redeclaration differs at parameter 1. +// CHECK:STDERR: interface Foo(b: D) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_name_mismatch.carbon:[[@LINE-4]]:15: Previous declaration's corresponding parameter here. +// CHECK:STDERR: interface Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +interface Foo(b: D) {} + +// --- fail_alias.carbon + +library "alias"; + +class C {} +alias D = C; + +interface Foo(a: C); +// CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:18: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: interface Foo(a: D) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_alias.carbon:[[@LINE-4]]:18: Comparing with previous declaration here. +// CHECK:STDERR: interface Foo(a: C); +// CHECK:STDERR: ^ +// CHECK:STDERR: +interface Foo(a: D) {} + +// --- fail_deduced_alias.carbon + +library "deduced_alias"; + +class C {} +alias D = C; + +interface Foo[a: C](); +// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE+7]]:18: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: interface Foo[a: D]() {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_deduced_alias.carbon:[[@LINE-4]]:18: Comparing with previous declaration here. +// CHECK:STDERR: interface Foo[a: C](); +// CHECK:STDERR: ^ +// CHECK:STDERR: +interface Foo[a: D]() {} + +// --- alias_two_file.carbon + +library "alias_two_file"; + +class C {} + +interface Foo(a: C); + +// --- fail_alias_two_file.impl.carbon + +impl library "alias_two_file"; + +alias D = C; + +// TODO: This fails because importing interfaces doesn't work well. It should +// fail due to `C` versus `D`, but may succeed if importing interfaces is fixed +// before syntax matching on imports is supported. +// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope. +// CHECK:STDERR: interface Foo(a: D) {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE-10]]:6: In import. +// CHECK:STDERR: impl library "alias_two_file"; +// CHECK:STDERR: ^~~~~~~ +// CHECK:STDERR: alias_two_file.carbon:6:1: Name is previously declared here. +// CHECK:STDERR: interface Foo(a: C); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +interface Foo(a: D) {} + +// --- fail_repeat_const.carbon + +library "repeat_const"; + +class C {} + +interface Foo(a: const C); +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+10]]:18: WARNING: `const` applied repeatedly to the same type has no additional effect. +// CHECK:STDERR: interface Foo(a: const (const C)) {} +// CHECK:STDERR: ^~~~~~~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE+6]]:24: ERROR: Redeclaration syntax differs here. +// CHECK:STDERR: interface Foo(a: const (const C)) {} +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_repeat_const.carbon:[[@LINE-8]]:24: Comparing with previous declaration here. +// CHECK:STDERR: interface Foo(a: const C); +// CHECK:STDERR: ^ +interface Foo(a: const (const C)) {} + +// CHECK:STDOUT: --- basic.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = interface_type @Foo [template] +// CHECK:STDOUT: %Self.1: %.3 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %Bar.type: type = generic_interface_type @Bar [template] +// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @Bar [template] +// CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl.loc7 +// CHECK:STDOUT: .Bar = %Bar.decl.loc10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_15.1: %C = param a +// CHECK:STDOUT: %a.loc7_15.2: %C = bind_name a, %a.loc7_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc8: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc8_15.1: %C = param a +// CHECK:STDOUT: %a.loc8_15.2: %C = bind_name a, %a.loc8_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl.loc10: %Bar.type = interface_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref.loc10: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc10_15.1: %C = param a +// CHECK:STDOUT: %a.loc10_15.2: %C = bind_name a, %a.loc10_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl.loc11: %Bar.type = interface_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref.loc11: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc11_15.1: %C = param a +// CHECK:STDOUT: %a.loc11_15.2: %C = bind_name a, %a.loc11_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo { +// CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Bar { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- spacing.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = interface_type @Foo [template] +// CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl.loc6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_21.1: %C = param a +// CHECK:STDOUT: %a.loc6_21.2: %C = bind_name a, %a.loc6_21.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_17.1: %C = param a +// CHECK:STDOUT: %a.loc7_17.2: %C = bind_name a, %a.loc7_17.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo { +// CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_parens.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_15.1: %C = param a +// CHECK:STDOUT: %a.loc6_15.2: %C = bind_name a, %a.loc6_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = interface_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %C.ref.loc14: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc14_15.1: %C = param a +// CHECK:STDOUT: %a.loc14_15.2: %C = bind_name a, %a.loc14_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- todo_fail_raw_identifier.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = interface_type @Foo [template] +// CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl.loc6 +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl.loc6: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_15.1: %C = param a +// CHECK:STDOUT: %a.loc6_15.2: %C = bind_name a, %a.loc6_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Foo.decl.loc7: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_15.1: %C = param a +// CHECK:STDOUT: %a.loc7_15.2: %C = bind_name a, %a.loc7_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo { +// CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- two_file.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %Bar.type: type = generic_interface_type @Bar [template] +// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: .Bar = %Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_15.1: %C = param a +// CHECK:STDOUT: %a.loc7_15.2: %C = bind_name a, %a.loc7_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Bar.decl: %Bar.type = interface_decl @Bar [template = constants.%Bar] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc8_15.1: %C = param a +// CHECK:STDOUT: %a.loc8_15.2: %C = bind_name a, %a.loc8_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Bar; +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_two_file.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type.1: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.3: %.type.1 = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self.1: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: %Bar.type: type = generic_interface_type @Bar [template] +// CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] +// CHECK:STDOUT: %.type.2: type = generic_interface_type @.2 [template] +// CHECK:STDOUT: %.5: %.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: type = interface_type @.2 [template] +// CHECK:STDOUT: %Self.2: %.6 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//two_file, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//two_file, inst+5, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3: %Foo.type = import_ref Main//two_file, inst+9, loaded [template = constants.%Foo] +// CHECK:STDOUT: %import_ref.4: %Bar.type = import_ref Main//two_file, inst+16, loaded [template = constants.%Bar] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//two_file, inst+2, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = imports.%import_ref.1 +// CHECK:STDOUT: .D = imports.%import_ref.2 +// CHECK:STDOUT: .Foo = imports.%import_ref.3 +// CHECK:STDOUT: .Bar = imports.%import_ref.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc2_6.1 = import +// CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: %.decl.loc14: %.type.1 = interface_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %a.loc14_15.1: %C = param a +// CHECK:STDOUT: %a.loc14_15.2: %C = bind_name a, %a.loc14_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl.loc25: %.type.2 = interface_decl @.2 [template = constants.%.5] { +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.2 [template = constants.%C] +// CHECK:STDOUT: %a.loc25_15.1: %C = param a +// CHECK:STDOUT: %a.loc25_15.2: %C = bind_name a, %a.loc25_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Bar; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.2 { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_name_mismatch.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_15.1: %C = param a +// CHECK:STDOUT: %a.loc7_15.2: %C = bind_name a, %a.loc7_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = interface_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %b.loc15_15.1: %C = param b +// CHECK:STDOUT: %b.loc15_15.2: %C = bind_name b, %b.loc15_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_alias.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_15.1: %C = param a +// CHECK:STDOUT: %a.loc7_15.2: %C = bind_name a, %a.loc7_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = interface_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc15_15.1: %C = param a +// CHECK:STDOUT: %a.loc15_15.2: %C = bind_name a, %a.loc15_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_deduced_alias.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %C.ref.loc5: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C] +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc7_15.1: %C = param a +// CHECK:STDOUT: %a.loc7_15.2: %C = bind_name a, %a.loc7_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = interface_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc15_15.1: %C = param a +// CHECK:STDOUT: %a.loc15_15.2: %C = bind_name a, %a.loc15_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- alias_two_file.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %a.loc6_15.1: %C = param a +// CHECK:STDOUT: %a.loc6_15.2: %C = bind_name a, %a.loc6_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_alias_two_file.impl.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.3: %.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//alias_two_file, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: %Foo.type = import_ref Main//alias_two_file, inst+7, loaded [template = constants.%Foo] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//alias_two_file, inst+2, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = imports.%import_ref.1 +// CHECK:STDOUT: .Foo = imports.%import_ref.2 +// CHECK:STDOUT: .D = %D +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import.loc2_6.1 = import +// CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %D: type = bind_alias D, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %.decl: %.type = interface_decl @.1 [template = constants.%.3] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %a.loc19_15.1: %C = param a +// CHECK:STDOUT: %a.loc19_15.2: %C = bind_name a, %a.loc19_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_repeat_const.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: type = const_type %C [template] +// CHECK:STDOUT: %Foo.type: type = generic_interface_type @Foo [template] +// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] +// CHECK:STDOUT: %.type: type = generic_interface_type @.1 [template] +// CHECK:STDOUT: %.4: %.type = struct_value () [template] +// CHECK:STDOUT: %.5: type = interface_type @.1 [template] +// CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .Foo = %Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} +// CHECK:STDOUT: %Foo.decl: %Foo.type = interface_decl @Foo [template = constants.%Foo] { +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc6: type = const_type %C [template = constants.%.2] +// CHECK:STDOUT: %a.loc6_15.1: %.2 = param a +// CHECK:STDOUT: %a.loc6_15.2: %.2 = bind_name a, %a.loc6_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.decl: %.type = interface_decl @.1 [template = constants.%.4] { +// CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc17_25: type = const_type %C [template = constants.%.2] +// CHECK:STDOUT: %.loc17_18: type = const_type %.2 [template = constants.%.2] +// CHECK:STDOUT: %a.loc17_15.1: %.2 = param a +// CHECK:STDOUT: %a.loc17_15.2: %.2 = bind_name a, %a.loc17_15.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Foo; +// CHECK:STDOUT: +// CHECK:STDOUT: interface @.1 { +// CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 0 [symbolic = constants.%Self] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/todo_define_not_default.carbon b/toolchain/check/testdata/interface/todo_define_not_default.carbon index fb737a742eeef..e179cd7363d5f 100644 --- a/toolchain/check/testdata/interface/todo_define_not_default.carbon +++ b/toolchain/check/testdata/interface/todo_define_not_default.carbon @@ -45,21 +45,25 @@ interface I { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .I = %I.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -110,14 +114,23 @@ interface I { // CHECK:STDOUT: witness = (%F.decl, %G.decl, %T, %N) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -// CHECK:STDOUT: generic [@I.%Self: %.1] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @F(@I.%Self: %.1) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(@I.%a.loc14_8.2: i32, @I.%b.loc14_16.2: i32) -> i32 = "int.sadd" -// CHECK:STDOUT: generic [@I.%Self: %.1]; +// CHECK:STDOUT: generic fn @G(@I.%Self: %.1) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(@I.%a.loc14_8.2: i32, @I.%b.loc14_16.2: i32) -> i32 = "int.sadd"; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G(constants.%Self) {} // CHECK:STDOUT: diff --git a/toolchain/check/testdata/ir/duplicate_name_same_line.carbon b/toolchain/check/testdata/ir/duplicate_name_same_line.carbon index 93cab32071ee5..65711e8bcfdbd 100644 --- a/toolchain/check/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/check/testdata/ir/duplicate_name_same_line.carbon @@ -24,17 +24,25 @@ fn A() { if (true) { var n: i32 = 1; } if (true) { var n: i32 = 2; } } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/convert.carbon b/toolchain/check/testdata/let/convert.carbon index f98c28913a8cc..f0b51e6625c49 100644 --- a/toolchain/check/testdata/let/convert.carbon +++ b/toolchain/check/testdata/let/convert.carbon @@ -12,7 +12,7 @@ fn F() -> i32 { var v: (i32, i32, i32) = (1, 2, 3); // Convert from object representation to value representation. let w: (i32, i32, i32) = v; - return w[1]; + return w.1; } // CHECK:STDOUT: --- convert.carbon @@ -33,22 +33,25 @@ fn F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -110,7 +113,7 @@ fn F() -> i32 { // CHECK:STDOUT: %w: %.3 = bind_name w, %.loc14_29 // CHECK:STDOUT: %w.ref: %.3 = name_ref w, %w // CHECK:STDOUT: %.loc15_12: i32 = int_literal 1 [template = constants.%.5] -// CHECK:STDOUT: %.loc15_13: i32 = tuple_index %w.ref, %.loc15_12 -// CHECK:STDOUT: return %.loc15_13 +// CHECK:STDOUT: %.loc15_11: i32 = tuple_index %w.ref, %.loc15_12 +// CHECK:STDOUT: return %.loc15_11 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_duplicate_decl.carbon b/toolchain/check/testdata/let/fail_duplicate_decl.carbon index b71cd0859714c..013e90aa7906e 100644 --- a/toolchain/check/testdata/let/fail_duplicate_decl.carbon +++ b/toolchain/check/testdata/let/fail_duplicate_decl.carbon @@ -32,17 +32,25 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_generic.carbon b/toolchain/check/testdata/let/fail_generic.carbon index c19f733870127..8f43738e77a48 100644 --- a/toolchain/check/testdata/let/fail_generic.carbon +++ b/toolchain/check/testdata/let/fail_generic.carbon @@ -35,18 +35,25 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc12_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_9.1: type = value_of_initializer %int.make_type_32.loc12_9 [template = i32] diff --git a/toolchain/check/testdata/let/fail_generic_import.carbon b/toolchain/check/testdata/let/fail_generic_import.carbon index f04f74d6c2041..e4a747d068489 100644 --- a/toolchain/check/testdata/let/fail_generic_import.carbon +++ b/toolchain/check/testdata/let/fail_generic_import.carbon @@ -34,16 +34,25 @@ let a: T = 0; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .T = @__global_init.%T // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -65,19 +74,27 @@ let a: T = 0; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+3, loaded [symbolic = constants.%T] +// CHECK:STDOUT: %import_ref: type = import_ref Implicit//default, inst+3, loaded [symbolic = constants.%T] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .T = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = @__global_init.%a // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%import_ref [symbolic = constants.%T] // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_missing_value.carbon b/toolchain/check/testdata/let/fail_missing_value.carbon index 255ad13ec704c..bb7b50b1cfa2e 100644 --- a/toolchain/check/testdata/let/fail_missing_value.carbon +++ b/toolchain/check/testdata/let/fail_missing_value.carbon @@ -32,18 +32,26 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = %n // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32, %.loc15_8.1 [template = i32] diff --git a/toolchain/check/testdata/let/fail_modifiers.carbon b/toolchain/check/testdata/let/fail_modifiers.carbon index fb2b939e29f36..07ea0218ad300 100644 --- a/toolchain/check/testdata/let/fail_modifiers.carbon +++ b/toolchain/check/testdata/let/fail_modifiers.carbon @@ -93,19 +93,22 @@ protected protected let i: i32 = 1; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: .c = @__global_init.%c // CHECK:STDOUT: .d = @__global_init.%d @@ -116,7 +119,6 @@ protected protected let i: i32 = 1; // CHECK:STDOUT: .i = @__global_init.%i // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_18.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] // CHECK:STDOUT: %.loc15_18.2: type = converted %int.make_type_32.loc15, %.loc15_18.1 [template = i32] diff --git a/toolchain/check/testdata/let/fail_use_in_init.carbon b/toolchain/check/testdata/let/fail_use_in_init.carbon index 298f71f56abb6..f45f3fc477549 100644 --- a/toolchain/check/testdata/let/fail_use_in_init.carbon +++ b/toolchain/check/testdata/let/fail_use_in_init.carbon @@ -26,16 +26,25 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/generic.carbon b/toolchain/check/testdata/let/generic.carbon index edfdf973eee2b..36dfcbda5cd81 100644 --- a/toolchain/check/testdata/let/generic.carbon +++ b/toolchain/check/testdata/let/generic.carbon @@ -27,16 +27,25 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/generic_import.carbon b/toolchain/check/testdata/let/generic_import.carbon index 6b98034d49c33..5a4e2ebd285c3 100644 --- a/toolchain/check/testdata/let/generic_import.carbon +++ b/toolchain/check/testdata/let/generic_import.carbon @@ -31,16 +31,25 @@ var b: T = *a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .T = @__global_init.%T // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -62,20 +71,28 @@ var b: T = *a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+3, loaded [symbolic = constants.%T] +// CHECK:STDOUT: %import_ref: type = import_ref Implicit//default, inst+3, loaded [symbolic = constants.%T] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .T = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %T.ref.loc4: type = name_ref T, imports.%import_ref [symbolic = constants.%T] // CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a diff --git a/toolchain/check/testdata/let/global.carbon b/toolchain/check/testdata/let/global.carbon index 2cdf78d783af1..38b3afd829655 100644 --- a/toolchain/check/testdata/let/global.carbon +++ b/toolchain/check/testdata/let/global.carbon @@ -24,18 +24,26 @@ fn F() -> i32 { return n; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = @__global_init.%n // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_8.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] // CHECK:STDOUT: %.loc11_8.2: type = converted %int.make_type_32.loc11, %.loc11_8.1 [template = i32] diff --git a/toolchain/check/testdata/let/local.carbon b/toolchain/check/testdata/let/local.carbon index 828ac15e6c26e..ea76df0c152e3 100644 --- a/toolchain/check/testdata/let/local.carbon +++ b/toolchain/check/testdata/let/local.carbon @@ -24,18 +24,25 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32] diff --git a/toolchain/check/testdata/let/no_prelude/import.carbon b/toolchain/check/testdata/let/no_prelude/import.carbon index b725859c07248..20863d0d3499e 100644 --- a/toolchain/check/testdata/let/no_prelude/import.carbon +++ b/toolchain/check/testdata/let/no_prelude/import.carbon @@ -66,7 +66,7 @@ let b:! () = Other.a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %.1 = import_ref ir0, inst+4, loaded [symbolic = constants.%a] +// CHECK:STDOUT: %import_ref: %.1 = import_ref Implicit//default, inst+4, loaded [symbolic = constants.%a] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -121,23 +121,26 @@ let b:! () = Other.a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %.1 = import_ref ir1, inst+4, loaded [symbolic = constants.%a] +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .a = %import_ref +// CHECK:STDOUT: import Other//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %.1 = import_ref Other//default, inst+4, loaded [symbolic = constants.%a] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .b = @__global_init.%b // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: %.loc4_10.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc4_10.2: type = converted %.loc4_10.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Other.ref: = name_ref Other, file.%Other [template = file.%Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %a.ref: %.1 = name_ref a, imports.%import_ref [symbolic = constants.%a] // CHECK:STDOUT: %b: %.1 = bind_symbolic_name b 0, %a.ref [symbolic = constants.%b] // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/let/no_prelude/import_access.carbon b/toolchain/check/testdata/let/no_prelude/import_access.carbon index 746004d7ec7a9..8e20b64e24886 100644 --- a/toolchain/check/testdata/let/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/let/no_prelude/import_access.carbon @@ -82,7 +82,7 @@ let v2: () = Test.v; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %.1 = import_ref ir0, inst+4, loaded +// CHECK:STDOUT: %import_ref: %.1 = import_ref Test//def, inst+4, loaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -131,20 +131,25 @@ let v2: () = Test.v; // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .v2 = @__global_init.%v2 // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %.loc9_10.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc9_10.2: type = converted %.loc9_10.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Test.ref: = name_ref Test, file.%Test [template = file.%Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %v.ref: = name_ref v, [template = ] // CHECK:STDOUT: %v2: %.1 = bind_name v2, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/let/shadowed_decl.carbon b/toolchain/check/testdata/let/shadowed_decl.carbon index 5c14edcf5c539..82d3db9a3105f 100644 --- a/toolchain/check/testdata/let/shadowed_decl.carbon +++ b/toolchain/check/testdata/let/shadowed_decl.carbon @@ -26,18 +26,25 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32.loc11_9 [template = i32] diff --git a/toolchain/check/testdata/namespace/add_to_import.carbon b/toolchain/check/testdata/namespace/add_to_import.carbon index e4eaa86556bac..c38835ce633f1 100644 --- a/toolchain/check/testdata/namespace/add_to_import.carbon +++ b/toolchain/check/testdata/namespace/add_to_import.carbon @@ -24,13 +24,24 @@ var a: i32 = NS.A(); // CHECK:STDOUT: --- implicit.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -46,24 +57,32 @@ var a: i32 = NS.A(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: = import_ref Implicit//default, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .A = file.%A.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .A = %A.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] { // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_14.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] @@ -87,7 +106,7 @@ var a: i32 = NS.A(); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.ref: = name_ref NS, file.%NS [template = file.%NS] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %A.call: init i32 = call %A.ref() // CHECK:STDOUT: assign file.%a.var, %A.call diff --git a/toolchain/check/testdata/namespace/alias.carbon b/toolchain/check/testdata/namespace/alias.carbon index f8615c3c49b1a..11290f4857d71 100644 --- a/toolchain/check/testdata/namespace/alias.carbon +++ b/toolchain/check/testdata/namespace/alias.carbon @@ -36,14 +36,22 @@ fn D() -> i32 { return C(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .ns = %ns // CHECK:STDOUT: .B = %B.decl @@ -51,7 +59,6 @@ fn D() -> i32 { return C(); } // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon b/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon index 18d224537db73..d3f0cf54d3c4b 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon @@ -53,13 +53,24 @@ fn NS(); // CHECK:STDOUT: --- namespace.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -73,19 +84,30 @@ fn NS(); // CHECK:STDOUT: %.3: %.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref: = import_ref Example//namespace, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref, [template] {} +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] {} -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %.loc8: = namespace [template] {} +// CHECK:STDOUT: %NS.loc8: = namespace [template] {} // CHECK:STDOUT: %.decl.loc20: %.type.1 = fn_decl @.1 [template = constants.%.2] {} -// CHECK:STDOUT: %.loc24: = namespace [template] {} +// CHECK:STDOUT: %NS.loc24: = namespace [template] {} // CHECK:STDOUT: %.decl.loc35: %.type.2 = fn_decl @.2 [template = constants.%.3] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon index e2f541031ffcc..39e10134e6bba 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon @@ -35,13 +35,24 @@ fn NS.Foo(); // CHECK:STDOUT: --- namespace.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -55,18 +66,29 @@ fn NS.Foo(); // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref: = import_ref Example//namespace, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { +// CHECK:STDOUT: .Foo = file.%Foo.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .Foo = %Foo.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon index 127c4454b0c67..86f995ae94865 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon @@ -51,13 +51,24 @@ fn NS.Foo(); // CHECK:STDOUT: %NS: %NS.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS.decl: %NS.type = fn_decl @NS [template = constants.%NS] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -74,17 +85,25 @@ fn NS.Foo(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %NS.type = import_ref ir1, inst+3, loaded [template = constants.%NS] +// CHECK:STDOUT: %import_ref: %NS.type = import_ref Example//fn, inst+3, loaded [template = constants.%NS] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .NS = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc16: = namespace [template] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon index fb528676aa4c1..7c8d1dc7eb16a 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon @@ -50,13 +50,24 @@ fn NS.Bar() {} // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } @@ -76,13 +87,24 @@ fn NS.Bar() {} // CHECK:STDOUT: %NS: %NS.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS.decl: %NS.type = fn_decl @NS [template = constants.%NS] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -100,23 +122,31 @@ fn NS.Bar() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+4, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: = import_ref Example//namespace, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .Foo = %import_ref.2 +// CHECK:STDOUT: .Bar = file.%Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Example//namespace, inst+4, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Example//fn, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .Foo = imports.%import_ref.1 -// CHECK:STDOUT: .Bar = %Bar.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon index d13485fafb203..445f1aeff902a 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon @@ -50,13 +50,24 @@ fn NS.Bar() {} // CHECK:STDOUT: %NS: %NS.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS.decl: %NS.type = fn_decl @NS [template = constants.%NS] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -73,13 +84,24 @@ fn NS.Bar() {} // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } @@ -100,23 +122,31 @@ fn NS.Bar() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+4, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Example//fn, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2: = import_ref Example//namespace, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .Foo = %import_ref.3 +// CHECK:STDOUT: .Bar = file.%Bar.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Example//namespace, inst+4, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir2, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .Foo = imports.%import_ref.2 -// CHECK:STDOUT: .Bar = %Bar.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon b/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon index 6528dd81f577e..d44b8fe71284f 100644 --- a/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon +++ b/toolchain/check/testdata/namespace/fail_decl_in_alias.carbon @@ -33,17 +33,26 @@ fn ns.A() -> i32 { return 0; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .ns = %ns // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] {} // CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] // CHECK:STDOUT: %ns: = bind_alias ns, %NS [template = %NS] diff --git a/toolchain/check/testdata/namespace/fail_duplicate.carbon b/toolchain/check/testdata/namespace/fail_duplicate.carbon index 80b78757fc6ca..471c187732e5d 100644 --- a/toolchain/check/testdata/namespace/fail_duplicate.carbon +++ b/toolchain/check/testdata/namespace/fail_duplicate.carbon @@ -30,13 +30,24 @@ fn Foo.Baz() { // CHECK:STDOUT: %Baz: %Baz.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo: = namespace [template] { // CHECK:STDOUT: .Baz = %Baz.decl.loc13 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/fail_modifiers.carbon b/toolchain/check/testdata/namespace/fail_modifiers.carbon index 635b3fe0ff491..d670bc7176b4d 100644 --- a/toolchain/check/testdata/namespace/fail_modifiers.carbon +++ b/toolchain/check/testdata/namespace/fail_modifiers.carbon @@ -56,15 +56,26 @@ extern namespace C; // CHECK:STDOUT: --- fail_modifiers.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .B = %B // CHECK:STDOUT: .C = %C // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A: = namespace [template] {} // CHECK:STDOUT: %B: = namespace [template] {} // CHECK:STDOUT: %C: = namespace [template] {} diff --git a/toolchain/check/testdata/namespace/fail_params.carbon b/toolchain/check/testdata/namespace/fail_params.carbon index 935d57d9290b0..2dd7db7071706 100644 --- a/toolchain/check/testdata/namespace/fail_params.carbon +++ b/toolchain/check/testdata/namespace/fail_params.carbon @@ -52,19 +52,28 @@ fn D(T:! type).F() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .B = %B // CHECK:STDOUT: .C = %C // CHECK:STDOUT: .D = %D // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A: = namespace [template] { // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } @@ -84,7 +93,7 @@ fn D(T:! type).F() {} // CHECK:STDOUT: %D: = namespace [template] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc39_6.1: type = param T -// CHECK:STDOUT: %T.loc39_6.2: type = bind_symbolic_name T 0, %T.loc39_6.1 [symbolic = %T.loc39_6.2 (constants.%T)] +// CHECK:STDOUT: %T.loc39_6.2: type = bind_symbolic_name T 0, %T.loc39_6.1 [symbolic = @.1.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -95,9 +104,18 @@ fn D(T:! type).F() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1() -// CHECK:STDOUT: generic [file.%T.loc39_6.2: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @.1(file.%T.loc39_6.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @.1(constants.%T) { +// CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_unresolved_scope.carbon b/toolchain/check/testdata/namespace/fail_unresolved_scope.carbon index 54c11762c1f15..31e8594778d3b 100644 --- a/toolchain/check/testdata/namespace/fail_unresolved_scope.carbon +++ b/toolchain/check/testdata/namespace/fail_unresolved_scope.carbon @@ -22,12 +22,23 @@ fn Foo.Baz() { // CHECK:STDOUT: %.2: %.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/function.carbon b/toolchain/check/testdata/namespace/function.carbon index 4a8feb6d99741..52f7f705e01ea 100644 --- a/toolchain/check/testdata/namespace/function.carbon +++ b/toolchain/check/testdata/namespace/function.carbon @@ -33,15 +33,26 @@ fn Bar() { // CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: .Baz = %Baz.decl.loc14 // CHECK:STDOUT: .Bar = %Bar.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo: = namespace [template] { // CHECK:STDOUT: .Baz = %Baz.decl.loc17 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/imported.carbon b/toolchain/check/testdata/namespace/imported.carbon index 44ef86ffc1813..60b039729ea14 100644 --- a/toolchain/check/testdata/namespace/imported.carbon +++ b/toolchain/check/testdata/namespace/imported.carbon @@ -38,13 +38,24 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .ChildNS = %ChildNS // CHECK:STDOUT: .A = %A.decl @@ -71,14 +82,32 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir0, inst+5, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir0, inst+9, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref.1: = import_ref Implicit//default, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .A = %import_ref.2 +// CHECK:STDOUT: .ChildNS = %ChildNS +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %A.type = import_ref Implicit//default, inst+5, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.3: = import_ref Implicit//default, inst+4, loaded +// CHECK:STDOUT: %ChildNS: = namespace %import_ref.3, [template] { +// CHECK:STDOUT: .B = %import_ref.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.4: %B.type = import_ref Implicit//default, inst+9, loaded [template = constants.%B] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .package_a = %package_a @@ -87,16 +116,6 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %import_ref.1: = import_ref ir0, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { -// CHECK:STDOUT: .A = imports.%import_ref.1 -// CHECK:STDOUT: .ChildNS = %ChildNS -// CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.2: = import_ref ir0, inst+4, loaded -// CHECK:STDOUT: %ChildNS: = namespace %import_ref.2, [template] { -// CHECK:STDOUT: .B = imports.%import_ref.2 -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -121,24 +140,24 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.ref.loc4: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %A.ref.loc4: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A] +// CHECK:STDOUT: %NS.ref.loc4: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %A.ref.loc4: %A.type = name_ref A, imports.%import_ref.2 [template = constants.%A] // CHECK:STDOUT: %A.call.loc4: init %.1 = call %A.ref.loc4() // CHECK:STDOUT: assign file.%a.var, %A.call.loc4 -// CHECK:STDOUT: %NS.ref.loc5: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %ChildNS.ref.loc5: = name_ref ChildNS, file.%ChildNS [template = file.%ChildNS] -// CHECK:STDOUT: %B.ref.loc5: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B] +// CHECK:STDOUT: %NS.ref.loc5: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %ChildNS.ref.loc5: = name_ref ChildNS, imports.%ChildNS [template = imports.%ChildNS] +// CHECK:STDOUT: %B.ref.loc5: %B.type = name_ref B, imports.%import_ref.4 [template = constants.%B] // CHECK:STDOUT: %B.call.loc5: init %.1 = call %B.ref.loc5() // CHECK:STDOUT: assign file.%b.var, %B.call.loc5 // CHECK:STDOUT: %package.ref.loc7: = name_ref package, package [template = package] -// CHECK:STDOUT: %NS.ref.loc7: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %A.ref.loc7: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A] +// CHECK:STDOUT: %NS.ref.loc7: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %A.ref.loc7: %A.type = name_ref A, imports.%import_ref.2 [template = constants.%A] // CHECK:STDOUT: %A.call.loc7: init %.1 = call %A.ref.loc7() // CHECK:STDOUT: assign file.%package_a.var, %A.call.loc7 // CHECK:STDOUT: %package.ref.loc8: = name_ref package, package [template = package] -// CHECK:STDOUT: %NS.ref.loc8: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %ChildNS.ref.loc8: = name_ref ChildNS, file.%ChildNS [template = file.%ChildNS] -// CHECK:STDOUT: %B.ref.loc8: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B] +// CHECK:STDOUT: %NS.ref.loc8: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %ChildNS.ref.loc8: = name_ref ChildNS, imports.%ChildNS [template = imports.%ChildNS] +// CHECK:STDOUT: %B.ref.loc8: %B.type = name_ref B, imports.%import_ref.4 [template = constants.%B] // CHECK:STDOUT: %B.call.loc8: init %.1 = call %B.ref.loc8() // CHECK:STDOUT: assign file.%package_b.var, %B.call.loc8 // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/imported_indirect.carbon b/toolchain/check/testdata/namespace/imported_indirect.carbon index 8f4de5b98e5d0..b6a6f7b00face 100644 --- a/toolchain/check/testdata/namespace/imported_indirect.carbon +++ b/toolchain/check/testdata/namespace/imported_indirect.carbon @@ -44,51 +44,84 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: --- a.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref: = import_ref Same//a, inst+3, loaded +// CHECK:STDOUT: %A: = namespace %import_ref, [template] { +// CHECK:STDOUT: .B = file.%B +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %A -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .A = imports.%A +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+3, loaded -// CHECK:STDOUT: %A: = namespace %import_ref, [template] { -// CHECK:STDOUT: .B = %B -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- c.carbon // CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %A -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+4, loaded +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: = import_ref Same//b, inst+4, loaded // CHECK:STDOUT: %A: = namespace %import_ref.1, [template] { // CHECK:STDOUT: .B = %B // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+6, loaded +// CHECK:STDOUT: %import_ref.2: = import_ref Same//b, inst+6, loaded // CHECK:STDOUT: %B: = namespace %import_ref.2, [template] { -// CHECK:STDOUT: .C = %C +// CHECK:STDOUT: .C = file.%C +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .A = imports.%A +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %C: = namespace [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -100,26 +133,37 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: %D: %D.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %A -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+4, loaded +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: = import_ref Same//c, inst+4, loaded // CHECK:STDOUT: %A: = namespace %import_ref.1, [template] { // CHECK:STDOUT: .B = %B // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+6, loaded +// CHECK:STDOUT: %import_ref.2: = import_ref Same//c, inst+6, loaded // CHECK:STDOUT: %B: = namespace %import_ref.2, [template] { // CHECK:STDOUT: .C = %C // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+8, loaded +// CHECK:STDOUT: %import_ref.3: = import_ref Same//c, inst+8, loaded // CHECK:STDOUT: %C: = namespace %import_ref.3, [template] { -// CHECK:STDOUT: .D = %D.decl +// CHECK:STDOUT: .D = file.%D.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .A = imports.%A +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -137,30 +181,38 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %D.type = import_ref ir1, inst+10, loaded [template = constants.%D] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %A -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .e = %e -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+4, loaded +// CHECK:STDOUT: %import_ref.1: = import_ref Same//d, inst+4, loaded // CHECK:STDOUT: %A: = namespace %import_ref.1, [template] { // CHECK:STDOUT: .B = %B // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.2: = import_ref ir1, inst+6, loaded +// CHECK:STDOUT: %import_ref.2: = import_ref Same//d, inst+6, loaded // CHECK:STDOUT: %B: = namespace %import_ref.2, [template] { // CHECK:STDOUT: .C = %C // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.3: = import_ref ir1, inst+8, loaded +// CHECK:STDOUT: %import_ref.3: = import_ref Same//d, inst+8, loaded // CHECK:STDOUT: %C: = namespace %import_ref.3, [template] { -// CHECK:STDOUT: .D = imports.%import_ref +// CHECK:STDOUT: .D = %import_ref.4 // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} +// CHECK:STDOUT: %import_ref.4: %D.type = import_ref Same//d, inst+10, loaded [template = constants.%D] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .A = imports.%A +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .e = %e +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %.loc5_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc5_9.2: type = converted %.loc5_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %e.var: ref %.1 = var e @@ -171,10 +223,10 @@ var e: () = A.B.C.D(); // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %A.ref: = name_ref A, file.%A [template = file.%A] -// CHECK:STDOUT: %B.ref: = name_ref B, file.%B [template = file.%B] -// CHECK:STDOUT: %C.ref: = name_ref C, file.%C [template = file.%C] -// CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref [template = constants.%D] +// CHECK:STDOUT: %A.ref: = name_ref A, imports.%A [template = imports.%A] +// CHECK:STDOUT: %B.ref: = name_ref B, imports.%B [template = imports.%B] +// CHECK:STDOUT: %C.ref: = name_ref C, imports.%C [template = imports.%C] +// CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D] // CHECK:STDOUT: %D.call: init %.1 = call %D.ref() // CHECK:STDOUT: assign file.%e.var, %D.call // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/merging.carbon b/toolchain/check/testdata/namespace/merging.carbon index db916ea03510a..fe3c6a7ecfc62 100644 --- a/toolchain/check/testdata/namespace/merging.carbon +++ b/toolchain/check/testdata/namespace/merging.carbon @@ -54,13 +54,24 @@ fn Run() { // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } @@ -82,19 +93,33 @@ fn Run() { // CHECK:STDOUT: %B2: %B2.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .NS = %NS.loc4 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %NS: = namespace [template] { +// CHECK:STDOUT: %NS.loc4: = namespace [template] { // CHECK:STDOUT: .B1 = %B1.decl // CHECK:STDOUT: .B2 = %B2.decl // CHECK:STDOUT: } // CHECK:STDOUT: %B1.decl: %B1.type = fn_decl @B1 [template = constants.%B1] {} -// CHECK:STDOUT: %.loc8: = namespace [template] {} +// CHECK:STDOUT: %NS.loc8: = namespace [template] { +// CHECK:STDOUT: .B1 = %B1.decl +// CHECK:STDOUT: .B2 = %B2.decl +// CHECK:STDOUT: } // CHECK:STDOUT: %B2.decl: %B2.type = fn_decl @B2 [template = constants.%B2] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -125,28 +150,41 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+4, loaded [template = constants.%A] -// CHECK:STDOUT: %import_ref.2: %B1.type = import_ref ir2, inst+4, loaded [template = constants.%B1] -// CHECK:STDOUT: %import_ref.3: %B2.type = import_ref ir2, inst+10, loaded [template = constants.%B2] +// CHECK:STDOUT: %import_ref.1: = import_ref Example//a, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .A = %import_ref.2 +// CHECK:STDOUT: .B1 = %import_ref.3 +// CHECK:STDOUT: .B2 = %import_ref.4 +// CHECK:STDOUT: .C = file.%C.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %A.type = import_ref Example//a, inst+4, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref.3: %B1.type = import_ref Example//b, inst+4, loaded [template = constants.%B1] +// CHECK:STDOUT: %import_ref.4: %B2.type = import_ref Example//b, inst+10, loaded [template = constants.%B2] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .NS = imports.%NS +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .A = imports.%import_ref.1 -// CHECK:STDOUT: .B1 = imports.%import_ref.2 -// CHECK:STDOUT: .B2 = imports.%import_ref.3 +// CHECK:STDOUT: %NS: = namespace [template] { +// CHECK:STDOUT: .A = imports.%import_ref.2 +// CHECK:STDOUT: .B1 = imports.%import_ref.3 +// CHECK:STDOUT: .B2 = imports.%import_ref.4 // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %.loc7: = namespace [template] {} // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } @@ -158,16 +196,16 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A] +// CHECK:STDOUT: %NS.ref.loc12: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.2 [template = constants.%A] // CHECK:STDOUT: %A.call: init %.1 = call %A.ref() -// CHECK:STDOUT: %NS.ref.loc13: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %B1.ref: %B1.type = name_ref B1, imports.%import_ref.2 [template = constants.%B1] +// CHECK:STDOUT: %NS.ref.loc13: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %B1.ref: %B1.type = name_ref B1, imports.%import_ref.3 [template = constants.%B1] // CHECK:STDOUT: %B1.call: init %.1 = call %B1.ref() -// CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, file.%NS [template = file.%NS] -// CHECK:STDOUT: %B2.ref: %B2.type = name_ref B2, imports.%import_ref.3 [template = constants.%B2] +// CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %B2.ref: %B2.type = name_ref B2, imports.%import_ref.4 [template = constants.%B2] // CHECK:STDOUT: %B2.call: init %.1 = call %B2.ref() -// CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, file.%NS [template = file.%NS] +// CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, imports.%NS [template = imports.%NS] // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %C.call: init %.1 = call %C.ref() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/merging_with_indirections.carbon b/toolchain/check/testdata/namespace/merging_with_indirections.carbon new file mode 100644 index 0000000000000..106e7a312e529 --- /dev/null +++ b/toolchain/check/testdata/namespace/merging_with_indirections.carbon @@ -0,0 +1,228 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/namespace/merging_with_indirections.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/merging_with_indirections.carbon + +// --- a.carbon + +package Other library "a"; + +namespace NS1; +class NS1.A {} + +// --- b.carbon + +package Other library "b"; +import library "a"; + +namespace NS1; +class NS1.B {} + +fn F() -> NS1.A { return {}; } + +// --- main.carbon + +import Other library "b"; +import Other library "a"; + +fn Run() { + // Note `Other.NS.A` is part of the return type here. + Other.F(); + + // Use `Other.NS.A` directly. + var a: Other.NS1.A; + + // Ensure the type is equivalent. + a = Other.F(); +} + +// CHECK:STDOUT: --- a.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %A: type = class_type @A [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .NS1 = %NS1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %NS1: = namespace [template] { +// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @A { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%A +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- b.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %B: type = class_type @B [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %A: type = class_type @A [template] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %.2: type = tuple_type () [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %struct: %A = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: = import_ref Other//a, inst+3, loaded +// CHECK:STDOUT: %NS1: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .A = %import_ref.2 +// CHECK:STDOUT: .B = file.%B.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: type = import_ref Other//a, inst+4, loaded [template = constants.%A] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Other//a, inst+5, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .NS1 = imports.%NS1 +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: %NS1: = namespace [template] { +// CHECK:STDOUT: .A = imports.%import_ref.2 +// CHECK:STDOUT: .B = %B.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %NS1.ref: = name_ref NS1, imports.%NS1 [template = imports.%NS1] +// CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.2 [template = constants.%A] +// CHECK:STDOUT: @F.%return: ref %A = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @B { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%B +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @A { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() -> %return: %A { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc8_27.1: %.1 = struct_literal () +// CHECK:STDOUT: %.loc8_27.2: init %A = class_init (), %return [template = constants.%struct] +// CHECK:STDOUT: %.loc8_28: init %A = converted %.loc8_27.1, %.loc8_27.2 [template = constants.%struct] +// CHECK:STDOUT: return %.loc8_28 to %return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- main.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %Run.type: type = fn_type @Run [template] +// CHECK:STDOUT: %.1: type = tuple_type () [template] +// CHECK:STDOUT: %Run: %Run.type = struct_value () [template] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %A: type = class_type @A [template] +// CHECK:STDOUT: %.2: type = struct_type {} [template] +// CHECK:STDOUT: %.3: type = ptr_type %.2 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .F = %import_ref.1 +// CHECK:STDOUT: .NS1 = %NS1 +// CHECK:STDOUT: import Other//b +// CHECK:STDOUT: import Other//a +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %F.type = import_ref Other//b, inst+17, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//b, inst+14, unloaded +// CHECK:STDOUT: %import_ref.3: = import_ref Other//b, inst+4, loaded +// CHECK:STDOUT: %NS1: = namespace %import_ref.3, [template] { +// CHECK:STDOUT: .A = %import_ref.4 +// CHECK:STDOUT: import Other//b +// CHECK:STDOUT: import Other//a +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.4: type = import_ref Other//a, inst+4, loaded [template = constants.%A] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Other = imports.%Other +// CHECK:STDOUT: .Run = %Run.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @A { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @Run() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Other.ref.loc7: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %F.ref.loc7: %F.type = name_ref F, imports.%import_ref.1 [template = constants.%F] +// CHECK:STDOUT: %.loc7_10.1: ref %A = temporary_storage +// CHECK:STDOUT: %F.call.loc7: init %A = call %F.ref.loc7() to %.loc7_10.1 +// CHECK:STDOUT: %.loc7_10.2: ref %A = temporary %.loc7_10.1, %F.call.loc7 +// CHECK:STDOUT: %Other.ref.loc10: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %NS1.ref: = name_ref NS1, imports.%NS1 [template = imports.%NS1] +// CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.4 [template = constants.%A] +// CHECK:STDOUT: %a.var: ref %A = var a +// CHECK:STDOUT: %a: ref %A = bind_name a, %a.var +// CHECK:STDOUT: %a.ref: ref %A = name_ref a, %a +// CHECK:STDOUT: %Other.ref.loc13: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %F.ref.loc13: %F.type = name_ref F, imports.%import_ref.1 [template = constants.%F] +// CHECK:STDOUT: %.loc13: ref %A = splice_block %a.ref {} +// CHECK:STDOUT: %F.call.loc13: init %A = call %F.ref.loc13() to %.loc13 +// CHECK:STDOUT: assign %a.ref, %F.call.loc13 +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() -> %A; +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/nested.carbon b/toolchain/check/testdata/namespace/nested.carbon index 0bbf88ab1d358..4379414804bff 100644 --- a/toolchain/check/testdata/namespace/nested.carbon +++ b/toolchain/check/testdata/namespace/nested.carbon @@ -28,13 +28,24 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: %Baz: %Baz.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo: = namespace [template] { // CHECK:STDOUT: .Bar = %Bar // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/shadow.carbon b/toolchain/check/testdata/namespace/shadow.carbon index 28b3f0cd3a7e1..c740ca0ffa918 100644 --- a/toolchain/check/testdata/namespace/shadow.carbon +++ b/toolchain/check/testdata/namespace/shadow.carbon @@ -44,18 +44,26 @@ fn N.M.B() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl.loc11 // CHECK:STDOUT: .N = %N // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl.loc11: %A.type.1 = fn_decl @A.1 [template = constants.%A.1] {} // CHECK:STDOUT: %N: = namespace [template] { // CHECK:STDOUT: .A = %A.decl.loc14 diff --git a/toolchain/check/testdata/namespace/unqualified_lookup.carbon b/toolchain/check/testdata/namespace/unqualified_lookup.carbon index 4d467fbed0438..5abdc49abbf3c 100644 --- a/toolchain/check/testdata/namespace/unqualified_lookup.carbon +++ b/toolchain/check/testdata/namespace/unqualified_lookup.carbon @@ -48,15 +48,26 @@ fn OuterN.InnerN.CallABC() { // CHECK:STDOUT: %CallABC: %CallABC.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .OuterN = %OuterN // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .CallA = %CallA.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %OuterN: = namespace [template] { // CHECK:STDOUT: .InnerN = %InnerN // CHECK:STDOUT: .B = %B.decl diff --git a/toolchain/check/testdata/operators/builtin/and.carbon b/toolchain/check/testdata/operators/builtin/and.carbon index 6dc23614ef9a7..4e02373e3c852 100644 --- a/toolchain/check/testdata/operators/builtin/and.carbon +++ b/toolchain/check/testdata/operators/builtin/and.carbon @@ -48,20 +48,22 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.5: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .And = %And.decl @@ -69,7 +71,6 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: .PartialConstant = %PartialConstant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type.loc11 [template = bool] diff --git a/toolchain/check/testdata/operators/builtin/assignment.carbon b/toolchain/check/testdata/operators/builtin/assignment.carbon index eff643d3aec5f..cec1e536ff00e 100644 --- a/toolchain/check/testdata/operators/builtin/assignment.carbon +++ b/toolchain/check/testdata/operators/builtin/assignment.carbon @@ -13,8 +13,8 @@ fn Main() { a = 9; var b: (i32, i32) = (1, 2); - b[0] = 3; - b[1] = 4; + b.0 = 3; + b.1 = 4; var c: {.a: i32, .b: i32} = {.a = 1, .b = 2}; c.a = 3; @@ -55,21 +55,25 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -107,14 +111,14 @@ fn Main() { // CHECK:STDOUT: assign %b.var, %.loc15_29 // CHECK:STDOUT: %b.ref.loc16: ref %.5 = name_ref b, %b // CHECK:STDOUT: %.loc16_5: i32 = int_literal 0 [template = constants.%.9] -// CHECK:STDOUT: %.loc16_6: ref i32 = tuple_index %b.ref.loc16, %.loc16_5 -// CHECK:STDOUT: %.loc16_10: i32 = int_literal 3 [template = constants.%.10] -// CHECK:STDOUT: assign %.loc16_6, %.loc16_10 +// CHECK:STDOUT: %.loc16_4: ref i32 = tuple_index %b.ref.loc16, %.loc16_5 +// CHECK:STDOUT: %.loc16_9: i32 = int_literal 3 [template = constants.%.10] +// CHECK:STDOUT: assign %.loc16_4, %.loc16_9 // CHECK:STDOUT: %b.ref.loc17: ref %.5 = name_ref b, %b // CHECK:STDOUT: %.loc17_5: i32 = int_literal 1 [template = constants.%.7] -// CHECK:STDOUT: %.loc17_6: ref i32 = tuple_index %b.ref.loc17, %.loc17_5 -// CHECK:STDOUT: %.loc17_10: i32 = int_literal 4 [template = constants.%.11] -// CHECK:STDOUT: assign %.loc17_6, %.loc17_10 +// CHECK:STDOUT: %.loc17_4: ref i32 = tuple_index %b.ref.loc17, %.loc17_5 +// CHECK:STDOUT: %.loc17_9: i32 = int_literal 4 [template = constants.%.11] +// CHECK:STDOUT: assign %.loc17_4, %.loc17_9 // CHECK:STDOUT: %int.make_type_32.loc19_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc19_15.1: type = value_of_initializer %int.make_type_32.loc19_15 [template = i32] // CHECK:STDOUT: %.loc19_15.2: type = converted %int.make_type_32.loc19_15, %.loc19_15.1 [template = i32] diff --git a/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon b/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon index 479e71b763d75..e7afcb28d6c99 100644 --- a/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon @@ -59,14 +59,26 @@ var or_: F(true or true); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace .inst+1, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: .Float = %import_ref.3 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.3: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: %.loc42_17: bool = block_arg [template = constants.%.3] -// CHECK:STDOUT: %F.call: init type = call (%.loc42_17) +// CHECK:STDOUT: %F.call: init type = call .inst+60.loc42_10(%.loc42_17) // CHECK:STDOUT: %.loc42_24.1: type = value_of_initializer %F.call // CHECK:STDOUT: %.loc42_24.2: type = converted %F.call, %.loc42_24.1 // CHECK:STDOUT: %or_.var: ref = var or_ diff --git a/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon b/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon index ca87c20353497..9c24ebe007a10 100644 --- a/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon @@ -56,18 +56,25 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .PartialConstant = %PartialConstant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %PartialConstant.decl: %PartialConstant.type = fn_decl @PartialConstant [template = constants.%PartialConstant] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc4_23.1: type = value_of_initializer %bool.make_type [template = bool] @@ -152,18 +159,25 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .KnownValueButNonConstantCondition = %KnownValueButNonConstantCondition.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %KnownValueButNonConstantCondition.decl: %KnownValueButNonConstantCondition.type = fn_decl @KnownValueButNonConstantCondition [template = constants.%KnownValueButNonConstantCondition] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc4_41.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/operators/builtin/fail_assignment_to_error.carbon b/toolchain/check/testdata/operators/builtin/fail_assignment_to_error.carbon index 46a89509828df..e6889c0017312 100644 --- a/toolchain/check/testdata/operators/builtin/fail_assignment_to_error.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_assignment_to_error.carbon @@ -29,13 +29,24 @@ fn Main() { // CHECK:STDOUT: %.2: i32 = int_literal 42 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon b/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon index e9e5d854de1f8..19c1b3ce32546 100644 --- a/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon @@ -85,21 +85,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon b/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon index 879dc20f809f6..508edf091ff7b 100644 --- a/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon @@ -38,18 +38,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon index 9e9c87df9c58c..6342c9e9ea2cb 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon @@ -27,16 +27,25 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon index 373f8727fed4c..6cd7f64d87a93 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon @@ -29,16 +29,25 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon index ea00f1d840a80..cfd9f513c320c 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon @@ -40,22 +40,31 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir4, inst+1, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.3 = import_ref ir4, inst+3, unloaded -// CHECK:STDOUT: %import_ref.4: %.5 = import_ref ir4, inst+24, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.5 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.7: type = import_ref ir4, inst+1, loaded [template = constants.%.4] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Add = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/arithmetic, inst+1, loaded [template = constants.%.4] +// CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/arithmetic, inst+3, unloaded +// CHECK:STDOUT: %import_ref.4: %.5 = import_ref Core//prelude/operators/arithmetic, inst+25, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -81,5 +90,9 @@ fn Main() -> i32 { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: generic fn @Op(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon b/toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon index ee8704e668ff9..4656fa1abaccf 100644 --- a/toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon @@ -34,21 +34,31 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir4, inst+1, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.3 = import_ref ir4, inst+3, unloaded -// CHECK:STDOUT: %import_ref.4: %.5 = import_ref ir4, inst+24, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.5 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+19, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Add = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/arithmetic, inst+1, loaded [template = constants.%.4] +// CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/arithmetic, inst+3, unloaded +// CHECK:STDOUT: %import_ref.4: %.5 = import_ref Core//prelude/operators/arithmetic, inst+25, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] @@ -73,5 +83,9 @@ fn Main() -> i32 { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: generic fn @Op(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/or.carbon b/toolchain/check/testdata/operators/builtin/or.carbon index a95b995503777..07a2cf0ce21e7 100644 --- a/toolchain/check/testdata/operators/builtin/or.carbon +++ b/toolchain/check/testdata/operators/builtin/or.carbon @@ -48,20 +48,22 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.5: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .Or = %Or.decl @@ -69,7 +71,6 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: .PartialConstant = %PartialConstant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type.loc11 [template = bool] diff --git a/toolchain/check/testdata/operators/builtin/unary_op.carbon b/toolchain/check/testdata/operators/builtin/unary_op.carbon index 9447fd0562d3d..31c0e56dd3d41 100644 --- a/toolchain/check/testdata/operators/builtin/unary_op.carbon +++ b/toolchain/check/testdata/operators/builtin/unary_op.carbon @@ -36,24 +36,28 @@ fn Constant() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.5: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Not = %Not.decl // CHECK:STDOUT: .not_true = @__global_init.%not_true // CHECK:STDOUT: .not_false = @__global_init.%not_false // CHECK:STDOUT: .Constant = %Constant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Not.decl: %Not.type = fn_decl @Not [template = constants.%Not] { // CHECK:STDOUT: %bool.make_type.loc11_11: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type.loc11_11 [template = bool] diff --git a/toolchain/check/testdata/operators/overloaded/add.carbon b/toolchain/check/testdata/operators/overloaded/add.carbon index f85d9448b2fe3..071b184ab6403 100644 --- a/toolchain/check/testdata/operators/overloaded/add.carbon +++ b/toolchain/check/testdata/operators/overloaded/add.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Add, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @AddAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir4, inst+24, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+19, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+26, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+28, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir4, inst+47, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+43, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+43, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Add = %import_ref.1 +// CHECK:STDOUT: .AddAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/arithmetic, inst+25, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+19, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+27, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+29, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/arithmetic, inst+50, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+44, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+44, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Add.ref: type = name_ref Add, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %AddAssign.ref: type = name_ref AddAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/bit_and.carbon b/toolchain/check/testdata/operators/overloaded/bit_and.carbon index 097de142c1522..22d3a743dc73d 100644 --- a/toolchain/check/testdata/operators/overloaded/bit_and.carbon +++ b/toolchain/check/testdata/operators/overloaded/bit_and.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @BitAnd, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @BitAndAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+21, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+23, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir5, inst+43, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir5, inst+39, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+45, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+47, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir5, inst+66, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir5, inst+62, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir5, inst+21, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir5, inst+39, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir5, inst+45, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir5, inst+62, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .BitAnd = %import_ref.1 +// CHECK:STDOUT: .BitAndAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/bitwise, inst+22, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/bitwise, inst+24, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/bitwise, inst+45, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/bitwise, inst+40, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/bitwise, inst+47, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/bitwise, inst+49, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/bitwise, inst+70, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/bitwise, inst+64, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/bitwise, inst+40, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/bitwise, inst+64, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitAnd.ref: type = name_ref BitAnd, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitAndAssign.ref: type = name_ref BitAndAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/bit_complement.carbon b/toolchain/check/testdata/operators/overloaded/bit_complement.carbon index 0a30f84b2b6bb..97449423a9b1d 100644 --- a/toolchain/check/testdata/operators/overloaded/bit_complement.carbon +++ b/toolchain/check/testdata/operators/overloaded/bit_complement.carbon @@ -42,30 +42,38 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.6: type = assoc_entity_type @BitComplement, %Op.type.2 [template] -// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %.6 = import_ref ir5, inst+19, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir5, inst+14, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+14, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .BitComplement = %import_ref.1 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/bitwise, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/bitwise, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/bitwise, inst+20, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/bitwise, inst+14, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/bitwise, inst+14, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitComplement.ref: type = name_ref BitComplement, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -112,7 +120,11 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: return %.loc19_14 to @impl.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self]() -> %Self; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self]() -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/bit_or.carbon b/toolchain/check/testdata/operators/overloaded/bit_or.carbon index 4e762fdc11fca..df1721eaa301c 100644 --- a/toolchain/check/testdata/operators/overloaded/bit_or.carbon +++ b/toolchain/check/testdata/operators/overloaded/bit_or.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @BitOr, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @BitOrAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+68, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+70, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir5, inst+90, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir5, inst+86, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+92, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+94, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir5, inst+113, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir5, inst+109, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir5, inst+68, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir5, inst+86, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir5, inst+92, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir5, inst+109, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .BitOr = %import_ref.1 +// CHECK:STDOUT: .BitOrAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/bitwise, inst+72, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/bitwise, inst+74, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/bitwise, inst+95, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/bitwise, inst+90, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/bitwise, inst+97, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/bitwise, inst+99, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/bitwise, inst+120, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/bitwise, inst+114, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/bitwise, inst+90, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/bitwise, inst+114, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitOr.ref: type = name_ref BitOr, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitOrAssign.ref: type = name_ref BitOrAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/bit_xor.carbon b/toolchain/check/testdata/operators/overloaded/bit_xor.carbon index fad60815122e4..5dbd773d11337 100644 --- a/toolchain/check/testdata/operators/overloaded/bit_xor.carbon +++ b/toolchain/check/testdata/operators/overloaded/bit_xor.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @BitXor, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @BitXorAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+115, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+117, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir5, inst+137, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir5, inst+133, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+139, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+141, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir5, inst+160, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir5, inst+156, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir5, inst+115, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir5, inst+133, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir5, inst+139, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir5, inst+156, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .BitXor = %import_ref.1 +// CHECK:STDOUT: .BitXorAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/bitwise, inst+122, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/bitwise, inst+124, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/bitwise, inst+145, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/bitwise, inst+140, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/bitwise, inst+147, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/bitwise, inst+149, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/bitwise, inst+170, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/bitwise, inst+164, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/bitwise, inst+140, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/bitwise, inst+164, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitXor.ref: type = name_ref BitXor, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %BitXorAssign.ref: type = name_ref BitXorAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/dec.carbon b/toolchain/check/testdata/operators/overloaded/dec.carbon index 19b5003041616..e76ae309987f7 100644 --- a/toolchain/check/testdata/operators/overloaded/dec.carbon +++ b/toolchain/check/testdata/operators/overloaded/dec.carbon @@ -34,39 +34,47 @@ fn TestOp() { // CHECK:STDOUT: %Op.type.1: type = fn_type @Op.1 [template] // CHECK:STDOUT: %.4: type = tuple_type () [template] // CHECK:STDOUT: %Op.1: %Op.type.1 = struct_value () [template] -// CHECK:STDOUT: %.5: type = ptr_type %Self [symbolic] // CHECK:STDOUT: %Op.type.2: type = fn_type @Op.2 [template] // CHECK:STDOUT: %Op.2: %Op.type.2 = struct_value () [template] +// CHECK:STDOUT: %.5: type = ptr_type %Self [symbolic] // CHECK:STDOUT: %.6: = interface_witness (%Op.1) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.7: type = ptr_type %.1 [template] // CHECK:STDOUT: %struct: %C = struct_value () [template] // CHECK:STDOUT: %.8: type = assoc_entity_type @Dec, %Op.type.2 [template] -// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.6 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+133, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+135, unloaded -// CHECK:STDOUT: %import_ref.3: %.8 = import_ref ir4, inst+149, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+145, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+133, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+145, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Dec = %import_ref.1 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+142, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+144, unloaded +// CHECK:STDOUT: %import_ref.3: %.8 = import_ref Core//prelude/operators/arithmetic, inst+160, loaded [template = constants.%.9] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+154, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+154, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Dec.ref: type = name_ref Dec, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] {} @@ -101,7 +109,12 @@ fn TestOp() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc18_14.3: %.3](); // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[addr %self: %.5](); +// CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.2.%Self (%Self) [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.5](); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp() { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/div.carbon b/toolchain/check/testdata/operators/overloaded/div.carbon index 4923ab5de87c2..4a279f6a22746 100644 --- a/toolchain/check/testdata/operators/overloaded/div.carbon +++ b/toolchain/check/testdata/operators/overloaded/div.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Div, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @DivAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+198, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+200, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir4, inst+220, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+216, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+222, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+224, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir4, inst+243, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+239, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+198, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+216, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+222, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+239, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Div = %import_ref.1 +// CHECK:STDOUT: .DivAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+212, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+214, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/arithmetic, inst+235, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+230, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+237, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+239, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/arithmetic, inst+260, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+254, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+230, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+254, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Div.ref: type = name_ref Div, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %DivAssign.ref: type = name_ref DivAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/eq.carbon b/toolchain/check/testdata/operators/overloaded/eq.carbon index fa6198319d961..288cfc0351724 100644 --- a/toolchain/check/testdata/operators/overloaded/eq.carbon +++ b/toolchain/check/testdata/operators/overloaded/eq.carbon @@ -102,43 +102,48 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [template] // CHECK:STDOUT: %.5: type = ptr_type %.1 [template] // CHECK:STDOUT: %.6: type = assoc_entity_type @Eq, %Equal.type.2 [template] -// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.11 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template] // CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [template] // CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [template] // CHECK:STDOUT: %.8: type = assoc_entity_type @Eq, %NotEqual.type.2 [template] -// CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.14 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.9 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir6, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir6, inst+5, unloaded -// CHECK:STDOUT: %import_ref.3: %.6 = import_ref ir6, inst+30, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.4: %.8 = import_ref ir6, inst+50, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref ir6, inst+26, loaded [template = constants.%Equal.2] -// CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref ir6, inst+46, loaded [template = constants.%NotEqual.2] -// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: type = import_ref ir6, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.11 = import_ref ir6, inst+26, unloaded -// CHECK:STDOUT: %import_ref.12: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.13: type = import_ref ir6, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.14 = import_ref ir6, inst+46, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Eq = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded +// CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+31, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+52, loaded [template = constants.%.9] +// CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+26, loaded [template = constants.%Equal.2] +// CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+47, loaded [template = constants.%NotEqual.2] +// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+26, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+47, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestEqual = %TestEqual.decl // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] { @@ -219,9 +224,17 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc8_15.2: %C](@impl.%other.loc8_24.2: %C) -> bool; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Equal.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Equal.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @NotEqual.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestEqual(%a: %C, %b: %C) -> bool { // CHECK:STDOUT: !entry: @@ -269,32 +282,40 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: %NotEqual.type: type = fn_type @NotEqual [template] // CHECK:STDOUT: %NotEqual: %NotEqual.type = struct_value () [template] // CHECK:STDOUT: %.7: type = assoc_entity_type @Eq, %NotEqual.type [template] -// CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.11 [template] +// CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.9 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir6, inst+3, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.3 = import_ref ir6, inst+5, unloaded -// CHECK:STDOUT: %import_ref.4: %.5 = import_ref ir6, inst+30, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.5: %.7 = import_ref ir6, inst+50, loaded [template = constants.%.8] -// CHECK:STDOUT: %import_ref.6 = import_ref ir6, inst+26, unloaded -// CHECK:STDOUT: %import_ref.7 = import_ref ir6, inst+46, unloaded -// CHECK:STDOUT: %import_ref.8 = import_ref ir6, inst+26, unloaded -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: type = import_ref ir6, inst+3, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.11 = import_ref ir6, inst+46, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Eq = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%.4] +// CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+5, unloaded +// CHECK:STDOUT: %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+31, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+52, loaded [template = constants.%.8] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/comparison, inst+26, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/comparison, inst+47, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+26, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+47, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .TestEqual = %TestEqual.decl // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] { // CHECK:STDOUT: %D.ref.loc6_17: type = name_ref D, %D.decl [template = constants.%D] @@ -344,7 +365,11 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Equal[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Equal(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestNotEqual(%a: %D, %b: %D) -> bool { // CHECK:STDOUT: !entry: @@ -353,7 +378,11 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @NotEqual[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @NotEqual(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_no_impl_for_args.carbon // CHECK:STDOUT: @@ -379,45 +408,50 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: %TestRhsBad: %TestRhsBad.type = struct_value () [template] // CHECK:STDOUT: %.5: type = ptr_type %.1 [template] // CHECK:STDOUT: %.6: type = assoc_entity_type @Eq, %Equal.type.2 [template] -// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.11 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template] // CHECK:STDOUT: %TestLhsBad.type: type = fn_type @TestLhsBad [template] // CHECK:STDOUT: %TestLhsBad: %TestLhsBad.type = struct_value () [template] // CHECK:STDOUT: %.8: type = assoc_entity_type @Eq, %NotEqual.type.2 [template] -// CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.14 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.9 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir6, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir6, inst+5, unloaded -// CHECK:STDOUT: %import_ref.3: %.6 = import_ref ir6, inst+30, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.4: %.8 = import_ref ir6, inst+50, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref ir6, inst+26, loaded [template = constants.%Equal.2] -// CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref ir6, inst+46, loaded [template = constants.%NotEqual.2] -// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.9: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.10: type = import_ref ir6, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.11 = import_ref ir6, inst+26, unloaded -// CHECK:STDOUT: %import_ref.12: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.13: type = import_ref ir6, inst+3, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.14 = import_ref ir6, inst+46, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Eq = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.7 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded +// CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+31, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+52, loaded [template = constants.%.9] +// CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+26, loaded [template = constants.%Equal.2] +// CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+47, loaded [template = constants.%NotEqual.2] +// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+26, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+47, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .TestRhsBad = %TestRhsBad.decl // CHECK:STDOUT: .TestLhsBad = %TestLhsBad.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestRhsBad.decl: %TestRhsBad.type = fn_decl @TestRhsBad [template = constants.%TestRhsBad] { @@ -503,9 +537,17 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc9_15.2: %C](@impl.%other.loc9_24.2: %C) -> bool; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Equal.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Equal.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @NotEqual.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestRhsBad(%a: %C, %b: %D) -> bool { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon b/toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon index 5eb4b09f69b54..97c47cf84af52 100644 --- a/toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon +++ b/toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon @@ -51,62 +51,70 @@ fn TestAddAssignNonRef(a: C, b: C) { // CHECK:STDOUT: %Op.type.1: type = fn_type @Op.1 [template] // CHECK:STDOUT: %.4: type = tuple_type () [template] // CHECK:STDOUT: %Op.1: %Op.type.1 = struct_value () [template] -// CHECK:STDOUT: %.5: type = ptr_type %Self.1 [symbolic] // CHECK:STDOUT: %Op.type.2: type = fn_type @Op.2 [template] // CHECK:STDOUT: %Op.2: %Op.type.2 = struct_value () [template] +// CHECK:STDOUT: %.5: type = ptr_type %Self.1 [symbolic] // CHECK:STDOUT: %.6: = interface_witness (%Op.1) [template] // CHECK:STDOUT: %.7: type = interface_type @AddAssign [template] // CHECK:STDOUT: %Self.2: %.7 = bind_symbolic_name Self 0 [symbolic] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestIncNonRef.type: type = fn_type @TestIncNonRef [template] // CHECK:STDOUT: %TestIncNonRef: %TestIncNonRef.type = struct_value () [template] // CHECK:STDOUT: %.10: type = ptr_type %.1 [template] // CHECK:STDOUT: %.11: type = assoc_entity_type @Inc, %Op.type.2 [template] -// CHECK:STDOUT: %.12: %.11 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.12: %.11 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAddAssignNonRef.type: type = fn_type @TestAddAssignNonRef [template] // CHECK:STDOUT: %TestAddAssignNonRef: %TestAddAssignNonRef.type = struct_value () [template] // CHECK:STDOUT: %.13: type = assoc_entity_type @AddAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.14: %.13 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.14: %.13 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+49, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+51, unloaded -// CHECK:STDOUT: %import_ref.3: %.11 = import_ref ir4, inst+65, loaded [template = constants.%.12] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+61, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+26, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+28, unloaded -// CHECK:STDOUT: %import_ref.7: %.13 = import_ref ir4, inst+47, loaded [template = constants.%.14] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+43, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+49, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+61, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+43, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Inc = %import_ref.1 +// CHECK:STDOUT: .AddAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+52, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+54, unloaded +// CHECK:STDOUT: %import_ref.3: %.11 = import_ref Core//prelude/operators/arithmetic, inst+70, loaded [template = constants.%.12] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+64, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+27, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+29, unloaded +// CHECK:STDOUT: %import_ref.7: %.13 = import_ref Core//prelude/operators/arithmetic, inst+50, loaded [template = constants.%.14] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+44, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+64, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+44, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestIncNonRef = %TestIncNonRef.decl // CHECK:STDOUT: .TestAddAssignNonRef = %TestAddAssignNonRef.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc15: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc15: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc15: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Inc.ref: type = name_ref Inc, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc18: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc18: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %AddAssign.ref: type = name_ref AddAssign, imports.%import_ref.5 [template = constants.%.7] // CHECK:STDOUT: } // CHECK:STDOUT: %TestIncNonRef.decl: %TestIncNonRef.type = fn_decl @TestIncNonRef [template = constants.%TestIncNonRef] { @@ -178,11 +186,21 @@ fn TestAddAssignNonRef(a: C, b: C) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.1[addr @impl.1.%self.loc16_14.3: %.3](); // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[addr %self: %.5](); +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.2.%Self (%Self.1) [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.5](); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: %.3](@impl.2.%other.loc19_24.2: %C); // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.7) { +// CHECK:STDOUT: %Self: %.7 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestIncNonRef(%a: %C) { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon b/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon index 4ad2a82fe2b65..a1db9fe4b42a0 100644 --- a/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon +++ b/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon @@ -69,53 +69,65 @@ fn TestRef(b: C) { // CHECK:STDOUT: %struct: %C = struct_value () [template] // CHECK:STDOUT: %.10: type = interface_type @AddAssign [template] // CHECK:STDOUT: %Self.3: %.10 = bind_symbolic_name Self 0 [symbolic] -// CHECK:STDOUT: %.11: type = ptr_type %Self.3 [symbolic] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] +// CHECK:STDOUT: %.11: type = ptr_type %Self.3 [symbolic] // CHECK:STDOUT: %.12: type = assoc_entity_type @AddAssign, %Op.type.3 [template] // CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.15 [template] // CHECK:STDOUT: %.14: type = interface_type @Inc [template] // CHECK:STDOUT: %Self.4: %.14 = bind_symbolic_name Self 0 [symbolic] -// CHECK:STDOUT: %.15: type = ptr_type %Self.4 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.15: type = ptr_type %Self.4 [symbolic] // CHECK:STDOUT: %.16: type = assoc_entity_type @Inc, %Op.type.4 [template] // CHECK:STDOUT: %.17: %.16 = assoc_entity element0, imports.%import_ref.20 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+67, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+69, unloaded -// CHECK:STDOUT: %import_ref.3: %.5 = import_ref ir4, inst+84, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.4 = import_ref ir4, inst+80, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir4, inst+80, unloaded -// CHECK:STDOUT: %import_ref.6: type = import_ref ir4, inst+1, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.7 = import_ref ir4, inst+3, unloaded -// CHECK:STDOUT: %import_ref.8: %.8 = import_ref ir4, inst+24, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.9 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.10] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+28, unloaded -// CHECK:STDOUT: %import_ref.13: %.12 = import_ref ir4, inst+47, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.14 = import_ref ir4, inst+43, unloaded -// CHECK:STDOUT: %import_ref.15 = import_ref ir4, inst+43, unloaded -// CHECK:STDOUT: %import_ref.16: type = import_ref ir4, inst+49, loaded [template = constants.%.14] -// CHECK:STDOUT: %import_ref.17 = import_ref ir4, inst+51, unloaded -// CHECK:STDOUT: %import_ref.18: %.16 = import_ref ir4, inst+65, loaded [template = constants.%.17] -// CHECK:STDOUT: %import_ref.19 = import_ref ir4, inst+61, unloaded -// CHECK:STDOUT: %import_ref.20 = import_ref ir4, inst+61, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Negate = %import_ref.1 +// CHECK:STDOUT: .Add = %import_ref.6 +// CHECK:STDOUT: .AddAssign = %import_ref.11 +// CHECK:STDOUT: .Inc = %import_ref.16 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+72, loaded [template = constants.%.4] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+74, unloaded +// CHECK:STDOUT: %import_ref.3: %.5 = import_ref Core//prelude/operators/arithmetic, inst+90, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/arithmetic, inst+85, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+85, unloaded +// CHECK:STDOUT: %import_ref.6: type = import_ref Core//prelude/operators/arithmetic, inst+1, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/arithmetic, inst+3, unloaded +// CHECK:STDOUT: %import_ref.8: %.8 = import_ref Core//prelude/operators/arithmetic, inst+25, loaded [template = constants.%.9] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded +// CHECK:STDOUT: %import_ref.11: type = import_ref Core//prelude/operators/arithmetic, inst+27, loaded [template = constants.%.10] +// CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/arithmetic, inst+29, unloaded +// CHECK:STDOUT: %import_ref.13: %.12 = import_ref Core//prelude/operators/arithmetic, inst+50, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.14 = import_ref Core//prelude/operators/arithmetic, inst+44, unloaded +// CHECK:STDOUT: %import_ref.15 = import_ref Core//prelude/operators/arithmetic, inst+44, unloaded +// CHECK:STDOUT: %import_ref.16: type = import_ref Core//prelude/operators/arithmetic, inst+52, loaded [template = constants.%.14] +// CHECK:STDOUT: %import_ref.17 = import_ref Core//prelude/operators/arithmetic, inst+54, unloaded +// CHECK:STDOUT: %import_ref.18: %.16 = import_ref Core//prelude/operators/arithmetic, inst+70, loaded [template = constants.%.17] +// CHECK:STDOUT: %import_ref.19 = import_ref Core//prelude/operators/arithmetic, inst+64, unloaded +// CHECK:STDOUT: %import_ref.20 = import_ref Core//prelude/operators/arithmetic, inst+64, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestUnary = %TestUnary.decl // CHECK:STDOUT: .TestBinary = %TestBinary.decl // CHECK:STDOUT: .TestRef = %TestRef.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %TestUnary.decl: %TestUnary.type = fn_decl @TestUnary [template = constants.%TestUnary] { // CHECK:STDOUT: %C.ref.loc15_17: type = name_ref C, %C.decl [template = constants.%C] @@ -180,7 +192,11 @@ fn TestRef(b: C) { // CHECK:STDOUT: return to %return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.1[%self: %Self.1]() -> %Self.1; +// CHECK:STDOUT: generic fn @Op.1(constants.%Self.1: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1]() -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestBinary(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: @@ -189,7 +205,11 @@ fn TestRef(b: C) { // CHECK:STDOUT: return to %return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.2](%other: %Self.2) -> %Self.2; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.2: %.7) { +// CHECK:STDOUT: %Self: %.7 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.2](%other: %Self.2) -> %Self.2; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestRef(%b: %C) { // CHECK:STDOUT: !entry: @@ -206,7 +226,17 @@ fn TestRef(b: C) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.3[addr %self: %.11](%other: %Self.3); +// CHECK:STDOUT: generic fn @Op.3(constants.%Self.3: %.10) { +// CHECK:STDOUT: %Self: %.10 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.3)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.3.%Self (%Self.3) [symbolic = %.2 (constants.%.11)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.11](%other: %Self.3); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.4: %.14) { +// CHECK:STDOUT: %Self: %.14 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.4)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.4) [symbolic = %.2 (constants.%.15)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.15](); +// CHECK:STDOUT: fn[addr %self: %.15](); +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon b/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon index 8e38749f83c4b..0c406ca515efb 100644 --- a/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon +++ b/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon @@ -61,57 +61,65 @@ fn TestAssign(b: D) { // CHECK:STDOUT: %.6: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.7: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.7: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.8: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %Test.type: type = fn_type @Test [template] // CHECK:STDOUT: %Test: %Test.type = struct_value () [template] // CHECK:STDOUT: %.9: type = ptr_type %.1 [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Add, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %struct: %C = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @AddAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir4, inst+24, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+19, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+26, loaded [template = constants.%.5] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+28, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir4, inst+47, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+43, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+1, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+19, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.5] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+43, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Add = %import_ref.1 +// CHECK:STDOUT: .AddAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+1, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/arithmetic, inst+25, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+19, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+27, loaded [template = constants.%.5] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+29, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/arithmetic, inst+50, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+44, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+19, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+44, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .Test = %Test.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc16: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc16: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc16: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Add.ref: type = name_ref Add, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc19: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc19: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc19: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %AddAssign.ref: type = name_ref AddAssign, imports.%import_ref.5 [template = constants.%.5] // CHECK:STDOUT: } // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [template = constants.%Test] { @@ -193,11 +201,20 @@ fn TestAssign(b: D) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc17_9.2: %C](@impl.1.%other.loc17_18.2: %C) -> %C; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc20_14.3: %.6](@impl.2.%other.loc20_24.2: %C); // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.7](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.5) { +// CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.7)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.7](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Test(%a: %C, %b: %D) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/inc.carbon b/toolchain/check/testdata/operators/overloaded/inc.carbon index 5c7db3272a5db..95ac2945ccb5d 100644 --- a/toolchain/check/testdata/operators/overloaded/inc.carbon +++ b/toolchain/check/testdata/operators/overloaded/inc.carbon @@ -34,39 +34,47 @@ fn TestOp() { // CHECK:STDOUT: %Op.type.1: type = fn_type @Op.1 [template] // CHECK:STDOUT: %.4: type = tuple_type () [template] // CHECK:STDOUT: %Op.1: %Op.type.1 = struct_value () [template] -// CHECK:STDOUT: %.5: type = ptr_type %Self [symbolic] // CHECK:STDOUT: %Op.type.2: type = fn_type @Op.2 [template] // CHECK:STDOUT: %Op.2: %Op.type.2 = struct_value () [template] +// CHECK:STDOUT: %.5: type = ptr_type %Self [symbolic] // CHECK:STDOUT: %.6: = interface_witness (%Op.1) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.7: type = ptr_type %.1 [template] // CHECK:STDOUT: %struct: %C = struct_value () [template] // CHECK:STDOUT: %.8: type = assoc_entity_type @Inc, %Op.type.2 [template] -// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.6 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+49, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+51, unloaded -// CHECK:STDOUT: %import_ref.3: %.8 = import_ref ir4, inst+65, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+61, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+49, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+61, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Inc = %import_ref.1 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+52, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+54, unloaded +// CHECK:STDOUT: %import_ref.3: %.8 = import_ref Core//prelude/operators/arithmetic, inst+70, loaded [template = constants.%.9] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+64, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+64, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Inc.ref: type = name_ref Inc, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] {} @@ -101,7 +109,12 @@ fn TestOp() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc18_14.3: %.3](); // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[addr %self: %.5](); +// CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.2.%Self (%Self) [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.5](); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp() { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/left_shift.carbon b/toolchain/check/testdata/operators/overloaded/left_shift.carbon index 019c29a49f60c..dcc1eabec122f 100644 --- a/toolchain/check/testdata/operators/overloaded/left_shift.carbon +++ b/toolchain/check/testdata/operators/overloaded/left_shift.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @LeftShift, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @LeftShiftAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+162, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+164, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir5, inst+184, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir5, inst+180, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+186, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+188, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir5, inst+207, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir5, inst+203, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir5, inst+162, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir5, inst+180, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir5, inst+186, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir5, inst+203, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .LeftShift = %import_ref.1 +// CHECK:STDOUT: .LeftShiftAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/bitwise, inst+172, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/bitwise, inst+174, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/bitwise, inst+195, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/bitwise, inst+190, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/bitwise, inst+197, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/bitwise, inst+199, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/bitwise, inst+220, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/bitwise, inst+214, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/bitwise, inst+190, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/bitwise, inst+214, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %LeftShift.ref: type = name_ref LeftShift, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %LeftShiftAssign.ref: type = name_ref LeftShiftAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/mod.carbon b/toolchain/check/testdata/operators/overloaded/mod.carbon index f6922c6c2da50..a61037c553a22 100644 --- a/toolchain/check/testdata/operators/overloaded/mod.carbon +++ b/toolchain/check/testdata/operators/overloaded/mod.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Mod, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @ModAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+245, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+247, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir4, inst+267, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+263, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+269, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+271, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir4, inst+290, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+286, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+245, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+263, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+269, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+286, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Mod = %import_ref.1 +// CHECK:STDOUT: .ModAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+262, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+264, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/arithmetic, inst+285, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+280, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+287, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+289, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/arithmetic, inst+310, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+304, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+280, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+304, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Mod.ref: type = name_ref Mod, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %ModAssign.ref: type = name_ref ModAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/mul.carbon b/toolchain/check/testdata/operators/overloaded/mul.carbon index 86ad023d1d43f..2445bb3d8e55a 100644 --- a/toolchain/check/testdata/operators/overloaded/mul.carbon +++ b/toolchain/check/testdata/operators/overloaded/mul.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Mul, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @MulAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+151, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+153, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir4, inst+173, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+169, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+175, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+177, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir4, inst+196, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+192, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+151, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+169, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+175, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+192, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Mul = %import_ref.1 +// CHECK:STDOUT: .MulAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+162, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+164, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/arithmetic, inst+185, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+180, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+187, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+189, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/arithmetic, inst+210, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+204, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+180, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+204, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Mul.ref: type = name_ref Mul, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %MulAssign.ref: type = name_ref MulAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/negate.carbon b/toolchain/check/testdata/operators/overloaded/negate.carbon index 547d651a919d1..846bf2a1ad18e 100644 --- a/toolchain/check/testdata/operators/overloaded/negate.carbon +++ b/toolchain/check/testdata/operators/overloaded/negate.carbon @@ -42,30 +42,38 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.6: type = assoc_entity_type @Negate, %Op.type.2 [template] -// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+67, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+69, unloaded -// CHECK:STDOUT: %import_ref.3: %.6 = import_ref ir4, inst+84, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+80, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+67, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+80, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Negate = %import_ref.1 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+72, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+74, unloaded +// CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/arithmetic, inst+90, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+85, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+85, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Negate.ref: type = name_ref Negate, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -112,7 +120,11 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: return %.loc19_14 to @impl.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self]() -> %Self; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self]() -> %Self; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/ordered.carbon b/toolchain/check/testdata/operators/overloaded/ordered.carbon index 790ce59748a82..af1d4a6ae8399 100644 --- a/toolchain/check/testdata/operators/overloaded/ordered.carbon +++ b/toolchain/check/testdata/operators/overloaded/ordered.carbon @@ -105,53 +105,53 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: %TestLess: %TestLess.type = struct_value () [template] // CHECK:STDOUT: %.5: type = ptr_type %.1 [template] // CHECK:STDOUT: %.6: type = assoc_entity_type @Ordered, %Less.type.2 [template] -// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.17 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.12 [template] // CHECK:STDOUT: %TestLessEqual.type: type = fn_type @TestLessEqual [template] // CHECK:STDOUT: %TestLessEqual: %TestLessEqual.type = struct_value () [template] // CHECK:STDOUT: %.8: type = assoc_entity_type @Ordered, %LessOrEquivalent.type.2 [template] -// CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.20 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.13 [template] // CHECK:STDOUT: %TestGreater.type: type = fn_type @TestGreater [template] // CHECK:STDOUT: %TestGreater: %TestGreater.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Ordered, %Greater.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element2, imports.%import_ref.23 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element2, imports.%import_ref.14 [template] // CHECK:STDOUT: %TestGreaterEqual.type: type = fn_type @TestGreaterEqual [template] // CHECK:STDOUT: %TestGreaterEqual: %TestGreaterEqual.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @Ordered, %GreaterOrEquivalent.type.2 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element3, imports.%import_ref.26 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element3, imports.%import_ref.15 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir6, inst+52, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir6, inst+54, unloaded -// CHECK:STDOUT: %import_ref.3: %.6 = import_ref ir6, inst+74, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.4: %.8 = import_ref ir6, inst+94, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.5: %.10 = import_ref ir6, inst+114, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.6: %.12 = import_ref ir6, inst+134, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.7: %Less.type.2 = import_ref ir6, inst+70, loaded [template = constants.%Less.2] -// CHECK:STDOUT: %import_ref.8: %LessOrEquivalent.type.2 = import_ref ir6, inst+90, loaded [template = constants.%LessOrEquivalent.2] -// CHECK:STDOUT: %import_ref.9: %Greater.type.2 = import_ref ir6, inst+110, loaded [template = constants.%Greater.2] -// CHECK:STDOUT: %import_ref.10: %GreaterOrEquivalent.type.2 = import_ref ir6, inst+130, loaded [template = constants.%GreaterOrEquivalent.2] -// CHECK:STDOUT: %import_ref.11: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.12: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.13: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.14: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.15: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.16: type = import_ref ir6, inst+52, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.17 = import_ref ir6, inst+70, unloaded -// CHECK:STDOUT: %import_ref.18: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.19: type = import_ref ir6, inst+52, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.20 = import_ref ir6, inst+90, unloaded -// CHECK:STDOUT: %import_ref.21: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.22: type = import_ref ir6, inst+52, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.23 = import_ref ir6, inst+110, unloaded -// CHECK:STDOUT: %import_ref.24: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.25: type = import_ref ir6, inst+52, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.26 = import_ref ir6, inst+130, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Ordered = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.11 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+54, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+56, unloaded +// CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+77, loaded [template = constants.%.7] +// CHECK:STDOUT: %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+98, loaded [template = constants.%.9] +// CHECK:STDOUT: %import_ref.5: %.10 = import_ref Core//prelude/operators/comparison, inst+119, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.6: %.12 = import_ref Core//prelude/operators/comparison, inst+140, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.7: %Less.type.2 = import_ref Core//prelude/operators/comparison, inst+72, loaded [template = constants.%Less.2] +// CHECK:STDOUT: %import_ref.8: %LessOrEquivalent.type.2 = import_ref Core//prelude/operators/comparison, inst+93, loaded [template = constants.%LessOrEquivalent.2] +// CHECK:STDOUT: %import_ref.9: %Greater.type.2 = import_ref Core//prelude/operators/comparison, inst+114, loaded [template = constants.%Greater.2] +// CHECK:STDOUT: %import_ref.10: %GreaterOrEquivalent.type.2 = import_ref Core//prelude/operators/comparison, inst+135, loaded [template = constants.%GreaterOrEquivalent.2] +// CHECK:STDOUT: %import_ref.11: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/comparison, inst+72, unloaded +// CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/comparison, inst+93, unloaded +// CHECK:STDOUT: %import_ref.14 = import_ref Core//prelude/operators/comparison, inst+114, unloaded +// CHECK:STDOUT: %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+135, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestLess = %TestLess.decl // CHECK:STDOUT: .TestLessEqual = %TestLessEqual.decl @@ -159,11 +159,10 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: .TestGreaterEqual = %TestGreaterEqual.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl { // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Ordered.ref: type = name_ref Ordered, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: %TestLess.decl: %TestLess.type = fn_decl @TestLess [template = constants.%TestLess] { @@ -300,13 +299,29 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @GreaterOrEquivalent.1[@impl.%self.loc10_26.2: %C](@impl.%other.loc10_35.2: %C) -> bool; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Less.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Less.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @LessOrEquivalent.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @LessOrEquivalent.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Greater.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Greater.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: -// CHECK:STDOUT: fn @GreaterOrEquivalent.2[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @GreaterOrEquivalent.2(constants.%Self: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestLess(%a: %C, %b: %C) -> bool { // CHECK:STDOUT: !entry: @@ -378,48 +393,53 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: %LessOrEquivalent.type: type = fn_type @LessOrEquivalent [template] // CHECK:STDOUT: %LessOrEquivalent: %LessOrEquivalent.type = struct_value () [template] // CHECK:STDOUT: %.7: type = assoc_entity_type @Ordered, %LessOrEquivalent.type [template] -// CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.15 [template] +// CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.13 [template] // CHECK:STDOUT: %TestGreater.type: type = fn_type @TestGreater [template] // CHECK:STDOUT: %TestGreater: %TestGreater.type = struct_value () [template] // CHECK:STDOUT: %Greater.type: type = fn_type @Greater [template] // CHECK:STDOUT: %Greater: %Greater.type = struct_value () [template] // CHECK:STDOUT: %.9: type = assoc_entity_type @Ordered, %Greater.type [template] -// CHECK:STDOUT: %.10: %.9 = assoc_entity element2, imports.%import_ref.18 [template] +// CHECK:STDOUT: %.10: %.9 = assoc_entity element2, imports.%import_ref.14 [template] // CHECK:STDOUT: %TestGreaterEqual.type: type = fn_type @TestGreaterEqual [template] // CHECK:STDOUT: %TestGreaterEqual: %TestGreaterEqual.type = struct_value () [template] // CHECK:STDOUT: %GreaterOrEquivalent.type: type = fn_type @GreaterOrEquivalent [template] // CHECK:STDOUT: %GreaterOrEquivalent: %GreaterOrEquivalent.type = struct_value () [template] // CHECK:STDOUT: %.11: type = assoc_entity_type @Ordered, %GreaterOrEquivalent.type [template] -// CHECK:STDOUT: %.12: %.11 = assoc_entity element3, imports.%import_ref.21 [template] +// CHECK:STDOUT: %.12: %.11 = assoc_entity element3, imports.%import_ref.15 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir6, inst+52, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.3 = import_ref ir6, inst+54, unloaded -// CHECK:STDOUT: %import_ref.4: %.5 = import_ref ir6, inst+74, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.5: %.7 = import_ref ir6, inst+94, loaded [template = constants.%.8] -// CHECK:STDOUT: %import_ref.6: %.9 = import_ref ir6, inst+114, loaded [template = constants.%.10] -// CHECK:STDOUT: %import_ref.7: %.11 = import_ref ir6, inst+134, loaded [template = constants.%.12] -// CHECK:STDOUT: %import_ref.8 = import_ref ir6, inst+70, unloaded -// CHECK:STDOUT: %import_ref.9 = import_ref ir6, inst+90, unloaded -// CHECK:STDOUT: %import_ref.10 = import_ref ir6, inst+110, unloaded -// CHECK:STDOUT: %import_ref.11 = import_ref ir6, inst+130, unloaded -// CHECK:STDOUT: %import_ref.12 = import_ref ir6, inst+70, unloaded -// CHECK:STDOUT: %import_ref.13: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.14: type = import_ref ir6, inst+52, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.15 = import_ref ir6, inst+90, unloaded -// CHECK:STDOUT: %import_ref.16: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.17: type = import_ref ir6, inst+52, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.18 = import_ref ir6, inst+110, unloaded -// CHECK:STDOUT: %import_ref.19: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.20: type = import_ref ir6, inst+52, loaded [template = constants.%.4] -// CHECK:STDOUT: %import_ref.21 = import_ref ir6, inst+130, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Ordered = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+54, loaded [template = constants.%.4] +// CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+56, unloaded +// CHECK:STDOUT: %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+77, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+98, loaded [template = constants.%.8] +// CHECK:STDOUT: %import_ref.6: %.9 = import_ref Core//prelude/operators/comparison, inst+119, loaded [template = constants.%.10] +// CHECK:STDOUT: %import_ref.7: %.11 = import_ref Core//prelude/operators/comparison, inst+140, loaded [template = constants.%.12] +// CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+72, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+93, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/comparison, inst+114, unloaded +// CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/comparison, inst+135, unloaded +// CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/comparison, inst+72, unloaded +// CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/comparison, inst+93, unloaded +// CHECK:STDOUT: %import_ref.14 = import_ref Core//prelude/operators/comparison, inst+114, unloaded +// CHECK:STDOUT: %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+135, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .TestLess = %TestLess.decl // CHECK:STDOUT: .TestLessEqual = %TestLessEqual.decl @@ -427,7 +447,6 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: .TestGreaterEqual = %TestGreaterEqual.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} // CHECK:STDOUT: %TestLess.decl: %TestLess.type = fn_decl @TestLess [template = constants.%TestLess] { // CHECK:STDOUT: %D.ref.loc6_16: type = name_ref D, %D.decl [template = constants.%D] @@ -503,7 +522,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Less[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Less(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestLessEqual(%a: %D, %b: %D) -> bool { // CHECK:STDOUT: !entry: @@ -512,7 +535,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @LessOrEquivalent[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @LessOrEquivalent(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestGreater(%a: %D, %b: %D) -> bool { // CHECK:STDOUT: !entry: @@ -521,7 +548,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Greater[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @Greater(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestGreaterEqual(%a: %D, %b: %D) -> bool { // CHECK:STDOUT: !entry: @@ -530,5 +561,9 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @GreaterOrEquivalent[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: generic fn @GreaterOrEquivalent(constants.%Self: %.4) { +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self](%other: %Self) -> bool; +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/right_shift.carbon b/toolchain/check/testdata/operators/overloaded/right_shift.carbon index 52104a5fa2714..db0f61163f528 100644 --- a/toolchain/check/testdata/operators/overloaded/right_shift.carbon +++ b/toolchain/check/testdata/operators/overloaded/right_shift.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @RightShift, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @RightShiftAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+209, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+211, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir5, inst+231, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir5, inst+227, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+233, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+235, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir5, inst+254, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir5, inst+250, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir5, inst+209, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir5, inst+227, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir5, inst+233, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir5, inst+250, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .RightShift = %import_ref.1 +// CHECK:STDOUT: .RightShiftAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/bitwise, inst+222, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/bitwise, inst+224, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/bitwise, inst+245, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/bitwise, inst+240, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/bitwise, inst+247, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/bitwise, inst+249, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/bitwise, inst+270, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/bitwise, inst+264, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/bitwise, inst+240, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/bitwise, inst+264, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %RightShift.ref: type = name_ref RightShift, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %RightShiftAssign.ref: type = name_ref RightShiftAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/operators/overloaded/sub.carbon b/toolchain/check/testdata/operators/overloaded/sub.carbon index c49d4443c2c0b..8559b85d65d95 100644 --- a/toolchain/check/testdata/operators/overloaded/sub.carbon +++ b/toolchain/check/testdata/operators/overloaded/sub.carbon @@ -51,53 +51,61 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: %.7: type = ptr_type %C [template] // CHECK:STDOUT: %Op.type.3: type = fn_type @Op.3 [template] // CHECK:STDOUT: %Op.3: %Op.type.3 = struct_value () [template] -// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %Op.type.4: type = fn_type @Op.4 [template] // CHECK:STDOUT: %Op.4: %Op.type.4 = struct_value () [template] +// CHECK:STDOUT: %.8: type = ptr_type %Self.2 [symbolic] // CHECK:STDOUT: %.9: = interface_witness (%Op.3) [template] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template] // CHECK:STDOUT: %.10: type = assoc_entity_type @Sub, %Op.type.2 [template] -// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.9 [template] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [template] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [template] // CHECK:STDOUT: %.12: type = assoc_entity_type @SubAssign, %Op.type.4 [template] -// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir4, inst+86, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.2 = import_ref ir4, inst+88, unloaded -// CHECK:STDOUT: %import_ref.3: %.10 = import_ref ir4, inst+108, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref ir4, inst+104, loaded [template = constants.%Op.2] -// CHECK:STDOUT: %import_ref.5: type = import_ref ir4, inst+110, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.6 = import_ref ir4, inst+112, unloaded -// CHECK:STDOUT: %import_ref.7: %.12 = import_ref ir4, inst+131, loaded [template = constants.%.13] -// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref ir4, inst+127, loaded [template = constants.%Op.4] -// CHECK:STDOUT: %import_ref.9: type = import_ref ir4, inst+86, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.10 = import_ref ir4, inst+104, unloaded -// CHECK:STDOUT: %import_ref.11: type = import_ref ir4, inst+110, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.12 = import_ref ir4, inst+127, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Sub = %import_ref.1 +// CHECK:STDOUT: .SubAssign = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+92, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+94, unloaded +// CHECK:STDOUT: %import_ref.3: %.10 = import_ref Core//prelude/operators/arithmetic, inst+115, loaded [template = constants.%.11] +// CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+110, loaded [template = constants.%Op.2] +// CHECK:STDOUT: %import_ref.5: type = import_ref Core//prelude/operators/arithmetic, inst+117, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/arithmetic, inst+119, unloaded +// CHECK:STDOUT: %import_ref.7: %.12 = import_ref Core//prelude/operators/arithmetic, inst+140, loaded [template = constants.%.13] +// CHECK:STDOUT: %import_ref.8: %Op.type.4 = import_ref Core//prelude/operators/arithmetic, inst+134, loaded [template = constants.%Op.4] +// CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/arithmetic, inst+110, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/arithmetic, inst+134, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: impl_decl @impl.1 { // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc17: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %Sub.ref: type = name_ref Sub, imports.%import_ref.1 [template = constants.%.2] // CHECK:STDOUT: } // CHECK:STDOUT: impl_decl @impl.2 { // CHECK:STDOUT: %C.ref.loc22: type = name_ref C, %C.decl [template = constants.%C] -// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, %Core [template = %Core] +// CHECK:STDOUT: %Core.ref.loc22: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %SubAssign.ref: type = name_ref SubAssign, imports.%import_ref.5 [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] { @@ -184,14 +192,23 @@ fn TestAssign(a: C*, b: C) { // CHECK:STDOUT: return %.loc19_14 to @impl.1.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.2[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: generic fn @Op.2(constants.%Self.1: %.2) { +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self: %Self.1](%other: %Self.1) -> %Self.1; +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc23_14.3: %.7](@impl.2.%other.loc23_24.2: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op.4[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: generic fn @Op.4(constants.%Self.2: %.6) { +// CHECK:STDOUT: %Self: %.6 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %.2: type = ptr_type @Op.4.%Self (%Self.2) [symbolic = %.2 (constants.%.8)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[addr %self: %.8](%other: %Self.2); +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a: %C, %b: %C) -> %return: %C { // CHECK:STDOUT: !entry: diff --git a/toolchain/check/testdata/package_expr/fail_not_found.carbon b/toolchain/check/testdata/package_expr/fail_not_found.carbon index a3446cefdfde5..37523f1c5422f 100644 --- a/toolchain/check/testdata/package_expr/fail_not_found.carbon +++ b/toolchain/check/testdata/package_expr/fail_not_found.carbon @@ -26,16 +26,25 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/package_expr/syntax.carbon b/toolchain/check/testdata/package_expr/syntax.carbon index 9a9bec14c21b8..55a27ec062512 100644 --- a/toolchain/check/testdata/package_expr/syntax.carbon +++ b/toolchain/check/testdata/package_expr/syntax.carbon @@ -51,18 +51,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_8.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_8.2: type = converted %int.make_type_32.loc4, %.loc4_8.1 [template = i32] @@ -101,19 +109,26 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_8.2: type = converted %int.make_type_32, %.loc4_8.1 [template = i32] @@ -165,14 +180,25 @@ fn Main() { // CHECK:STDOUT: %.3: type = ptr_type %.2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %NS: = namespace [template] { // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/packages/explicit_imports.carbon b/toolchain/check/testdata/packages/explicit_imports.carbon index 69d331835916e..1cbd97276862f 100644 --- a/toolchain/check/testdata/packages/explicit_imports.carbon +++ b/toolchain/check/testdata/packages/explicit_imports.carbon @@ -40,66 +40,135 @@ import library "lib"; // CHECK:STDOUT: --- api.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- api_lib.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- same_package.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- different_package.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Api: = namespace file.%Api.import, [template] { +// CHECK:STDOUT: import Api//default +// CHECK:STDOUT: import Api//lib +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Api = %Api +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Api = imports.%Api // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Api.import = import Api -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Api: = namespace %Api.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- main_lib_api.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- main_import.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_api_not_found.carbon b/toolchain/check/testdata/packages/fail_api_not_found.carbon index 39bc013911286..4f57b99a60fd3 100644 --- a/toolchain/check/testdata/packages/fail_api_not_found.carbon +++ b/toolchain/check/testdata/packages/fail_api_not_found.carbon @@ -33,37 +33,70 @@ impl library "Bar"; // CHECK:STDOUT: --- fail_no_api.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_no_api_lib.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_no_api_main_lib.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon b/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon index 67a56e912d03e..bc5443a2905b1 100644 --- a/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon +++ b/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon @@ -47,13 +47,24 @@ import library "var"; // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -68,16 +79,25 @@ import library "var"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_10.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_10.2: type = converted %int.make_type_32, %.loc4_10.1 [template = i32] @@ -90,17 +110,25 @@ import library "var"; // CHECK:STDOUT: --- fail_conflict.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+3, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+13, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Example//fn, inst+3, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Example//var, inst+13, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Foo = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_cycle.carbon b/toolchain/check/testdata/packages/fail_cycle.carbon index 883e6971dbcd1..daed62198de2a 100644 --- a/toolchain/check/testdata/packages/fail_cycle.carbon +++ b/toolchain/check/testdata/packages/fail_cycle.carbon @@ -57,73 +57,128 @@ import B; // CHECK:STDOUT: --- fail_a.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %B: = namespace file.%B.import, [template] { +// CHECK:STDOUT: has_error +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .B = %B +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .B = imports.%B // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %B.import = import B -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %B: = namespace %B.import, [template] { -// CHECK:STDOUT: has_error -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_b.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %C: = namespace file.%C.import, [template] { +// CHECK:STDOUT: has_error +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .C = %C +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .C = imports.%C // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.import = import C -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %C: = namespace %C.import, [template] { -// CHECK:STDOUT: has_error -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_c.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %A: = namespace file.%A.import, [template] { +// CHECK:STDOUT: has_error +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .A = %A +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .A = imports.%A // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.import = import A -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %A: = namespace %A.import, [template] { -// CHECK:STDOUT: has_error -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_c.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_cycle_child.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %B: = namespace file.%B.import, [template] { +// CHECK:STDOUT: has_error +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .B = %B +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .B = imports.%B // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %B.import = import B -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %B: = namespace %B.import, [template] { -// CHECK:STDOUT: has_error -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_duplicate_api.carbon b/toolchain/check/testdata/packages/fail_duplicate_api.carbon index b5e1aa73f6d28..1a81a955154fd 100644 --- a/toolchain/check/testdata/packages/fail_duplicate_api.carbon +++ b/toolchain/check/testdata/packages/fail_duplicate_api.carbon @@ -51,81 +51,169 @@ package Package library "lib"; // CHECK:STDOUT: --- main1.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main2.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- main_lib1.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_lib2.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- package1.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_package2.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- package_lib1.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_package_lib2.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_extension.carbon b/toolchain/check/testdata/packages/fail_extension.carbon index f1deb44b20539..4df4ee6307bb9 100644 --- a/toolchain/check/testdata/packages/fail_extension.carbon +++ b/toolchain/check/testdata/packages/fail_extension.carbon @@ -86,109 +86,219 @@ impl package SwappedExt; // CHECK:STDOUT: --- fail_main.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_redundant_with_swapped_ext.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_lib.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_lib_impl.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc6_6.1 = import // CHECK:STDOUT: %default.import.loc6_6.2 = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_package.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_package_impl.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Package.import = import Package // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_package_lib.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_package_lib_impl.incorrect // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Package.import = import Package // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_swapped_ext.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_swapped_ext.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %SwappedExt.import = import SwappedExt // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_import_default.carbon b/toolchain/check/testdata/packages/fail_import_default.carbon index 6b9afa848329a..08a05a0887f10 100644 --- a/toolchain/check/testdata/packages/fail_import_default.carbon +++ b/toolchain/check/testdata/packages/fail_import_default.carbon @@ -47,43 +47,87 @@ import library default; // CHECK:STDOUT: --- fail_default_api.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_default.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %A.import = import A // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_import_default.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_lib_import_default.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_import_invalid.carbon b/toolchain/check/testdata/packages/fail_import_invalid.carbon index d68f8651de1d8..608d5b5544f29 100644 --- a/toolchain/check/testdata/packages/fail_import_invalid.carbon +++ b/toolchain/check/testdata/packages/fail_import_invalid.carbon @@ -96,100 +96,199 @@ import ImportNotFound; // CHECK:STDOUT: --- fail_main.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_not_main.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_this.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_this_lib.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- implicit_api.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_implicit.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- implicit_lib_api.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_implicit_lib.impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_not_found.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %ImportNotFound: = namespace file.%ImportNotFound.import, [template] { +// CHECK:STDOUT: has_error +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .ImportNotFound = %ImportNotFound +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .ImportNotFound = imports.%ImportNotFound // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %ImportNotFound.import = import ImportNotFound -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %ImportNotFound: = namespace %ImportNotFound.import, [template] { -// CHECK:STDOUT: has_error -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_import_repeat.carbon b/toolchain/check/testdata/packages/fail_import_repeat.carbon index 26c5b04f62c61..c4d0d5778b64f 100644 --- a/toolchain/check/testdata/packages/fail_import_repeat.carbon +++ b/toolchain/check/testdata/packages/fail_import_repeat.carbon @@ -67,56 +67,114 @@ import library default; // CHECK:STDOUT: --- api.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- api_lib.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- main_lib.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_import.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %Api: = namespace file.%Api.import, [template] { +// CHECK:STDOUT: import Api//default +// CHECK:STDOUT: import Api//lib +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core -// CHECK:STDOUT: .Api = %Api +// CHECK:STDOUT: .Core = imports.%Core +// CHECK:STDOUT: .Api = imports.%Api // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Api.import = import Api // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} -// CHECK:STDOUT: %Api: = namespace %Api.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_default_import.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_import_type_error.carbon b/toolchain/check/testdata/packages/fail_import_type_error.carbon index 1f8948344a51d..70bb0185d1a92 100644 --- a/toolchain/check/testdata/packages/fail_import_type_error.carbon +++ b/toolchain/check/testdata/packages/fail_import_type_error.carbon @@ -45,16 +45,27 @@ var d: i32 = d_ref; // CHECK:STDOUT: --- fail_implicit.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: .b_ref = %b_ref // CHECK:STDOUT: .c_ref = %c_ref // CHECK:STDOUT: .d_ref = %d_ref // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %x.ref.loc8: = name_ref x, [template = ] // CHECK:STDOUT: %a_ref.var: ref = var a_ref // CHECK:STDOUT: %a_ref: ref = bind_name a_ref, %a_ref.var @@ -81,14 +92,21 @@ var d: i32 = d_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: ref = import_ref ir0, inst+5, loaded -// CHECK:STDOUT: %import_ref.2: ref = import_ref ir0, inst+10, loaded -// CHECK:STDOUT: %import_ref.3: ref = import_ref ir0, inst+14, loaded -// CHECK:STDOUT: %import_ref.4: ref = import_ref ir0, inst+18, loaded -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: ref = import_ref Implicit//default, inst+5, loaded +// CHECK:STDOUT: %import_ref.2: ref = import_ref Implicit//default, inst+10, loaded +// CHECK:STDOUT: %import_ref.3: ref = import_ref Implicit//default, inst+14, loaded +// CHECK:STDOUT: %import_ref.4: ref = import_ref Implicit//default, inst+18, loaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -97,7 +115,7 @@ var d: i32 = d_ref; // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .c_ref = imports.%import_ref.3 // CHECK:STDOUT: .d_ref = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c @@ -106,7 +124,6 @@ var d: i32 = d_ref; // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_8.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32] // CHECK:STDOUT: %.loc6_8.2: type = converted %int.make_type_32.loc6, %.loc6_8.1 [template = i32] diff --git a/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon b/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon index f1edaf6e07715..26faf4af833c7 100644 --- a/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon +++ b/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon @@ -23,15 +23,26 @@ var a: () = A(); // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc7_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc7_9.2: type = converted %.loc7_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a diff --git a/toolchain/check/testdata/packages/fail_package_main.carbon b/toolchain/check/testdata/packages/fail_package_main.carbon index 50d4dd3125ffe..0cc9e54d2be83 100644 --- a/toolchain/check/testdata/packages/fail_package_main.carbon +++ b/toolchain/check/testdata/packages/fail_package_main.carbon @@ -42,41 +42,85 @@ package Main library "lib"; // CHECK:STDOUT: --- fail_main.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_impl.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_raw_main.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_lib.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/implicit_imports_prelude.carbon b/toolchain/check/testdata/packages/implicit_imports_prelude.carbon index 3bd0ebe7bc947..4d4b6f63f54de 100644 --- a/toolchain/check/testdata/packages/implicit_imports_prelude.carbon +++ b/toolchain/check/testdata/packages/implicit_imports_prelude.carbon @@ -32,16 +32,25 @@ var b: i32 = a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_8.2: type = converted %int.make_type_32, %.loc4_8.1 [template = i32] @@ -67,20 +76,29 @@ var b: i32 = a; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: ref i32 = import_ref ir0, inst+13, loaded -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1: ref i32 = import_ref Main//lib, inst+13, loaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .a = imports.%import_ref.1 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_8.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_8.2: type = converted %int.make_type_32, %.loc4_8.1 [template = i32] diff --git a/toolchain/check/testdata/packages/loaded_global.carbon b/toolchain/check/testdata/packages/loaded_global.carbon index 8b742ee03e87f..14ba9a615810b 100644 --- a/toolchain/check/testdata/packages/loaded_global.carbon +++ b/toolchain/check/testdata/packages/loaded_global.carbon @@ -46,13 +46,24 @@ var package_b: () = package.B(); // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -67,20 +78,28 @@ var package_b: () = package.B(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %A.type = import_ref ir0, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %import_ref: %A.type = import_ref Implicit//default, inst+3, loaded [template = constants.%A] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .package_a = %package_a // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %a.var: ref %.1 = var a @@ -113,13 +132,24 @@ var package_b: () = package.B(); // CHECK:STDOUT: %B: %B.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -134,19 +164,27 @@ var package_b: () = package.B(); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %B.type = import_ref ir1, inst+3, loaded [template = constants.%B] +// CHECK:STDOUT: %import_ref: %B.type = import_ref SamePackage//default, inst+3, loaded [template = constants.%B] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .B = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .package_b = %package_b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %b.var: ref %.1 = var b diff --git a/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon b/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon index c21f1eafa7099..e0fc96b2d33c1 100644 --- a/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon +++ b/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon @@ -250,7 +250,7 @@ alias C = Other.C; // CHECK:STDOUT: --- export_import.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Other//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -263,7 +263,7 @@ alias C = Other.C; // CHECK:STDOUT: --- export_import_copy.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Other//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -276,7 +276,7 @@ alias C = Other.C; // CHECK:STDOUT: --- export_import_indirect.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir2, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Other//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -295,9 +295,9 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -323,9 +323,9 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -351,9 +351,9 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//export_name, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//export_name, inst+9, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//export_name, inst+10, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -382,19 +382,23 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_import +// CHECK:STDOUT: import Other//base +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -431,19 +435,24 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir3, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir3, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir3, inst+7, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_import +// CHECK:STDOUT: import Other//export_import_copy +// CHECK:STDOUT: import Other//base +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -480,19 +489,24 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir3, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir3, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir3, inst+7, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_import_indirect +// CHECK:STDOUT: import Other//export_import +// CHECK:STDOUT: import Other//base +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -529,19 +543,22 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_name +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//export_name, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//export_name, inst+9, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//export_name, inst+10, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -578,19 +595,23 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_name +// CHECK:STDOUT: import Other//export_name_copy +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//export_name, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//export_name, inst+9, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//export_name, inst+10, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -627,19 +648,22 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_name_indirect +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//export_name_indirect, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//export_name_indirect, inst+9, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//export_name_indirect, inst+10, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -676,19 +700,28 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+10, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_import +// CHECK:STDOUT: import Other//export_name +// CHECK:STDOUT: import Other//export_import_copy +// CHECK:STDOUT: import Other//export_name_copy +// CHECK:STDOUT: import Other//export_import_indirect +// CHECK:STDOUT: import Other//export_name_indirect +// CHECK:STDOUT: import Other//base +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//export_name, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//export_name, inst+9, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//export_name, inst+10, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var @@ -715,22 +748,35 @@ alias C = Other.C; // CHECK:STDOUT: // CHECK:STDOUT: --- unused_conflict_on_export_import.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//export_import +// CHECK:STDOUT: import Other//conflict +// CHECK:STDOUT: import Other//base +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- unused_conflict_on_export_name.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//export_name +// CHECK:STDOUT: import Other//conflict +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_conflict_on_export_import.carbon @@ -742,18 +788,23 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %C.type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir3, inst+1, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_import +// CHECK:STDOUT: import Other//conflict +// CHECK:STDOUT: import Other//base +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %C.type = import_ref Other//conflict, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .C = %C // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %C: %C.type = bind_alias C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: } @@ -769,20 +820,24 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+11, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+9, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir2, inst+1, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import Other//export_name +// CHECK:STDOUT: import Other//conflict +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//export_name, inst+11, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//export_name, inst+9, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Other//export_name, inst+10, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Other//conflict, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .C = %C // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %C: type = bind_alias C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/packages/no_prelude/cross_package_import.carbon b/toolchain/check/testdata/packages/no_prelude/cross_package_import.carbon index 5255c5d12a09b..0b51ca11c9d69 100644 --- a/toolchain/check/testdata/packages/no_prelude/cross_package_import.carbon +++ b/toolchain/check/testdata/packages/no_prelude/cross_package_import.carbon @@ -311,7 +311,7 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %F.type = import_ref ir1, inst+1, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref: %F.type = import_ref Other//fn, inst+1, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -354,26 +354,31 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %F.type = import_ref ir1, inst+1, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.2: %F2.type = import_ref ir2, inst+1, loaded [template = constants.%F2] +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .F = %import_ref.1 +// CHECK:STDOUT: .F2 = %import_ref.2 +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: import Other//fn2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %F.type = import_ref Other//fn, inst+1, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.2: %F2.type = import_ref Other//fn2, inst+1, loaded [template = constants.%F2] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Other.ref.loc8: = name_ref Other, file.%Other [template = file.%Other] +// CHECK:STDOUT: %Other.ref.loc8: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.1 [template = constants.%F] // CHECK:STDOUT: %F.call: init %.1 = call %F.ref() -// CHECK:STDOUT: %Other.ref.loc9: = name_ref Other, file.%Other [template = file.%Other] +// CHECK:STDOUT: %Other.ref.loc9: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %F2.ref: %F2.type = name_ref F2, imports.%import_ref.2 [template = constants.%F2] // CHECK:STDOUT: %F2.call: init %.1 = call %F2.ref() // CHECK:STDOUT: return @@ -394,23 +399,27 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %F.type = import_ref ir1, inst+1, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+1, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .F = %import_ref.1 +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: import Other//fn_extern +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %F.type = import_ref Other//fn, inst+1, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//fn_extern, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Other.ref: = name_ref Other, file.%Other [template = file.%Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.1 [template = constants.%F] // CHECK:STDOUT: %F.call: init %.1 = call %F.ref() // CHECK:STDOUT: return @@ -420,12 +429,18 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: // CHECK:STDOUT: --- main_unused_other_ambiguous.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: import Other//fn_conflict +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_main_use_other_ambiguous.carbon @@ -439,23 +454,27 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %F.type = import_ref ir1, inst+1, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+6, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .F = %import_ref.1 +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: import Other//fn_conflict +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %F.type = import_ref Other//fn, inst+1, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//fn_conflict, inst+6, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Other.ref: = name_ref Other, file.%Other [template = file.%Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.1 [template = constants.%F] // CHECK:STDOUT: %F.call: init %.1 = call %F.ref() // CHECK:STDOUT: return @@ -472,17 +491,20 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %F.type = import_ref ir2, inst+1, loaded [template = constants.%F] +// CHECK:STDOUT: %import_ref.1: = import_ref Main//other_ns, inst+1, loaded +// CHECK:STDOUT: %Other: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .F = file.%F.decl +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: %F.type = import_ref Other//fn, inst+1, loaded [template = constants.%F] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+1, loaded -// CHECK:STDOUT: %Other: = namespace %import_ref, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -499,15 +521,22 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: %G: %G.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .G = file.%G.decl +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] { +// CHECK:STDOUT: %Other: = namespace [template] { // CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: import Other//fn // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc13: = namespace [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -524,14 +553,18 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .Nested = file.%Nested +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] { -// CHECK:STDOUT: .Nested = %Nested -// CHECK:STDOUT: } // CHECK:STDOUT: %Nested: = namespace [template] { // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } @@ -551,14 +584,18 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: %G: %G.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .G = file.%G.decl +// CHECK:STDOUT: import Other//fn +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] { -// CHECK:STDOUT: .G = %G.decl -// CHECK:STDOUT: } // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -575,19 +612,24 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: %UseF: %UseF.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//fn_use +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .UseF = %UseF.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: %UseF.decl: %UseF.type = fn_decl @UseF [template = constants.%UseF] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @UseF() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Other.ref: = name_ref Other, file.%Other [template = file.%Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %F.ref: = name_ref F, [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/packages/no_prelude/export_import.carbon b/toolchain/check/testdata/packages/no_prelude/export_import.carbon index 298a5b86ba00b..9ad8b47063fdf 100644 --- a/toolchain/check/testdata/packages/no_prelude/export_import.carbon +++ b/toolchain/check/testdata/packages/no_prelude/export_import.carbon @@ -195,7 +195,7 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: --- export.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -208,7 +208,7 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: --- export_copy.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -221,7 +221,7 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: --- non_export.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir2, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -234,7 +234,7 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: --- export_export.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir2, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -247,7 +247,7 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: --- import_then_export.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//base, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -275,9 +275,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -322,9 +322,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -370,9 +370,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+2, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_export, inst+2, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -418,9 +418,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir3, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir3, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir3, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -465,9 +465,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -512,9 +512,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -559,9 +559,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -606,9 +606,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -653,9 +653,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir3, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir3, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir3, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -711,9 +711,9 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -758,10 +758,10 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+14, unloaded -// CHECK:STDOUT: %import_ref.2: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//use_non_export_then_base, inst+14, unloaded +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon b/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon index be5eae1fefcc1..f052315533c24 100644 --- a/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon +++ b/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon @@ -157,8 +157,8 @@ var d: D = {.y = ()}; // CHECK:STDOUT: --- export_import.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+11, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//base, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+11, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -178,10 +178,10 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+11, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir2, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+11, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -208,10 +208,10 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+11, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+11, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -232,7 +232,7 @@ var d: D = {.y = ()}; // CHECK:STDOUT: --- export_name_then_import.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+12, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//export_name, inst+12, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -254,9 +254,9 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+11, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_import_then_name, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export_import_then_name, inst+10, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export_import_then_name, inst+11, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -301,9 +301,9 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+10, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+11, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_name, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export_name, inst+10, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export_name, inst+11, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -348,9 +348,9 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+11, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_import_then_name, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export_import_then_name, inst+10, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export_import_then_name, inst+11, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -391,7 +391,7 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+12, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//export_import_then_name, inst+12, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -425,9 +425,9 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+11, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_import_then_name, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//export_import_then_name, inst+10, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export_import_then_name, inst+11, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -476,12 +476,12 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+12, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir5, inst+11, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+10, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+11, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir5, inst+12, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+16, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_import_then_name, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//base, inst+11, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export_import_then_name, inst+10, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//export_import_then_name, inst+11, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//base, inst+12, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//base, inst+16, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/packages/no_prelude/export_name.carbon b/toolchain/check/testdata/packages/no_prelude/export_name.carbon index b5db76ea34459..4f22ec8f926c5 100644 --- a/toolchain/check/testdata/packages/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/packages/no_prelude/export_name.carbon @@ -259,57 +259,57 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+12, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+7, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+17, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//base, inst+11, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = file.%NSC +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//base, inst+12, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//base, inst+7, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//base, inst+13, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//base, inst+17, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+11, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = %NSC -// CHECK:STDOUT: } // CHECK:STDOUT: %C: type = export C, imports.%import_ref.1 [template = constants.%C] -// CHECK:STDOUT: %NSC: type = export NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NSC: type = export NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- not_reexporting.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+14, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//export, inst+14, unloaded +// CHECK:STDOUT: %import_ref.2: = import_ref Main//export, inst+4, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//export, inst+22, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+4, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- export_export.carbon @@ -323,38 +323,38 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+22, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+20, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+21, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//export, inst+4, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = file.%NSC +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//export, inst+22, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//export, inst+12, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//export, inst+13, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//export, inst+20, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//export, inst+21, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+4, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = %NSC -// CHECK:STDOUT: } // CHECK:STDOUT: %C: type = export C, imports.%import_ref.1 [template = constants.%C] -// CHECK:STDOUT: %NSC: type = export NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NSC: type = export NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- export_in_impl.carbon @@ -379,45 +379,45 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+22, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+20, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+21, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//export, inst+4, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//export, inst+22, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//export, inst+12, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//export, inst+13, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//export, inst+20, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//export, inst+21, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+4, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var -// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -457,46 +457,46 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir0, inst+22, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir0, inst+12, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir0, inst+13, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+20, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir0, inst+21, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_export, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//export_export, inst+4, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//export_export, inst+22, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//export_export, inst+12, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//export_export, inst+13, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//export_export, inst+20, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//export_export, inst+21, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+4, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var -// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -536,45 +536,45 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+22, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+20, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+21, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export_export, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//export_export, inst+4, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//export_export, inst+22, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//export_export, inst+12, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//export_export, inst+13, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//export_export, inst+20, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//export_export, inst+21, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+4, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var -// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -601,20 +601,20 @@ private export C; // CHECK:STDOUT: --- fail_export_ns.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+12, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Main//base, inst+1, unloaded +// CHECK:STDOUT: %import_ref.2: = import_ref Main//base, inst+11, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+12, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+11, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_export_decl.carbon @@ -645,28 +645,28 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//base, inst+11, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+12, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+11, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- import_both.carbon @@ -685,45 +685,45 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+12, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+7, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+17, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//base, inst+11, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//base, inst+12, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//base, inst+7, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//base, inst+13, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//base, inst+17, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+11, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var -// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -763,45 +763,45 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+22, loaded [template = constants.%NSC] -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+13, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+20, unloaded -// CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+21, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//export, inst+4, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//export, inst+22, loaded [template = constants.%NSC] +// CHECK:STDOUT: %import_ref.4 = import_ref Main//export, inst+12, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//export, inst+13, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//export, inst+20, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//export, inst+21, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+4, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var -// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.2 [template = constants.%NSC] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.3 [template = constants.%NSC] // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 -// CHECK:STDOUT: .y = imports.%import_ref.6 +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .y = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -848,29 +848,29 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//base, inst+11, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+12, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+11, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C: type = export C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- use_repeat_export.carbon @@ -885,9 +885,9 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+14, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+13, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//repeat_export, inst+14, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//repeat_export, inst+12, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//repeat_export, inst+13, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -929,28 +929,28 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+12, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+7, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2: = import_ref Main//base, inst+11, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.2, [template] { +// CHECK:STDOUT: .NSC = %import_ref.3 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+12, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//base, inst+2, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//base, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+11, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .NSC = imports.%import_ref.2 -// CHECK:STDOUT: } // CHECK:STDOUT: %C: type = export C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.3 -// CHECK:STDOUT: .x = imports.%import_ref.4 +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .x = imports.%import_ref.5 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon b/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon index ce299a8aa4184..27697b8a4a06a 100644 --- a/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon +++ b/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon @@ -71,9 +71,9 @@ export C.n; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+8, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Foo//a, inst+1, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref Foo//a, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Foo//a, inst+8, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon b/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon index 2fbd83d252ca3..6e62138da2ddb 100644 --- a/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon +++ b/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon @@ -35,10 +35,10 @@ export C2(T:! type); // CHECK:STDOUT: %C1.type: type = generic_class_type @C1 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %C1.1: %C1.type = struct_value () [template] -// CHECK:STDOUT: %C1.2: type = class_type @C1, (%T) [symbolic] +// CHECK:STDOUT: %C1.2: type = class_type @C1, @C1(%T) [symbolic] // CHECK:STDOUT: %C2.type: type = generic_class_type @C2 [template] // CHECK:STDOUT: %C2.1: %C2.type = struct_value () [template] -// CHECK:STDOUT: %C2.2: type = class_type @C2, (%T) [symbolic] +// CHECK:STDOUT: %C2.2: type = class_type @C2, @C2(%T) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -48,19 +48,33 @@ export C2(T:! type); // CHECK:STDOUT: } // CHECK:STDOUT: %C1.decl: %C1.type = class_decl @C1 [template = constants.%C1.1] { // CHECK:STDOUT: %T.loc4_10.1: type = param T -// CHECK:STDOUT: %T.loc4_10.2: type = bind_symbolic_name T 0, %T.loc4_10.1 [symbolic = %T.loc4_10.2 (constants.%T)] +// CHECK:STDOUT: %T.loc4_10.2: type = bind_symbolic_name T 0, %T.loc4_10.1 [symbolic = @C1.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %C2.decl: %C2.type = class_decl @C2 [template = constants.%C2.1] { // CHECK:STDOUT: %T.loc5_10.1: type = param T -// CHECK:STDOUT: %T.loc5_10.2: type = bind_symbolic_name T 0, %T.loc5_10.1 [symbolic = %T.loc5_10.2 (constants.%T)] +// CHECK:STDOUT: %T.loc5_10.2: type = bind_symbolic_name T 0, %T.loc5_10.1 [symbolic = @C2.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C1 -// CHECK:STDOUT: generic [file.%T.loc4_10.2: type]; +// CHECK:STDOUT: generic class @C1(file.%T.loc4_10.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: class @C2 -// CHECK:STDOUT: generic [file.%T.loc5_10.2: type]; +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C2(file.%T.loc5_10.2: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C1(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C2(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_b.carbon // CHECK:STDOUT: @@ -68,16 +82,16 @@ export C2(T:! type); // CHECK:STDOUT: %C1.type: type = generic_class_type @C1 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %C1.1: %C1.type = struct_value () [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T 0, [symbolic] -// CHECK:STDOUT: %C1.2: type = class_type @C1, (%T) [symbolic] +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %C1.2: type = class_type @C1, @C1(%T) [symbolic] // CHECK:STDOUT: %C2.type: type = generic_class_type @C2 [template] // CHECK:STDOUT: %C2.1: %C2.type = struct_value () [template] -// CHECK:STDOUT: %C2.2: type = class_type @C2, (%T) [symbolic] +// CHECK:STDOUT: %C2.2: type = class_type @C2, @C2(%T) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %C1.type = import_ref ir1, inst+4, loaded [template = constants.%C1.1] -// CHECK:STDOUT: %import_ref.2: %C2.type = import_ref ir1, inst+11, loaded [template = constants.%C2.1] +// CHECK:STDOUT: %import_ref.1: %C1.type = import_ref Foo//a, inst+4, loaded [template = constants.%C1.1] +// CHECK:STDOUT: %import_ref.2: %C2.type = import_ref Foo//a, inst+12, loaded [template = constants.%C2.1] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -92,7 +106,23 @@ export C2(T:! type); // CHECK:STDOUT: %C2: %C2.type = export C2, imports.%import_ref.2 [template = constants.%C2.1] // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C1; +// CHECK:STDOUT: generic class @C1(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] // CHECK:STDOUT: -// CHECK:STDOUT: class @C2; +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C2(constants.%T: type) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: +// CHECK:STDOUT: class; +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C1(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C2(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/fail_modifiers.carbon b/toolchain/check/testdata/packages/no_prelude/fail_modifiers.carbon index c839f8fb6b806..58731eec34aa2 100644 --- a/toolchain/check/testdata/packages/no_prelude/fail_modifiers.carbon +++ b/toolchain/check/testdata/packages/no_prelude/fail_modifiers.carbon @@ -131,33 +131,36 @@ private import PrivateImport; // CHECK:STDOUT: // CHECK:STDOUT: --- fail_import_modifiers.carbon // CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .ImplImport = %ImplImport -// CHECK:STDOUT: .ExtendImport = %ExtendImport -// CHECK:STDOUT: .VirtualImport = %VirtualImport -// CHECK:STDOUT: .BaseImport = %BaseImport -// CHECK:STDOUT: .PrivateImport = %PrivateImport -// CHECK:STDOUT: } -// CHECK:STDOUT: %ImplImport.import = import ImplImport -// CHECK:STDOUT: %ExtendImport.import = import ExtendImport -// CHECK:STDOUT: %VirtualImport.import = import VirtualImport -// CHECK:STDOUT: %BaseImport.import = import BaseImport -// CHECK:STDOUT: %PrivateImport.import = import PrivateImport -// CHECK:STDOUT: %ImplImport: = namespace %ImplImport.import, [template] { +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %ImplImport: = namespace file.%ImplImport.import, [template] { // CHECK:STDOUT: has_error // CHECK:STDOUT: } -// CHECK:STDOUT: %ExtendImport: = namespace %ExtendImport.import, [template] { +// CHECK:STDOUT: %ExtendImport: = namespace file.%ExtendImport.import, [template] { // CHECK:STDOUT: has_error // CHECK:STDOUT: } -// CHECK:STDOUT: %VirtualImport: = namespace %VirtualImport.import, [template] { +// CHECK:STDOUT: %VirtualImport: = namespace file.%VirtualImport.import, [template] { // CHECK:STDOUT: has_error // CHECK:STDOUT: } -// CHECK:STDOUT: %BaseImport: = namespace %BaseImport.import, [template] { +// CHECK:STDOUT: %BaseImport: = namespace file.%BaseImport.import, [template] { // CHECK:STDOUT: has_error // CHECK:STDOUT: } -// CHECK:STDOUT: %PrivateImport: = namespace %PrivateImport.import, [template] { +// CHECK:STDOUT: %PrivateImport: = namespace file.%PrivateImport.import, [template] { // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .ImplImport = imports.%ImplImport +// CHECK:STDOUT: .ExtendImport = imports.%ExtendImport +// CHECK:STDOUT: .VirtualImport = imports.%VirtualImport +// CHECK:STDOUT: .BaseImport = imports.%BaseImport +// CHECK:STDOUT: .PrivateImport = imports.%PrivateImport +// CHECK:STDOUT: } +// CHECK:STDOUT: %ImplImport.import = import ImplImport +// CHECK:STDOUT: %ExtendImport.import = import ExtendImport +// CHECK:STDOUT: %VirtualImport.import = import VirtualImport +// CHECK:STDOUT: %BaseImport.import = import BaseImport +// CHECK:STDOUT: %PrivateImport.import = import PrivateImport +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon b/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon index dc9cce963fe53..209a9dfed53d5 100644 --- a/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon +++ b/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon @@ -292,7 +292,7 @@ import Other library "O1"; // CHECK:STDOUT: --- mix_current_package.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//C1, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -315,10 +315,10 @@ import Other library "O1"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+2, loaded [template = constants.%C1] -// CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+1, loaded [template = constants.%C2] -// CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//mix_current_package, inst+2, loaded [template = constants.%C1] +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//C2, inst+1, loaded [template = constants.%C2] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//C1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//C2, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -364,7 +364,7 @@ import Other library "O1"; // CHECK:STDOUT: --- dup_c1.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//C1, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -385,8 +385,8 @@ import Other library "O1"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+2, loaded [template = constants.%C1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: type = import_ref Main//dup_c1, inst+2, loaded [template = constants.%C1] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//C1, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -418,18 +418,18 @@ import Other library "O1"; // CHECK:STDOUT: --- use_ns.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.1: = import_ref Main//ns, inst+1, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .C = %import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2 = import_ref Main//ns, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %import_ref: = import_ref ir1, inst+1, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .C = imports.%import_ref -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- use_ns.impl.carbon @@ -443,30 +443,30 @@ import Other library "O1"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir0, inst+4, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded +// CHECK:STDOUT: %import_ref.1: = import_ref Main//use_ns, inst+3, loaded +// CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { +// CHECK:STDOUT: .C = %import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.2: type = import_ref Main//use_ns, inst+4, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.3 = import_ref Main//ns, inst+3, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .NS = %NS +// CHECK:STDOUT: .NS = imports.%NS // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import -// CHECK:STDOUT: %import_ref: = import_ref ir0, inst+3, loaded -// CHECK:STDOUT: %NS: = namespace %import_ref, [template] { -// CHECK:STDOUT: .C = imports.%import_ref.1 -// CHECK:STDOUT: } -// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] -// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.2 [template = constants.%C] // CHECK:STDOUT: %c.var: ref %C = var c // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: .Self = imports.%import_ref.3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -480,12 +480,17 @@ import Other library "O1"; // CHECK:STDOUT: // CHECK:STDOUT: --- mix_other.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- mix_other.impl.carbon @@ -501,27 +506,32 @@ import Other library "O1"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%O1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir2, inst+2, unloaded -// CHECK:STDOUT: %import_ref.3: type = import_ref ir1, inst+1, loaded [template = constants.%O2] -// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .O1 = %import_ref.1 +// CHECK:STDOUT: .O2 = %import_ref.3 +// CHECK:STDOUT: import Other//O2 +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//O1, inst+1, loaded [template = constants.%O1] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//O1, inst+2, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref Other//O2, inst+1, loaded [template = constants.%O2] +// CHECK:STDOUT: %import_ref.4 = import_ref Other//O2, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .o1 = %o1 // CHECK:STDOUT: .o2 = %o2 // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref.loc6: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref.loc6: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %O1.ref: type = name_ref O1, imports.%import_ref.1 [template = constants.%O1] // CHECK:STDOUT: %o1.var: ref %O1 = var o1 // CHECK:STDOUT: %o1: ref %O1 = bind_name o1, %o1.var -// CHECK:STDOUT: %Other.ref.loc7: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref.loc7: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %O2.ref: type = name_ref O2, imports.%import_ref.3 [template = constants.%O2] // CHECK:STDOUT: %o2.var: ref %O2 = var o2 // CHECK:STDOUT: %o2: ref %O2 = bind_name o2, %o2.var @@ -552,12 +562,17 @@ import Other library "O1"; // CHECK:STDOUT: // CHECK:STDOUT: --- dup_o1.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- dup_o1.impl.carbon @@ -571,20 +586,23 @@ import Other library "O1"; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%O1] -// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: .O1 = %import_ref.1 +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref Other//O1, inst+1, loaded [template = constants.%O1] +// CHECK:STDOUT: %import_ref.2 = import_ref Other//O1, inst+2, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: .o1 = %o1 // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} -// CHECK:STDOUT: %Other.ref: = name_ref Other, %Other [template = %Other] +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %O1.ref: type = name_ref O1, imports.%import_ref.1 [template = constants.%O1] // CHECK:STDOUT: %o1.var: ref %O1 = var o1 // CHECK:STDOUT: %o1: ref %O1 = bind_name o1, %o1.var @@ -606,34 +624,41 @@ import Other library "O1"; // CHECK:STDOUT: // CHECK:STDOUT: --- import_conflict.carbon // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_import_conflict.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//local_other, inst+1, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc15_6.1 = import // CHECK:STDOUT: %default.import.loc15_6.2 = import // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- import_conflict_reverse.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir1, inst+1, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//local_other, inst+1, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -646,16 +671,18 @@ import Other library "O1"; // CHECK:STDOUT: --- fail_import_conflict_reverse.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir0, inst+2, unloaded +// CHECK:STDOUT: %import_ref = import_ref Main//import_conflict_reverse, inst+2, unloaded +// CHECK:STDOUT: %Other: = namespace file.%Other.import, [template] { +// CHECK:STDOUT: import Other//O1 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Other = %Other +// CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %Other: = namespace %Other.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/unused_lazy_import.carbon b/toolchain/check/testdata/packages/unused_lazy_import.carbon index a54dffa69efdc..683299cd01cd7 100644 --- a/toolchain/check/testdata/packages/unused_lazy_import.carbon +++ b/toolchain/check/testdata/packages/unused_lazy_import.carbon @@ -26,13 +26,24 @@ impl package Implicit; // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -41,17 +52,25 @@ impl package Implicit; // CHECK:STDOUT: --- implicit.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref = import_ref ir0, inst+3, unloaded +// CHECK:STDOUT: %import_ref = import_ref Implicit//default, inst+3, unloaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = imports.%import_ref -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/address_of_deref.carbon b/toolchain/check/testdata/pointer/address_of_deref.carbon index 6f4ebc532bc63..6a97c5654f130 100644 --- a/toolchain/check/testdata/pointer/address_of_deref.carbon +++ b/toolchain/check/testdata/pointer/address_of_deref.carbon @@ -26,17 +26,25 @@ fn F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/pointer/address_of_lvalue.carbon b/toolchain/check/testdata/pointer/address_of_lvalue.carbon index 14dbb71e95c07..528f6d7b28f2d 100644 --- a/toolchain/check/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/check/testdata/pointer/address_of_lvalue.carbon @@ -16,8 +16,8 @@ fn F() { var r: i32* = &s.b; var t: (i32, i32) = (1, 2); - var t0: i32* = &t[0]; - var t1: i32* = &t[1]; + var t0: i32* = &t.0; + var t1: i32* = &t.1; } // CHECK:STDOUT: --- address_of_lvalue.carbon @@ -42,25 +42,25 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -146,8 +146,8 @@ fn F() { // CHECK:STDOUT: %t0: ref %.6 = bind_name t0, %t0.var // CHECK:STDOUT: %t.ref.loc19: ref %.8 = name_ref t, %t // CHECK:STDOUT: %.loc19_21: i32 = int_literal 0 [template = constants.%.10] -// CHECK:STDOUT: %.loc19_22: ref i32 = tuple_index %t.ref.loc19, %.loc19_21 -// CHECK:STDOUT: %.loc19_18: %.6 = addr_of %.loc19_22 +// CHECK:STDOUT: %.loc19_20: ref i32 = tuple_index %t.ref.loc19, %.loc19_21 +// CHECK:STDOUT: %.loc19_18: %.6 = addr_of %.loc19_20 // CHECK:STDOUT: assign %t0.var, %.loc19_18 // CHECK:STDOUT: %int.make_type_32.loc20: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc20_14.1: type = value_of_initializer %int.make_type_32.loc20 [template = i32] @@ -157,8 +157,8 @@ fn F() { // CHECK:STDOUT: %t1: ref %.6 = bind_name t1, %t1.var // CHECK:STDOUT: %t.ref.loc20: ref %.8 = name_ref t, %t // CHECK:STDOUT: %.loc20_21: i32 = int_literal 1 [template = constants.%.4] -// CHECK:STDOUT: %.loc20_22: ref i32 = tuple_index %t.ref.loc20, %.loc20_21 -// CHECK:STDOUT: %.loc20_18: %.6 = addr_of %.loc20_22 +// CHECK:STDOUT: %.loc20_20: ref i32 = tuple_index %t.ref.loc20, %.loc20_21 +// CHECK:STDOUT: %.loc20_18: %.6 = addr_of %.loc20_20 // CHECK:STDOUT: assign %t1.var, %.loc20_18 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/arrow.carbon b/toolchain/check/testdata/pointer/arrow.carbon index 303aa55aa48c2..74b761b929a23 100644 --- a/toolchain/check/testdata/pointer/arrow.carbon +++ b/toolchain/check/testdata/pointer/arrow.carbon @@ -38,14 +38,25 @@ fn Foo(ptr: C*) { // CHECK:STDOUT: %.5: type = ptr_type %.4 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .Foo = %Foo.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] { // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] diff --git a/toolchain/check/testdata/pointer/basic.carbon b/toolchain/check/testdata/pointer/basic.carbon index 0088b8d14452c..73592bf5ed1d4 100644 --- a/toolchain/check/testdata/pointer/basic.carbon +++ b/toolchain/check/testdata/pointer/basic.carbon @@ -28,18 +28,25 @@ fn F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/pointer/fail_address_of_error.carbon b/toolchain/check/testdata/pointer/fail_address_of_error.carbon index f50e856a42f90..a50900e75e1ad 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_error.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_error.carbon @@ -32,13 +32,24 @@ fn Test() { // CHECK:STDOUT: %Test: %Test.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Test = %Test.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [template = constants.%Test] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/fail_address_of_value.carbon b/toolchain/check/testdata/pointer/fail_address_of_value.carbon index 81cd7bdfaddb6..2ae8b952691d8 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_value.carbon @@ -86,10 +86,10 @@ fn AddressOfType() { fn AddressOfTupleElementValue() { // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: ERROR: Cannot take the address of non-reference expression. - // CHECK:STDERR: &((1, 2)[0]); + // CHECK:STDERR: &((1, 2).0); // CHECK:STDERR: ^ // CHECK:STDERR: - &((1, 2)[0]); + &((1, 2).0); } fn AddressOfParam(param: i32) { @@ -144,17 +144,22 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .H = %H.decl // CHECK:STDOUT: .AddressOfLiteral = %AddressOfLiteral.decl @@ -165,7 +170,6 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: .AddressOfParam = %AddressOfParam.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] @@ -273,7 +277,7 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: %.loc92_12: i32 = int_literal 0 [template = constants.%.3] // CHECK:STDOUT: %tuple: %.13 = tuple_value (%.loc92_6, %.loc92_9) [template = constants.%tuple] // CHECK:STDOUT: %.loc92_10.2: %.13 = converted %.loc92_10.1, %tuple [template = constants.%tuple] -// CHECK:STDOUT: %.loc92_13: i32 = tuple_index %.loc92_10.2, %.loc92_12 [template = constants.%.11] +// CHECK:STDOUT: %.loc92_11: i32 = tuple_index %.loc92_10.2, %.loc92_12 [template = constants.%.11] // CHECK:STDOUT: %.loc92_3: %.4 = addr_of [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/fail_deref_error.carbon b/toolchain/check/testdata/pointer/fail_deref_error.carbon index 9c055d341460d..07db2e23589ae 100644 --- a/toolchain/check/testdata/pointer/fail_deref_error.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_error.carbon @@ -27,18 +27,26 @@ let n2: i32 = undeclared->foo; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .n = @__global_init.%n // CHECK:STDOUT: .n2 = @__global_init.%n2 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32.loc15, %.loc15_8.1 [template = i32] diff --git a/toolchain/check/testdata/pointer/fail_deref_function.carbon b/toolchain/check/testdata/pointer/fail_deref_function.carbon index 02e0d9bcacdd1..53bb90f919400 100644 --- a/toolchain/check/testdata/pointer/fail_deref_function.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_function.carbon @@ -28,13 +28,24 @@ fn A() { // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/fail_deref_namespace.carbon b/toolchain/check/testdata/pointer/fail_deref_namespace.carbon index d8dbc638e9052..0264004f1587d 100644 --- a/toolchain/check/testdata/pointer/fail_deref_namespace.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_namespace.carbon @@ -30,14 +30,25 @@ fn F() { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A: = namespace [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/fail_deref_not_pointer.carbon b/toolchain/check/testdata/pointer/fail_deref_not_pointer.carbon index bd299e2c67413..4e530b8f21f27 100644 --- a/toolchain/check/testdata/pointer/fail_deref_not_pointer.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_not_pointer.carbon @@ -54,16 +54,25 @@ fn Deref(n: i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Deref = %Deref.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Deref.decl: %Deref.type = fn_decl @Deref [template = constants.%Deref] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/pointer/fail_deref_type.carbon b/toolchain/check/testdata/pointer/fail_deref_type.carbon index e9d0bf390bf03..720d6da66db8b 100644 --- a/toolchain/check/testdata/pointer/fail_deref_type.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_type.carbon @@ -30,18 +30,26 @@ var p2: i32->foo; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .p = %p // CHECK:STDOUT: .p2 = %p2 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc18: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc18_9.1: type = value_of_initializer %int.make_type_32.loc18 [template = i32] // CHECK:STDOUT: %.loc18_9.2: type = converted %int.make_type_32.loc18, %.loc18_9.1 [template = i32] diff --git a/toolchain/check/testdata/pointer/fail_type_mismatch.carbon b/toolchain/check/testdata/pointer/fail_type_mismatch.carbon index b08eddc88b791..4a798978bc91a 100644 --- a/toolchain/check/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/pointer/fail_type_mismatch.carbon @@ -28,13 +28,24 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: %ConstMismatch: %ConstMismatch.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .ConstMismatch = %ConstMismatch.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ConstMismatch.decl: %ConstMismatch.type = fn_decl @ConstMismatch [template = constants.%ConstMismatch] { // CHECK:STDOUT: %.loc11_28: %.1 = struct_literal () // CHECK:STDOUT: %.loc11_21.1: type = converted %.loc11_28, constants.%.1 [template = constants.%.1] diff --git a/toolchain/check/testdata/pointer/import.carbon b/toolchain/check/testdata/pointer/import.carbon index 5965473ae1dd3..8bc794218b428 100644 --- a/toolchain/check/testdata/pointer/import.carbon +++ b/toolchain/check/testdata/pointer/import.carbon @@ -32,18 +32,26 @@ var a: i32* = a_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a_orig = %a_orig // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_13.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_13.2: type = converted %int.make_type_32.loc4, %.loc4_13.1 [template = i32] @@ -79,22 +87,31 @@ var a: i32* = a_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+13, unloaded -// CHECK:STDOUT: %import_ref.2: ref %.2 = import_ref ir0, inst+24, loaded -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+13, unloaded +// CHECK:STDOUT: %import_ref.2: ref %.2 = import_ref Implicit//default, inst+23, loaded +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.3 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .a_orig = imports.%import_ref.1 // CHECK:STDOUT: .a_ref = imports.%import_ref.2 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_32, %.loc4_11.1 [template = i32] diff --git a/toolchain/check/testdata/pointer/nested_const.carbon b/toolchain/check/testdata/pointer/nested_const.carbon index b34437228f069..3a52777f5aaef 100644 --- a/toolchain/check/testdata/pointer/nested_const.carbon +++ b/toolchain/check/testdata/pointer/nested_const.carbon @@ -29,17 +29,25 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc12_29: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_23.1: type = value_of_initializer %int.make_type_32.loc12_29 [template = i32] diff --git a/toolchain/check/testdata/pointer/types.carbon b/toolchain/check/testdata/pointer/types.carbon index f0bc73a331c1f..eaf1c0adfe90b 100644 --- a/toolchain/check/testdata/pointer/types.carbon +++ b/toolchain/check/testdata/pointer/types.carbon @@ -32,20 +32,26 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Ptr = %Ptr.decl // CHECK:STDOUT: .ConstPtr = %ConstPtr.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Ptr.decl: %Ptr.type = fn_decl @Ptr [template = constants.%Ptr] { // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32] diff --git a/toolchain/check/testdata/return/code_after_return.carbon b/toolchain/check/testdata/return/code_after_return.carbon index eb7400a5677cc..0eb0bd98e0889 100644 --- a/toolchain/check/testdata/return/code_after_return.carbon +++ b/toolchain/check/testdata/return/code_after_return.carbon @@ -25,16 +25,25 @@ fn Main() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/code_after_return_value.carbon b/toolchain/check/testdata/return/code_after_return_value.carbon index c0a37a164a7f5..bbbdd21200b16 100644 --- a/toolchain/check/testdata/return/code_after_return_value.carbon +++ b/toolchain/check/testdata/return/code_after_return_value.carbon @@ -38,18 +38,27 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/return/fail_call_in_type.carbon b/toolchain/check/testdata/return/fail_call_in_type.carbon index 1737af69e256d..b80436de9d2de 100644 --- a/toolchain/check/testdata/return/fail_call_in_type.carbon +++ b/toolchain/check/testdata/return/fail_call_in_type.carbon @@ -30,17 +30,26 @@ fn Six() -> ReturnType() { return 6; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .ReturnType = %ReturnType.decl // CHECK:STDOUT: .Six = %Six.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %ReturnType.decl: %ReturnType.type = fn_decl @ReturnType [template = constants.%ReturnType] { // CHECK:STDOUT: @ReturnType.%return: ref type = var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/return/fail_error_in_type.carbon b/toolchain/check/testdata/return/fail_error_in_type.carbon index dcfb9bb854fe2..f8050fb91d289 100644 --- a/toolchain/check/testdata/return/fail_error_in_type.carbon +++ b/toolchain/check/testdata/return/fail_error_in_type.carbon @@ -21,13 +21,24 @@ fn Six() -> x; // CHECK:STDOUT: %Six: %Six.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Six = %Six.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Six.decl: %Six.type = fn_decl @Six [template = constants.%Six] { // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] // CHECK:STDOUT: @Six.%return: ref = var diff --git a/toolchain/check/testdata/return/fail_let_in_type.carbon b/toolchain/check/testdata/return/fail_let_in_type.carbon index f2f12489d50e9..3d39a037370b3 100644 --- a/toolchain/check/testdata/return/fail_let_in_type.carbon +++ b/toolchain/check/testdata/return/fail_let_in_type.carbon @@ -54,10 +54,19 @@ fn FirstPerfectNumber() -> z { return 6; } // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @HalfDozen() -> %y -// CHECK:STDOUT: generic [: type] { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc24: i32 = int_literal 6 [template = constants.%.2] -// CHECK:STDOUT: return +// CHECK:STDOUT: generic fn @HalfDozen(.inst+21.loc19_5: type) { +// CHECK:STDOUT: %y: type = bind_symbolic_name y 0 [symbolic = %y (constants.%y)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() -> @HalfDozen.%y (%y) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %.loc24: i32 = int_literal 6 [template = constants.%.2] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @HalfDozen(constants.%y) { +// CHECK:STDOUT: %y => constants.%y // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/fail_missing_return.carbon b/toolchain/check/testdata/return/fail_missing_return.carbon index f3287f3ee057b..734bcafa4d19d 100644 --- a/toolchain/check/testdata/return/fail_missing_return.carbon +++ b/toolchain/check/testdata/return/fail_missing_return.carbon @@ -25,16 +25,25 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon index 20c3b248a4110..3810a62c2e2be 100644 --- a/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/check/testdata/return/fail_missing_return_empty_tuple.carbon @@ -22,13 +22,24 @@ fn F() -> () { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %.loc11_12.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc11_12.2: type = converted %.loc11_12.1, constants.%.1 [template = constants.%.1] diff --git a/toolchain/check/testdata/return/fail_return_var_no_returned_var.carbon b/toolchain/check/testdata/return/fail_return_var_no_returned_var.carbon index 2febd00c7ebd9..c6dee1951a76a 100644 --- a/toolchain/check/testdata/return/fail_return_var_no_returned_var.carbon +++ b/toolchain/check/testdata/return/fail_return_var_no_returned_var.carbon @@ -26,16 +26,25 @@ fn Procedure() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Procedure = %Procedure.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Procedure.decl: %Procedure.type = fn_decl @Procedure [template = constants.%Procedure] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/fail_return_with_returned_var.carbon b/toolchain/check/testdata/return/fail_return_with_returned_var.carbon index 73901c612cafa..07084c63fd048 100644 --- a/toolchain/check/testdata/return/fail_return_with_returned_var.carbon +++ b/toolchain/check/testdata/return/fail_return_with_returned_var.carbon @@ -53,21 +53,27 @@ fn G() -> C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon b/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon index e398a1d962458..6be669b3a2777 100644 --- a/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon @@ -27,13 +27,24 @@ fn Procedure() { // CHECK:STDOUT: %Procedure: %Procedure.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Procedure = %Procedure.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Procedure.decl: %Procedure.type = fn_decl @Procedure [template = constants.%Procedure] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/fail_returned_var_shadow.carbon b/toolchain/check/testdata/return/fail_returned_var_shadow.carbon index 1d4fe0113105b..4dfb8213d8637 100644 --- a/toolchain/check/testdata/return/fail_returned_var_shadow.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_shadow.carbon @@ -55,22 +55,26 @@ fn DifferentScopes() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .SameScope = %SameScope.decl // CHECK:STDOUT: .DifferentScopes = %DifferentScopes.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %SameScope.decl: %SameScope.type = fn_decl @SameScope [template = constants.%SameScope] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/return/fail_returned_var_type.carbon b/toolchain/check/testdata/return/fail_returned_var_type.carbon index 268e2a6d8a108..4662a55f83760 100644 --- a/toolchain/check/testdata/return/fail_returned_var_type.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_type.carbon @@ -34,17 +34,27 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Mismatch = %Mismatch.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Mismatch.decl: %Mismatch.type = fn_decl @Mismatch [template = constants.%Mismatch] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_18.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/fail_type_mismatch.carbon b/toolchain/check/testdata/return/fail_type_mismatch.carbon index fd203ca7ce4b1..d79a0e6a5fd06 100644 --- a/toolchain/check/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/return/fail_type_mismatch.carbon @@ -27,16 +27,25 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/fail_value_disallowed.carbon b/toolchain/check/testdata/return/fail_value_disallowed.carbon index 64cdf62bfda36..1cce53d214cd0 100644 --- a/toolchain/check/testdata/return/fail_value_disallowed.carbon +++ b/toolchain/check/testdata/return/fail_value_disallowed.carbon @@ -27,13 +27,24 @@ fn Main() { // CHECK:STDOUT: %.2: i32 = int_literal 0 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/fail_value_missing.carbon b/toolchain/check/testdata/return/fail_value_missing.carbon index 4badb196fca86..e23ce23c07f0a 100644 --- a/toolchain/check/testdata/return/fail_value_missing.carbon +++ b/toolchain/check/testdata/return/fail_value_missing.carbon @@ -29,16 +29,25 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/fail_var_in_type.carbon b/toolchain/check/testdata/return/fail_var_in_type.carbon index 64a55ff67d517..9a8e44caebf83 100644 --- a/toolchain/check/testdata/return/fail_var_in_type.carbon +++ b/toolchain/check/testdata/return/fail_var_in_type.carbon @@ -26,17 +26,26 @@ fn Six() -> x { return 6; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .Six = %Six.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %x.var: ref type = var x // CHECK:STDOUT: %x: ref type = bind_name x, %x.var // CHECK:STDOUT: %Six.decl: %Six.type = fn_decl @Six [template = constants.%Six] { diff --git a/toolchain/check/testdata/return/missing_return_no_return_type.carbon b/toolchain/check/testdata/return/missing_return_no_return_type.carbon index 8a7641eb57373..b99c6d4bb11c9 100644 --- a/toolchain/check/testdata/return/missing_return_no_return_type.carbon +++ b/toolchain/check/testdata/return/missing_return_no_return_type.carbon @@ -19,13 +19,24 @@ fn F() { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/no_value.carbon b/toolchain/check/testdata/return/no_value.carbon index 87145c7f304cf..f5187f3315833 100644 --- a/toolchain/check/testdata/return/no_value.carbon +++ b/toolchain/check/testdata/return/no_value.carbon @@ -20,13 +20,24 @@ fn Main() { // CHECK:STDOUT: %Main: %Main.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/returned_var.carbon b/toolchain/check/testdata/return/returned_var.carbon index e29247ceb48ac..338ec916138e6 100644 --- a/toolchain/check/testdata/return/returned_var.carbon +++ b/toolchain/check/testdata/return/returned_var.carbon @@ -44,21 +44,27 @@ fn G() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] diff --git a/toolchain/check/testdata/return/returned_var_scope.carbon b/toolchain/check/testdata/return/returned_var_scope.carbon index d190ea4b0c3f2..a0ca6112f8cdf 100644 --- a/toolchain/check/testdata/return/returned_var_scope.carbon +++ b/toolchain/check/testdata/return/returned_var_scope.carbon @@ -45,23 +45,28 @@ fn EnclosingButAfter(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Bool = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .UnrelatedScopes = %UnrelatedScopes.decl // CHECK:STDOUT: .EnclosingButAfter = %EnclosingButAfter.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %UnrelatedScopes.decl: %UnrelatedScopes.type = fn_decl @UnrelatedScopes [template = constants.%UnrelatedScopes] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_25.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/return/struct.carbon b/toolchain/check/testdata/return/struct.carbon index 7ab96b74b0485..aad9a148b40fc 100644 --- a/toolchain/check/testdata/return/struct.carbon +++ b/toolchain/check/testdata/return/struct.carbon @@ -26,16 +26,25 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/return/tuple.carbon b/toolchain/check/testdata/return/tuple.carbon index fa21c5a2fa26f..de5759efccc4a 100644 --- a/toolchain/check/testdata/return/tuple.carbon +++ b/toolchain/check/testdata/return/tuple.carbon @@ -30,17 +30,25 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32.loc12_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc12_20: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/return/value.carbon b/toolchain/check/testdata/return/value.carbon index 3f1145ba47feb..4be41a549d133 100644 --- a/toolchain/check/testdata/return/value.carbon +++ b/toolchain/check/testdata/return/value.carbon @@ -24,16 +24,25 @@ fn Main() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_access_into_invalid.carbon b/toolchain/check/testdata/struct/fail_access_into_invalid.carbon index aa5af3a164423..c440e05a6f4de 100644 --- a/toolchain/check/testdata/struct/fail_access_into_invalid.carbon +++ b/toolchain/check/testdata/struct/fail_access_into_invalid.carbon @@ -22,13 +22,24 @@ fn F() { a.b; } // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_assign_empty.carbon b/toolchain/check/testdata/struct/fail_assign_empty.carbon index 3368ffea65b74..6e31d3923ea55 100644 --- a/toolchain/check/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/check/testdata/struct/fail_assign_empty.carbon @@ -24,16 +24,25 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32, %.loc14_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_assign_to_empty.carbon b/toolchain/check/testdata/struct/fail_assign_to_empty.carbon index 0fac43593eff6..7953534edf5fc 100644 --- a/toolchain/check/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/check/testdata/struct/fail_assign_to_empty.carbon @@ -22,13 +22,24 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: %.4: type = struct_type {.a: i32} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc14_9.1: %.1 = struct_literal () // CHECK:STDOUT: %.loc14_9.2: type = converted %.loc14_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %x.var: ref %.1 = var x diff --git a/toolchain/check/testdata/struct/fail_duplicate_name.carbon b/toolchain/check/testdata/struct/fail_duplicate_name.carbon index 1ab815c3b3505..b7e4d7b2c64f3 100644 --- a/toolchain/check/testdata/struct/fail_duplicate_name.carbon +++ b/toolchain/check/testdata/struct/fail_duplicate_name.carbon @@ -70,22 +70,22 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .v = @__global_init.%v // CHECK:STDOUT: .w = @__global_init.%w @@ -93,7 +93,6 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4}; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc18_16: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc18_16.1: type = value_of_initializer %int.make_type_32.loc18_16 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon index 096148da260d8..09e9c5c6723c3 100644 --- a/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon @@ -31,18 +31,26 @@ var y: {.b: i32} = x; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc15_13.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32] // CHECK:STDOUT: %.loc15_13.2: type = converted %int.make_type_32.loc15, %.loc15_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon index 74e2b7d5bffe6..003170422d3af 100644 --- a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon @@ -25,16 +25,25 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32, %.loc14_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_member_access_type.carbon b/toolchain/check/testdata/struct/fail_member_access_type.carbon index c9024a1a2041e..649febb481083 100644 --- a/toolchain/check/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/check/testdata/struct/fail_member_access_type.carbon @@ -29,18 +29,28 @@ var y: i32 = x.b; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc11_13.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%.loc11_13.1) [template = f64] // CHECK:STDOUT: %.loc11_13.2: type = value_of_initializer %float.make_type [template = f64] diff --git a/toolchain/check/testdata/struct/fail_member_of_function.carbon b/toolchain/check/testdata/struct/fail_member_of_function.carbon index 59be7d8b02ba0..d1360d4c3b59c 100644 --- a/toolchain/check/testdata/struct/fail_member_of_function.carbon +++ b/toolchain/check/testdata/struct/fail_member_of_function.carbon @@ -23,13 +23,24 @@ fn A() { // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_non_member_access.carbon b/toolchain/check/testdata/struct/fail_non_member_access.carbon index 49d6f4b58c6ad..18fc71284c1ed 100644 --- a/toolchain/check/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/check/testdata/struct/fail_non_member_access.carbon @@ -26,18 +26,26 @@ var y: i32 = x.b; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] // CHECK:STDOUT: %.loc11_13.2: type = converted %int.make_type_32.loc11, %.loc11_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_too_few_values.carbon b/toolchain/check/testdata/struct/fail_too_few_values.carbon index f25c01e4a2be3..fb10f1692e51e 100644 --- a/toolchain/check/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/check/testdata/struct/fail_too_few_values.carbon @@ -26,17 +26,25 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc14_13: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32.loc14_13 [template = i32] // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32.loc14_13, %.loc14_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_type_assign.carbon b/toolchain/check/testdata/struct/fail_type_assign.carbon index 306725ec81d25..0fbdda90ecc0d 100644 --- a/toolchain/check/testdata/struct/fail_type_assign.carbon +++ b/toolchain/check/testdata/struct/fail_type_assign.carbon @@ -23,17 +23,25 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32, %.loc14_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/fail_value_as_type.carbon b/toolchain/check/testdata/struct/fail_value_as_type.carbon index 8077b4d3546bc..af6b2b5b14e4d 100644 --- a/toolchain/check/testdata/struct/fail_value_as_type.carbon +++ b/toolchain/check/testdata/struct/fail_value_as_type.carbon @@ -20,13 +20,24 @@ var x: {.a = 1}; // CHECK:STDOUT: %.2: type = struct_type {.a: i32} [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc14_14: i32 = int_literal 1 [template = constants.%.1] // CHECK:STDOUT: %.loc14_15: %.2 = struct_literal (%.loc14_14) // CHECK:STDOUT: %x.var: ref = var x diff --git a/toolchain/check/testdata/struct/import.carbon b/toolchain/check/testdata/struct/import.carbon index 52115d83f901e..0f39e25334ee7 100644 --- a/toolchain/check/testdata/struct/import.carbon +++ b/toolchain/check/testdata/struct/import.carbon @@ -73,36 +73,40 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0 [symbolic] // CHECK:STDOUT: %C.type: type = generic_class_type @C [template] // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] -// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic] // CHECK:STDOUT: %.12: type = struct_type {} [template] // CHECK:STDOUT: %.13: i32 = int_literal 1 [template] // CHECK:STDOUT: %.14: i32 = int_literal 2 [template] // CHECK:STDOUT: %.15: type = ptr_type %.11 [template] // CHECK:STDOUT: %struct.4: %.11 = struct_value (%.13, %.14) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%struct.4) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct.4) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: .b_ref = %b_ref // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_17.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_17.2: type = converted %int.make_type_32.loc4, %.loc4_17.1 [template = i32] @@ -133,7 +137,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %.loc8_27.2: type = converted %int.make_type_32.loc8_27, %.loc8_27.1 [template = i32] // CHECK:STDOUT: %.loc8_30: type = struct_type {.a: i32, .b: i32} [template = constants.%.11] // CHECK:STDOUT: %S.loc8_9.1: %.11 = param S -// CHECK:STDOUT: %S.loc8_9.2: %.11 = bind_symbolic_name S 0, %S.loc8_9.1 [symbolic = %S.loc8_9.2 (constants.%S)] +// CHECK:STDOUT: %S.loc8_9.2: %.11 = bind_symbolic_name S 0, %S.loc8_9.1 [symbolic = @C.%S (constants.%S)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.1] @@ -149,10 +153,15 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C -// CHECK:STDOUT: generic [file.%S.loc8_9.2: %.11] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: generic class @C(file.%S.loc8_9.2: %.11) { +// CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0 [symbolic = %S (constants.%S)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -189,6 +198,14 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%S) { +// CHECK:STDOUT: %S => constants.%S +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%struct.4) { +// CHECK:STDOUT: %S => constants.%struct.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- implicit.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -207,28 +224,35 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] // CHECK:STDOUT: %.10: type = struct_type {} [template] // CHECK:STDOUT: %.11: type = struct_type {.a: i32, .b: i32} [template] -// CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0, [symbolic] -// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic] +// CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0 [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic] // CHECK:STDOUT: %.12: i32 = int_literal 1 [template] // CHECK:STDOUT: %.13: i32 = int_literal 2 [template] // CHECK:STDOUT: %.14: type = ptr_type %.11 [template] // CHECK:STDOUT: %struct: %.11 = struct_value (%.12, %.13) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%struct) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct) [template] // CHECK:STDOUT: %.15: type = ptr_type %.10 [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: ref %.2 = import_ref ir0, inst+17, loaded -// CHECK:STDOUT: %import_ref.2: ref %.6 = import_ref ir0, inst+60, loaded -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir0, inst+104, loaded [template = constants.%C.1] -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir0, inst+126, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9 = import_ref ir0, inst+107, unloaded +// CHECK:STDOUT: %import_ref.1: ref %.2 = import_ref Implicit//default, inst+17, loaded +// CHECK:STDOUT: %import_ref.2: ref %.6 = import_ref Implicit//default, inst+57, loaded +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+99, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+122, loaded [template = constants.%F] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.6 = import_ref Implicit//default, inst+103, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -237,7 +261,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .F = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c @@ -245,7 +269,6 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_13.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_13.2: type = converted %int.make_type_32.loc4, %.loc4_13.1 [template = i32] @@ -280,9 +303,15 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %c: ref %C.3 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.9 +// CHECK:STDOUT: generic class @C(constants.%S: %.11) { +// CHECK:STDOUT: %S: %.11 = bind_symbolic_name S 0 [symbolic = %S (constants.%S)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -327,6 +356,16 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%S) { +// CHECK:STDOUT: %S => constants.%S +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%struct) { +// CHECK:STDOUT: %S => constants.%struct +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_bad_type.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -335,25 +374,34 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template] -// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0, [symbolic] -// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic] +// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0 [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic] // CHECK:STDOUT: %.4: i32 = int_literal 1 [template] // CHECK:STDOUT: %.5: i32 = int_literal 2 [template] // CHECK:STDOUT: %.6: type = struct_type {.c: i32, .d: i32} [template] // CHECK:STDOUT: %.7: type = ptr_type %.3 [template] -// CHECK:STDOUT: %struct: %.3 = struct_value (%.4, %.5) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%struct) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %struct: %.3 = struct_value (%.4, %.5) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct) [template] // CHECK:STDOUT: %.8: type = ptr_type %.2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+17, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+60, unloaded -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir0, inst+104, loaded [template = constants.%C.1] -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir0, inst+126, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+107, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+57, unloaded +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+99, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+122, loaded [template = constants.%F] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+103, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -362,13 +410,12 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .F = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .c_bad = %c_bad // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1] // CHECK:STDOUT: %.loc13_20: i32 = int_literal 1 [template = constants.%.4] // CHECK:STDOUT: %.loc13_28: i32 = int_literal 2 [template = constants.%.5] @@ -380,9 +427,15 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %c_bad: ref = bind_name c_bad, %c_bad.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: generic class @C(constants.%S: %.3) { +// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0 [symbolic = %S (constants.%S)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %C.3; @@ -396,6 +449,16 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%S) { +// CHECK:STDOUT: %S => constants.%S +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%struct) { +// CHECK:STDOUT: %S => constants.%struct +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_bad_value.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -404,28 +467,37 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template] -// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0, [symbolic] -// CHECK:STDOUT: %C.2: type = class_type @C, (%S) [symbolic] +// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0 [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic] // CHECK:STDOUT: %.4: i32 = int_literal 3 [template] // CHECK:STDOUT: %.5: i32 = int_literal 4 [template] // CHECK:STDOUT: %.6: type = ptr_type %.3 [template] // CHECK:STDOUT: %struct.1: %.3 = struct_value (%.4, %.5) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%struct.1) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct.1) [template] // CHECK:STDOUT: %.7: type = ptr_type %.2 [template] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %.8: i32 = int_literal 2 [template] // CHECK:STDOUT: %.9: i32 = int_literal 1 [template] // CHECK:STDOUT: %struct.2: %.3 = struct_value (%.9, %.8) [template] -// CHECK:STDOUT: %C.4: type = class_type @C, (%struct.2) [template] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %C.4: type = class_type @C, @C(%struct.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+17, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+60, unloaded -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir0, inst+104, loaded [template = constants.%C.1] -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir0, inst+126, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+107, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+57, unloaded +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+99, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+122, loaded [template = constants.%F] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+103, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -434,13 +506,12 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .F = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .c_bad = %c_bad // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1] // CHECK:STDOUT: %.loc6_20: i32 = int_literal 3 [template = constants.%.4] // CHECK:STDOUT: %.loc6_28: i32 = int_literal 4 [template = constants.%.5] @@ -454,9 +525,15 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %c_bad: ref %C.3 = bind_name c_bad, %c_bad.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: generic class @C(constants.%S: %.3) { +// CHECK:STDOUT: %S: %.3 = bind_symbolic_name S 0 [symbolic = %S (constants.%S)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %C.4; @@ -470,3 +547,19 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%S) { +// CHECK:STDOUT: %S => constants.%S +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%struct.1) { +// CHECK:STDOUT: %S => constants.%struct.1 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%struct.2) { +// CHECK:STDOUT: %S => constants.%struct.2 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/literal_member_access.carbon b/toolchain/check/testdata/struct/literal_member_access.carbon index 6d73eabcb0590..686c9fcad72c6 100644 --- a/toolchain/check/testdata/struct/literal_member_access.carbon +++ b/toolchain/check/testdata/struct/literal_member_access.carbon @@ -34,20 +34,26 @@ fn F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %int.make_type_32.loc11_16: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_16.1: type = value_of_initializer %int.make_type_32.loc11_16 [template = i32] diff --git a/toolchain/check/testdata/struct/member_access.carbon b/toolchain/check/testdata/struct/member_access.carbon index 18a8face18dee..4bfbef9eed944 100644 --- a/toolchain/check/testdata/struct/member_access.carbon +++ b/toolchain/check/testdata/struct/member_access.carbon @@ -29,21 +29,29 @@ var z: i32 = y; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Float = %import_ref.1 +// CHECK:STDOUT: .Int32 = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] +// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: .z = %z // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc11_13.1: i32 = int_literal 64 [template = constants.%.1] // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%.loc11_13.1) [template = f64] // CHECK:STDOUT: %.loc11_13.2: type = value_of_initializer %float.make_type [template = f64] diff --git a/toolchain/check/testdata/struct/nested_struct_in_place.carbon b/toolchain/check/testdata/struct/nested_struct_in_place.carbon index b607a02db3f7a..f39ef07275950 100644 --- a/toolchain/check/testdata/struct/nested_struct_in_place.carbon +++ b/toolchain/check/testdata/struct/nested_struct_in_place.carbon @@ -33,25 +33,26 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_17: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/struct/one_entry.carbon b/toolchain/check/testdata/struct/one_entry.carbon index 9857135f6584a..ddd10ffd6efd4 100644 --- a/toolchain/check/testdata/struct/one_entry.carbon +++ b/toolchain/check/testdata/struct/one_entry.carbon @@ -23,18 +23,26 @@ var y: {.a: i32} = x; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] // CHECK:STDOUT: %.loc11_13.2: type = converted %int.make_type_32.loc11, %.loc11_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/reorder_fields.carbon b/toolchain/check/testdata/struct/reorder_fields.carbon index b841de8640054..a8f48749d9b51 100644 --- a/toolchain/check/testdata/struct/reorder_fields.carbon +++ b/toolchain/check/testdata/struct/reorder_fields.carbon @@ -39,25 +39,29 @@ fn F() -> {.a: i32, .b: f64} { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+32, loaded [template = constants.%Float] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.1 +// CHECK:STDOUT: .Float = %import_ref.2 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+32, loaded [template = constants.%Float] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .MakeI32 = %MakeI32.decl // CHECK:STDOUT: .MakeF64 = %MakeF64.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %MakeI32.decl: %MakeI32.type = fn_decl @MakeI32 [template = constants.%MakeI32] { // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/struct/tuple_as_element.carbon b/toolchain/check/testdata/struct/tuple_as_element.carbon index d408154c1f54a..92d9d45d1c142 100644 --- a/toolchain/check/testdata/struct/tuple_as_element.carbon +++ b/toolchain/check/testdata/struct/tuple_as_element.carbon @@ -28,20 +28,26 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_13: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32.loc11_13 [template = i32] // CHECK:STDOUT: %.loc11_13.2: type = converted %int.make_type_32.loc11_13, %.loc11_13.1 [template = i32] diff --git a/toolchain/check/testdata/struct/two_entries.carbon b/toolchain/check/testdata/struct/two_entries.carbon index aa719a4630b0a..ef19437c9167b 100644 --- a/toolchain/check/testdata/struct/two_entries.carbon +++ b/toolchain/check/testdata/struct/two_entries.carbon @@ -28,26 +28,28 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .v = @__global_init.%v // CHECK:STDOUT: .w = @__global_init.%w // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_13: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32.loc11_13 [template = i32] // CHECK:STDOUT: %.loc11_13.2: type = converted %int.make_type_32.loc11_13, %.loc11_13.1 [template = i32] diff --git a/toolchain/check/testdata/tuples/fail_assign_nested.carbon b/toolchain/check/testdata/tuples/fail_assign_nested.carbon index 5f80fc97b5edc..8d3349150b13e 100644 --- a/toolchain/check/testdata/tuples/fail_assign_nested.carbon +++ b/toolchain/check/testdata/tuples/fail_assign_nested.carbon @@ -37,19 +37,25 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc14_10: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc14_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_18: %.2 = tuple_literal (%int.make_type_32.loc14_10, %int.make_type_32.loc14_15) diff --git a/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon index 512df2e3248b0..d970315ef8d71 100644 --- a/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/check/testdata/tuples/fail_element_type_mismatch.carbon @@ -28,17 +28,25 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc14_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc14_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%int.make_type_32.loc14_9, %int.make_type_32.loc14_14) diff --git a/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon b/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon index 5bad927bf889a..5f7cfe6fe62ef 100644 --- a/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon +++ b/toolchain/check/testdata/tuples/fail_nested_incomplete.carbon @@ -34,18 +34,27 @@ var p: Incomplete* = &t[1]; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Incomplete = %Incomplete.decl // CHECK:STDOUT: .t = %t // CHECK:STDOUT: .p = %p // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %Incomplete.ref.loc19: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] diff --git a/toolchain/check/testdata/tuples/fail_too_few_element.carbon b/toolchain/check/testdata/tuples/fail_too_few_element.carbon index 7419cc469434e..34c11630c2214 100644 --- a/toolchain/check/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/check/testdata/tuples/fail_too_few_element.carbon @@ -27,17 +27,25 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc14_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc14_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%int.make_type_32.loc14_9, %int.make_type_32.loc14_14) diff --git a/toolchain/check/testdata/tuples/fail_type_assign.carbon b/toolchain/check/testdata/tuples/fail_type_assign.carbon index fff78385f553b..c5cce186534e8 100644 --- a/toolchain/check/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/check/testdata/tuples/fail_type_assign.carbon @@ -24,17 +24,25 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_14.1: %.2 = tuple_literal (%int.make_type_32) // CHECK:STDOUT: %.loc14_14.2: type = value_of_initializer %int.make_type_32 [template = i32] diff --git a/toolchain/check/testdata/tuples/fail_value_as_type.carbon b/toolchain/check/testdata/tuples/fail_value_as_type.carbon index 16ea1e9ce8260..ab18061107f79 100644 --- a/toolchain/check/testdata/tuples/fail_value_as_type.carbon +++ b/toolchain/check/testdata/tuples/fail_value_as_type.carbon @@ -20,13 +20,24 @@ var x: (1, ); // CHECK:STDOUT: %.2: type = tuple_type (i32) [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc14_9: i32 = int_literal 1 [template = constants.%.1] // CHECK:STDOUT: %.loc14_12: %.2 = tuple_literal (%.loc14_9) // CHECK:STDOUT: %x.var: ref = var x diff --git a/toolchain/check/testdata/tuples/import.carbon b/toolchain/check/testdata/tuples/import.carbon index d00aa3a782f51..db4aa38517017 100644 --- a/toolchain/check/testdata/tuples/import.carbon +++ b/toolchain/check/testdata/tuples/import.carbon @@ -81,34 +81,37 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %X: %.9 = bind_symbolic_name X 0 [symbolic] // CHECK:STDOUT: %C.type: type = generic_class_type @C [template] // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] -// CHECK:STDOUT: %C.2: type = class_type @C, (%X) [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic] // CHECK:STDOUT: %.18: type = struct_type {} [template] // CHECK:STDOUT: %tuple.5: %.9 = tuple_value (%.15, %.16) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%tuple.5) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple.5) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: .b_ref = %b_ref // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_17.1: %.2 = tuple_literal (%int.make_type_32.loc4) // CHECK:STDOUT: %.loc4_17.2: type = value_of_initializer %int.make_type_32.loc4 [template = i32] @@ -148,7 +151,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %.loc7_22.5: type = converted %int.make_type_32.loc7_19, %.loc7_22.4 [template = i32] // CHECK:STDOUT: %.loc7_22.6: type = converted %.loc7_22.1, constants.%.9 [template = constants.%.9] // CHECK:STDOUT: %X.loc7_9.1: %.9 = param X -// CHECK:STDOUT: %X.loc7_9.2: %.9 = bind_symbolic_name X 0, %X.loc7_9.1 [symbolic = %X.loc7_9.2 (constants.%X)] +// CHECK:STDOUT: %X.loc7_9.2: %.9 = bind_symbolic_name X 0, %X.loc7_9.1 [symbolic = @C.%X (constants.%X)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.1] @@ -164,10 +167,15 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C -// CHECK:STDOUT: generic [file.%X.loc7_9.2: %.9] { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: generic class @C(file.%X.loc7_9.2: %.9) { +// CHECK:STDOUT: %X: %.9 = bind_symbolic_name X 0 [symbolic = %X (constants.%X)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -211,6 +219,14 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%X) { +// CHECK:STDOUT: %X => constants.%X +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%tuple.5) { +// CHECK:STDOUT: %X => constants.%tuple.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- implicit.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -232,28 +248,34 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %C.type: type = generic_class_type @C [template] // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] // CHECK:STDOUT: %.14: type = struct_type {} [template] -// CHECK:STDOUT: %X: %.8 = bind_symbolic_name X 0, [symbolic] -// CHECK:STDOUT: %C.2: type = class_type @C, (%X) [symbolic] +// CHECK:STDOUT: %X: %.8 = bind_symbolic_name X 0 [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic] // CHECK:STDOUT: %.15: i32 = int_literal 1 [template] // CHECK:STDOUT: %.16: i32 = int_literal 2 [template] // CHECK:STDOUT: %tuple: %.8 = tuple_value (%.15, %.16) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%tuple) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple) [template] // CHECK:STDOUT: %.17: type = ptr_type %.14 [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: ref %.3 = import_ref ir0, inst+17, loaded -// CHECK:STDOUT: %import_ref.2: ref %.9 = import_ref ir0, inst+61, loaded -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir0, inst+109, loaded [template = constants.%C.1] -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir0, inst+126, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10 = import_ref ir0, inst+112, unloaded +// CHECK:STDOUT: %import_ref.1: ref %.3 = import_ref Implicit//default, inst+17, loaded +// CHECK:STDOUT: %import_ref.2: ref %.9 = import_ref Implicit//default, inst+57, loaded +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+103, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+121, loaded [template = constants.%F] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref.5 +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %import_ref.6 = import_ref Implicit//default, inst+107, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -262,7 +284,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .F = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c @@ -270,7 +292,6 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_13.1: %.2 = tuple_literal (%int.make_type_32.loc4) // CHECK:STDOUT: %.loc4_13.2: type = value_of_initializer %int.make_type_32.loc4 [template = i32] @@ -313,9 +334,15 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %c: ref %C.3 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.10 +// CHECK:STDOUT: generic class @C(constants.%X: %.8) { +// CHECK:STDOUT: %X: %.8 = bind_symbolic_name X 0 [symbolic = %X (constants.%X)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; @@ -368,6 +395,16 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%X) { +// CHECK:STDOUT: %X => constants.%X +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%tuple) { +// CHECK:STDOUT: %X => constants.%tuple +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_bad_type.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -376,26 +413,35 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template] -// CHECK:STDOUT: %X: %.3 = bind_symbolic_name X 0, [symbolic] -// CHECK:STDOUT: %C.2: type = class_type @C, (%X) [symbolic] +// CHECK:STDOUT: %X: %.3 = bind_symbolic_name X 0 [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic] // CHECK:STDOUT: %.4: i32 = int_literal 1 [template] // CHECK:STDOUT: %.5: i32 = int_literal 2 [template] // CHECK:STDOUT: %.6: i32 = int_literal 3 [template] // CHECK:STDOUT: %.7: type = tuple_type (i32, i32, i32) [template] // CHECK:STDOUT: %.8: type = ptr_type %.3 [template] -// CHECK:STDOUT: %tuple: %.3 = tuple_value (%.4, %.5) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%tuple) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %tuple: %.3 = tuple_value (%.4, %.5) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple) [template] // CHECK:STDOUT: %.9: type = ptr_type %.2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+17, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+61, unloaded -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir0, inst+109, loaded [template = constants.%C.1] -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir0, inst+126, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+112, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+57, unloaded +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+103, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+121, loaded [template = constants.%F] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+107, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -404,13 +450,12 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .F = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .c_bad = %c_bad // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1] // CHECK:STDOUT: %.loc14_15: i32 = int_literal 1 [template = constants.%.4] // CHECK:STDOUT: %.loc14_18: i32 = int_literal 2 [template = constants.%.5] @@ -423,9 +468,15 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %c_bad: ref = bind_name c_bad, %c_bad.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: generic class @C(constants.%X: %.3) { +// CHECK:STDOUT: %X: %.3 = bind_symbolic_name X 0 [symbolic = %X (constants.%X)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %C.3; @@ -439,6 +490,16 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%X) { +// CHECK:STDOUT: %X => constants.%X +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%tuple) { +// CHECK:STDOUT: %X => constants.%tuple +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_bad_value.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -447,28 +508,37 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %C.1: %C.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {} [template] // CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template] -// CHECK:STDOUT: %X: %.3 = bind_symbolic_name X 0, [symbolic] -// CHECK:STDOUT: %C.2: type = class_type @C, (%X) [symbolic] +// CHECK:STDOUT: %X: %.3 = bind_symbolic_name X 0 [symbolic] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic] // CHECK:STDOUT: %.4: i32 = int_literal 3 [template] // CHECK:STDOUT: %.5: i32 = int_literal 4 [template] // CHECK:STDOUT: %.6: type = ptr_type %.3 [template] // CHECK:STDOUT: %tuple.1: %.3 = tuple_value (%.4, %.5) [template] -// CHECK:STDOUT: %C.3: type = class_type @C, (%tuple.1) [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple.1) [template] // CHECK:STDOUT: %.7: type = ptr_type %.2 [template] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %.8: i32 = int_literal 2 [template] // CHECK:STDOUT: %.9: i32 = int_literal 1 [template] // CHECK:STDOUT: %tuple.2: %.3 = tuple_value (%.9, %.8) [template] -// CHECK:STDOUT: %C.4: type = class_type @C, (%tuple.2) [template] -// CHECK:STDOUT: %F.type: type = fn_type @F [template] -// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %C.4: type = class_type @C, @C(%tuple.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1 = import_ref ir0, inst+17, unloaded -// CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+61, unloaded -// CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir0, inst+109, loaded [template = constants.%C.1] -// CHECK:STDOUT: %import_ref.4: %F.type = import_ref ir0, inst+126, loaded [template = constants.%F] -// CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+112, unloaded +// CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded +// CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+57, unloaded +// CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+103, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+121, loaded [template = constants.%F] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+107, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -477,13 +547,12 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: .b_ref = imports.%import_ref.2 // CHECK:STDOUT: .C = imports.%import_ref.3 // CHECK:STDOUT: .F = imports.%import_ref.4 -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .c_bad = %c_bad // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1] // CHECK:STDOUT: %.loc7_15: i32 = int_literal 3 [template = constants.%.4] // CHECK:STDOUT: %.loc7_18: i32 = int_literal 4 [template = constants.%.5] @@ -497,9 +566,15 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %c_bad: ref %C.3 = bind_name c_bad, %c_bad.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: generic class @C(constants.%X: %.3) { +// CHECK:STDOUT: %X: %.3 = bind_symbolic_name X 0 [symbolic = %X (constants.%X)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %C.4; @@ -513,3 +588,19 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%X) { +// CHECK:STDOUT: %X => constants.%X +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%tuple.1) { +// CHECK:STDOUT: %X => constants.%tuple.1 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%tuple.2) { +// CHECK:STDOUT: %X => constants.%tuple.2 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuples/nested_tuple.carbon b/toolchain/check/testdata/tuples/nested_tuple.carbon index 6e7f27eb2d79c..f7217da82ffa8 100644 --- a/toolchain/check/testdata/tuples/nested_tuple.carbon +++ b/toolchain/check/testdata/tuples/nested_tuple.carbon @@ -31,18 +31,25 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_10: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_15: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_18: %.2 = tuple_literal (%int.make_type_32.loc11_10, %int.make_type_32.loc11_15) diff --git a/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon b/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon index f06c1993c1eee..b71074e59c734 100644 --- a/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon +++ b/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon @@ -46,31 +46,27 @@ fn H() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.9: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.10: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.11: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.13: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.14: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: .H = %H.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %int.make_type_32.loc11_12: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_17: init type = call constants.%Int32() [template = i32] diff --git a/toolchain/check/testdata/tuples/one_element.carbon b/toolchain/check/testdata/tuples/one_element.carbon index a6152380f4361..ab0f0a1702d89 100644 --- a/toolchain/check/testdata/tuples/one_element.carbon +++ b/toolchain/check/testdata/tuples/one_element.carbon @@ -24,18 +24,26 @@ var y: (i32,) = x; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_13.1: %.2 = tuple_literal (%int.make_type_32.loc11) // CHECK:STDOUT: %.loc11_13.2: type = value_of_initializer %int.make_type_32.loc11 [template = i32] diff --git a/toolchain/check/testdata/tuples/two_elements.carbon b/toolchain/check/testdata/tuples/two_elements.carbon index 511d7ef4bfc57..4e8fc2b6ad0bb 100644 --- a/toolchain/check/testdata/tuples/two_elements.carbon +++ b/toolchain/check/testdata/tuples/two_elements.carbon @@ -29,26 +29,28 @@ var y: (i32, i32) = x; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] -// CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir3, inst+4, loaded [template = constants.%Int32] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Int32 = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .v = @__global_init.%v // CHECK:STDOUT: .w = @__global_init.%w // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %int.make_type_32.loc11_9: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %int.make_type_32.loc11_14: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_17.1: %.2 = tuple_literal (%int.make_type_32.loc11_9, %int.make_type_32.loc11_14) diff --git a/toolchain/check/testdata/var/fail_not_copyable.carbon b/toolchain/check/testdata/var/fail_not_copyable.carbon index caec918f477dc..c75be81068108 100644 --- a/toolchain/check/testdata/var/fail_not_copyable.carbon +++ b/toolchain/check/testdata/var/fail_not_copyable.carbon @@ -40,14 +40,25 @@ fn F(x: X) { // CHECK:STDOUT: %.5: String = string_literal "hello" [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .X = %X.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %X.ref: type = name_ref X, %X.decl [template = constants.%X] diff --git a/toolchain/check/testdata/var/fail_storage_is_literal.carbon b/toolchain/check/testdata/var/fail_storage_is_literal.carbon index b01a5d2322dbb..2cbf5b2528f1a 100644 --- a/toolchain/check/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/check/testdata/var/fail_storage_is_literal.carbon @@ -24,13 +24,24 @@ fn Main() { // CHECK:STDOUT: %.2: i32 = int_literal 1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon b/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon index 7a617f3172687..a236905c7682a 100644 --- a/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon +++ b/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon @@ -67,20 +67,28 @@ var y2: bool = false or true; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .x2 = %x2 // CHECK:STDOUT: .y = %y // CHECK:STDOUT: .y2 = %y2 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.loc23_9.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc23_9.2: type = converted %.loc23_9.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %x.var: ref %.1 = var x diff --git a/toolchain/check/testdata/var/no_prelude/export_name.carbon b/toolchain/check/testdata/var/no_prelude/export_name.carbon index dbebcd99f26e4..c11b292cfbfc9 100644 --- a/toolchain/check/testdata/var/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/var/no_prelude/export_name.carbon @@ -70,7 +70,7 @@ var w: () = v; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: ref %.1 = import_ref ir1, inst+5, loaded +// CHECK:STDOUT: %import_ref: ref %.1 = import_ref Main//base, inst+5, loaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -89,7 +89,7 @@ var w: () = v; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: ref %.1 = import_ref ir1, inst+4, loaded [template = ] +// CHECK:STDOUT: %import_ref: ref %.1 = import_ref Main//export, inst+4, loaded [template = ] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/var/no_prelude/import.carbon b/toolchain/check/testdata/var/no_prelude/import.carbon index 476f082f27528..49d8c78941fd8 100644 --- a/toolchain/check/testdata/var/no_prelude/import.carbon +++ b/toolchain/check/testdata/var/no_prelude/import.carbon @@ -54,7 +54,7 @@ var a: () = a_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: ref %.1 = import_ref ir0, inst+5, loaded +// CHECK:STDOUT: %import_ref: ref %.1 = import_ref Implicit//default, inst+5, loaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/var/no_prelude/import_access.carbon b/toolchain/check/testdata/var/no_prelude/import_access.carbon index 7dbef8602136d..714b3ab43027a 100644 --- a/toolchain/check/testdata/var/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/var/no_prelude/import_access.carbon @@ -85,7 +85,7 @@ var v2: () = Test.v; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: ref %.1 = import_ref ir0, inst+5, loaded +// CHECK:STDOUT: %import_ref: ref %.1 = import_ref Test//def, inst+5, loaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -140,13 +140,18 @@ var v2: () = Test.v; // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Test: = namespace file.%Test.import, [template] { +// CHECK:STDOUT: import Test//def +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Test = %Test +// CHECK:STDOUT: .Test = imports.%Test // CHECK:STDOUT: .v2 = %v2 // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test -// CHECK:STDOUT: %Test: = namespace %Test.import, [template] {} // CHECK:STDOUT: %.loc9_10.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc9_10.2: type = converted %.loc9_10.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %v2.var: ref %.1 = var v2 @@ -155,7 +160,7 @@ var v2: () = Test.v; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Test.ref: = name_ref Test, file.%Test [template = file.%Test] +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %v.ref: = name_ref v, [template = ] // CHECK:STDOUT: assign file.%v2.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/while/break_continue.carbon b/toolchain/check/testdata/while/break_continue.carbon index 8792d7cce09c2..753362b55993c 100644 --- a/toolchain/check/testdata/while/break_continue.carbon +++ b/toolchain/check/testdata/while/break_continue.carbon @@ -57,19 +57,22 @@ fn While() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.3: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.4: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.5: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] -// CHECK:STDOUT: %import_ref.8: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl @@ -81,7 +84,6 @@ fn While() { // CHECK:STDOUT: .While = %While.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] { // CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type.loc11 [template = bool] diff --git a/toolchain/check/testdata/while/fail_bad_condition.carbon b/toolchain/check/testdata/while/fail_bad_condition.carbon index 315a8d0184428..1d4307aa95edf 100644 --- a/toolchain/check/testdata/while/fail_bad_condition.carbon +++ b/toolchain/check/testdata/while/fail_bad_condition.carbon @@ -25,13 +25,24 @@ fn While() { // CHECK:STDOUT: %.3: String = string_literal "Hello" [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .While = %While.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %While.decl: %While.type = fn_decl @While [template = constants.%While] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/while/fail_break_continue.carbon b/toolchain/check/testdata/while/fail_break_continue.carbon index 8cf3a720cfc21..28f34b1210177 100644 --- a/toolchain/check/testdata/while/fail_break_continue.carbon +++ b/toolchain/check/testdata/while/fail_break_continue.carbon @@ -43,13 +43,24 @@ fn While() { // CHECK:STDOUT: %.2: bool = bool_literal false [template] // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .While = %While.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %While.decl: %While.type = fn_decl @While [template = constants.%While] {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/while/unreachable_end.carbon b/toolchain/check/testdata/while/unreachable_end.carbon index fb77646345b3a..fa97597b962bb 100644 --- a/toolchain/check/testdata/while/unreachable_end.carbon +++ b/toolchain/check/testdata/while/unreachable_end.carbon @@ -42,12 +42,22 @@ fn While() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Cond = %Cond.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl @@ -55,7 +65,6 @@ fn While() { // CHECK:STDOUT: .While = %While.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Cond.decl: %Cond.type = fn_decl @Cond [template = constants.%Cond] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/check/testdata/while/while.carbon b/toolchain/check/testdata/while/while.carbon index d0e1364178b6d..1981a1f3a95cd 100644 --- a/toolchain/check/testdata/while/while.carbon +++ b/toolchain/check/testdata/while/while.carbon @@ -41,12 +41,22 @@ fn While() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool] +// CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .Bool = %import_ref +// CHECK:STDOUT: import Core//prelude +// CHECK:STDOUT: import Core//prelude/operators +// CHECK:STDOUT: import Core//prelude/types +// CHECK:STDOUT: import Core//prelude/operators/arithmetic +// CHECK:STDOUT: import Core//prelude/operators/bitwise +// CHECK:STDOUT: import Core//prelude/operators/comparison +// CHECK:STDOUT: import Core//prelude/types/bool +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .Core = %Core +// CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Cond = %Cond.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl @@ -54,7 +64,6 @@ fn While() { // CHECK:STDOUT: .While = %While.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Cond.decl: %Cond.type = fn_decl @Cond [template = constants.%Cond] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc11_14.1: type = value_of_initializer %bool.make_type [template = bool] diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index 7e021ba9584eb..7e7f934a6e172 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -37,7 +37,6 @@ CARBON_DIAGNOSTIC_KIND(HexadecimalEscapeMissingDigits) CARBON_DIAGNOSTIC_KIND(InvalidDigit) CARBON_DIAGNOSTIC_KIND(InvalidDigitSeparator) CARBON_DIAGNOSTIC_KIND(InvalidHorizontalWhitespaceInString) -CARBON_DIAGNOSTIC_KIND(IrregularDigitSeparators) CARBON_DIAGNOSTIC_KIND(MismatchedIndentInString) CARBON_DIAGNOSTIC_KIND(MultiLineStringWithDoubleQuotes) CARBON_DIAGNOSTIC_KIND(NoWhitespaceAfterCommentIntroducer) @@ -166,6 +165,8 @@ CARBON_DIAGNOSTIC_KIND(RedeclParamCountDiffers) CARBON_DIAGNOSTIC_KIND(RedeclParamCountPrevious) CARBON_DIAGNOSTIC_KIND(RedeclParamDiffers) CARBON_DIAGNOSTIC_KIND(RedeclParamPrevious) +CARBON_DIAGNOSTIC_KIND(RedeclParamSyntaxDiffers) +CARBON_DIAGNOSTIC_KIND(RedeclParamSyntaxPrevious) // Function call checking. CARBON_DIAGNOSTIC_KIND(AddrSelfIsNonRef) @@ -203,6 +204,11 @@ CARBON_DIAGNOSTIC_KIND(ClassSpecificDeclRepeated) CARBON_DIAGNOSTIC_KIND(ClassIncompleteWithinDefinition) CARBON_DIAGNOSTIC_KIND(ConstructionOfAbstractClass) +// Deduction. +CARBON_DIAGNOSTIC_KIND(DeductionIncomplete) +CARBON_DIAGNOSTIC_KIND(DeductionInconsistent) +CARBON_DIAGNOSTIC_KIND(DeductionGenericHere) + // Export checking. CARBON_DIAGNOSTIC_KIND(ExportNotImportedEntity) CARBON_DIAGNOSTIC_KIND(ExportNotImportedEntitySource) @@ -299,6 +305,7 @@ CARBON_DIAGNOSTIC_KIND(StructNameDuplicate) CARBON_DIAGNOSTIC_KIND(StructNamePrevious) CARBON_DIAGNOSTIC_KIND(TupleIndexNotConstant) CARBON_DIAGNOSTIC_KIND(TupleIndexOutOfBounds) +CARBON_DIAGNOSTIC_KIND(TupleIndexOnANonTupleType) CARBON_DIAGNOSTIC_KIND(TupleInitElementCountMismatch) CARBON_DIAGNOSTIC_KIND(ReturnedVarHere) CARBON_DIAGNOSTIC_KIND(ReturnedVarShadowed) diff --git a/toolchain/driver/BUILD b/toolchain/driver/BUILD index 1a5f4a760eb0c..13e0612250264 100644 --- a/toolchain/driver/BUILD +++ b/toolchain/driver/BUILD @@ -74,6 +74,7 @@ cc_library( "//toolchain/lex", "//toolchain/lower", "//toolchain/parse", + "//toolchain/parse:tree", "//toolchain/sem_ir:file", "//toolchain/sem_ir:formatter", "//toolchain/sem_ir:inst_namer", diff --git a/toolchain/driver/driver.cpp b/toolchain/driver/driver.cpp index 41fd4f7e71971..cd388b062c14b 100644 --- a/toolchain/driver/driver.cpp +++ b/toolchain/driver/driver.cpp @@ -27,6 +27,7 @@ #include "toolchain/lex/lex.h" #include "toolchain/lower/lower.h" #include "toolchain/parse/parse.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/sem_ir/formatter.h" #include "toolchain/sem_ir/inst_namer.h" #include "toolchain/source/source_buffer.h" @@ -308,6 +309,14 @@ Dump the generated assembly to stdout after codegen. )""", }, [&](auto& arg_b) { arg_b.Set(&dump_asm); }); + b.AddFlag( + { + .name = "dump-mem-usage", + .help = R"""( +Dumps the amount of memory used. +)""", + }, + [&](auto& arg_b) { arg_b.Set(&dump_mem_usage); }); b.AddFlag( { .name = "prelude-import", @@ -344,6 +353,7 @@ Excludes files with the given prefix from dumps. bool dump_sem_ir = false; bool dump_llvm_ir = false; bool dump_asm = false; + bool dump_mem_usage = false; bool stream_errors = false; bool preorder_parse_tree = false; bool builtin_sem_ir = false; @@ -540,6 +550,9 @@ class Driver::CompilationUnit { sorting_consumer_ = SortingDiagnosticConsumer(*consumer); consumer_ = &*sorting_consumer_; } + if (options_.dump_mem_usage && IncludeInDumps()) { + mem_usage_ = MemUsage(); + } } // Loads source and lexes it. Returns true on success. @@ -552,6 +565,10 @@ class Driver::CompilationUnit { *consumer_); } }); + if (mem_usage_) { + mem_usage_->Add("source_", source_->text().size(), + source_->text().size()); + } if (!source_) { success_ = false; return; @@ -565,6 +582,9 @@ class Driver::CompilationUnit { consumer_->Flush(); driver_->output_stream_ << tokens_; } + if (mem_usage_) { + mem_usage_->Collect("tokens_", *tokens_); + } CARBON_VLOG() << "*** Lex::TokenizedBuffer ***\n" << tokens_; if (tokens_->has_errors()) { success_ = false; @@ -580,7 +600,15 @@ class Driver::CompilationUnit { }); if (options_.dump_parse_tree && IncludeInDumps()) { consumer_->Flush(); - parse_tree_->Print(driver_->output_stream_, options_.preorder_parse_tree); + const auto& tree_and_subtrees = GetParseTreeAndSubtrees(); + if (options_.preorder_parse_tree) { + tree_and_subtrees.PrintPreorder(driver_->output_stream_); + } else { + tree_and_subtrees.Print(driver_->output_stream_); + } + } + if (mem_usage_) { + mem_usage_->Collect("parse_tree_", *parse_tree_); } CARBON_VLOG() << "*** Parse::Tree ***\n" << parse_tree_; if (parse_tree_->has_errors()) { @@ -591,11 +619,15 @@ class Driver::CompilationUnit { // Returns information needed to check this unit. auto GetCheckUnit() -> Check::Unit { CARBON_CHECK(parse_tree_); - return {.value_stores = &value_stores_, - .tokens = &*tokens_, - .parse_tree = &*parse_tree_, - .consumer = consumer_, - .sem_ir = &sem_ir_}; + return { + .value_stores = &value_stores_, + .tokens = &*tokens_, + .parse_tree = &*parse_tree_, + .consumer = consumer_, + .get_parse_tree_and_subtrees = [&]() -> const Parse::TreeAndSubtrees& { + return GetParseTreeAndSubtrees(); + }, + .sem_ir = &sem_ir_}; } // Runs post-check logic. Returns true if checking succeeded for the IR. @@ -607,21 +639,28 @@ class Driver::CompilationUnit { // to wait for code generation. consumer_->Flush(); - CARBON_VLOG() << "*** Raw SemIR::File ***\n" << *sem_ir_ << "\n"; + if (mem_usage_) { + mem_usage_->Collect("sem_ir_", *sem_ir_); + } + if (options_.dump_raw_sem_ir && IncludeInDumps()) { + CARBON_VLOG() << "*** Raw SemIR::File ***\n" << *sem_ir_ << "\n"; sem_ir_->Print(driver_->output_stream_, options_.builtin_sem_ir); if (options_.dump_sem_ir) { driver_->output_stream_ << "\n"; } } - if (vlog_stream_) { - CARBON_VLOG() << "*** SemIR::File ***\n"; - SemIR::FormatFile(*tokens_, *parse_tree_, *sem_ir_, *vlog_stream_); - } - if (options_.dump_sem_ir && IncludeInDumps()) { - SemIR::FormatFile(*tokens_, *parse_tree_, *sem_ir_, - driver_->output_stream_); + bool print = options_.dump_sem_ir && IncludeInDumps(); + if (vlog_stream_ || print) { + SemIR::Formatter formatter(*tokens_, *parse_tree_, *sem_ir_); + if (vlog_stream_) { + CARBON_VLOG() << "*** SemIR::File ***\n"; + formatter.Print(*vlog_stream_); + } + if (print) { + formatter.Print(driver_->output_stream_); + } } if (sem_ir_->has_errors()) { success_ = false; @@ -659,11 +698,16 @@ class Driver::CompilationUnit { // Runs post-compile logic. This is always called, and called after all other // actions on the CompilationUnit. - auto PostCompile() const -> void { + auto PostCompile() -> void { if (options_.dump_shared_values && IncludeInDumps()) { Yaml::Print(driver_->output_stream_, value_stores_.OutputYaml(input_filename_)); } + if (mem_usage_) { + mem_usage_->Collect("value_stores_", value_stores_); + Yaml::Print(driver_->output_stream_, + mem_usage_->OutputYaml(input_filename_)); + } // The diagnostics consumer must be flushed before compilation artifacts are // destructed, because diagnostics can refer to their state. @@ -744,6 +788,19 @@ class Driver::CompilationUnit { return true; } + // The TreeAndSubtrees is mainly used for debugging and diagnostics, and has + // significant overhead. Avoid constructing it when unused. + auto GetParseTreeAndSubtrees() -> const Parse::TreeAndSubtrees& { + if (!parse_tree_and_subtrees_) { + parse_tree_and_subtrees_ = Parse::TreeAndSubtrees(*tokens_, *parse_tree_); + if (mem_usage_) { + mem_usage_->Collect("parse_tree_and_subtrees_", + *parse_tree_and_subtrees_); + } + } + return *parse_tree_and_subtrees_; + } + // Wraps a call with log statements to indicate start and end. auto LogCall(llvm::StringLiteral label, llvm::function_ref fn) -> void { @@ -773,10 +830,14 @@ class Driver::CompilationUnit { bool success_ = true; + // Tracks memory usage of the compile. + std::optional mem_usage_; + // These are initialized as steps are run. std::optional source_; std::optional tokens_; std::optional parse_tree_; + std::optional parse_tree_and_subtrees_; std::optional sem_ir_; std::unique_ptr llvm_context_; std::unique_ptr module_; diff --git a/toolchain/driver/testdata/dump_mem_usage.carbon b/toolchain/driver/testdata/dump_mem_usage.carbon new file mode 100644 index 0000000000000..17c595bbccbac --- /dev/null +++ b/toolchain/driver/testdata/dump_mem_usage.carbon @@ -0,0 +1,19 @@ +// 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 +// +// ARGS: compile --phase=check --dump-mem-usage %s +// +// NOAUTOUPDATE +// +// Avoid testing specific values: +// SET-CHECK-SUBSET + +var x: i32 = 1; + +// CHECK:STDOUT: --- +// CHECK:STDOUT: filename: dump_mem_usage.carbon +// CHECK:STDOUT: source_: +// CHECK:STDOUT: used_bytes: 0 +// CHECK:STDOUT: reserved_bytes: 0 +// CHECK:STDOUT: ... diff --git a/toolchain/lex/BUILD b/toolchain/lex/BUILD index ee4bc4e09f2ad..06349a96ccb77 100644 --- a/toolchain/lex/BUILD +++ b/toolchain/lex/BUILD @@ -221,6 +221,7 @@ cc_library( "//common:ostream", "//common:string_helpers", "//toolchain/base:index_base", + "//toolchain/base:mem_usage", "//toolchain/base:value_store", "//toolchain/diagnostics:diagnostic_emitter", "//toolchain/source:source_buffer", diff --git a/toolchain/lex/lex.cpp b/toolchain/lex/lex.cpp index 95af499d846e4..44cfe93bf4f68 100644 --- a/toolchain/lex/lex.cpp +++ b/toolchain/lex/lex.cpp @@ -625,12 +625,59 @@ static auto DispatchNext(Lexer& lexer, llvm::StringRef source_text, lexer.LexFileEnd(source_text, position); } +// Estimate an upper bound on the number of identifiers we will need to lex. +// +// When analyzing both Carbon and LLVM's C++ code, we have found a roughly +// normal distribution of unique identifiers in the file centered at 0.5 * +// lines, and in the vast majority of cases bounded below 1.0 * lines. For +// example, here is LLVM's distribution computed with `scripts/source_stats.py` +// and rendered in an ASCII-art histogram: +// +// ## Unique IDs per 10 lines ## (median: 5, p90: 8, p95: 9, p99: 14) +// 1 ids [ 29] ▍ +// 2 ids [ 282] ███▊ +// 3 ids [1492] ███████████████████▉ +// 4 ids [2674] ███████████████████████████████████▌ +// 5 ids [3011] ████████████████████████████████████████ +// 6 ids [2267] ██████████████████████████████▏ +// 7 ids [1549] ████████████████████▋ +// 8 ids [ 817] ██████████▉ +// 9 ids [ 301] ████ +// 10 ids [ 98] █▎ +// +// (Trimmed to only cover 1 - 10 unique IDs per 10 lines of code, 272 files +// with more unique IDs in the tail.) +// +// We have checked this distribution with several large codebases (currently +// those at Google, happy to cross check with others) that use a similar coding +// style, and it appears to be very consistent. However, we suspect it may be +// dependent on the column width style. Currently, Carbon's toolchain style +// specifies 80-columns, but if we expect the lexer to routinely see files in +// different styles we should re-compute this estimate. +static auto EstimateUpperBoundOnNumIdentifiers(int line_count) -> int { + return line_count; +} + auto Lexer::Lex() && -> TokenizedBuffer { llvm::StringRef source_text = buffer_.source_->text(); // First build up our line data structures. MakeLines(source_text); + // Use the line count (and any other info needed from this scan) to make rough + // estimated reservations of memory in the hot data structures used by the + // lexer. In practice, scanning for lines is one of the easiest parts of the + // lexer to accelerate, and we can use its results to minimize the cost of + // incrementally growing data structures during the hot path of the lexer. + // + // Note that for hashtables we want estimates near the upper bound to minimize + // growth across the vast majority of inputs. They will also typically reserve + // more memory than we request due to load factor and rounding to power-of-two + // size. This overshoot is usually fine for hot parts of the lexer where + // latency is expected to be more important than minimizing memory usage. + buffer_.value_stores_->identifiers().Reserve( + EstimateUpperBoundOnNumIdentifiers(buffer_.line_infos_.size())); + ssize_t position = 0; LexFileStart(source_text, position); diff --git a/toolchain/lex/numeric_literal.cpp b/toolchain/lex/numeric_literal.cpp index fd5777a4053de..88f452d2dc0f7 100644 --- a/toolchain/lex/numeric_literal.cpp +++ b/toolchain/lex/numeric_literal.cpp @@ -138,8 +138,6 @@ class NumericLiteral::Parser { auto CheckDigitSequence(llvm::StringRef text, Radix radix, bool allow_digit_separators = true) -> CheckDigitSequenceResult; - auto CheckDigitSeparatorPlacement(llvm::StringRef text, Radix radix, - int num_digit_separators) -> void; auto CheckLeadingZero() -> bool; auto CheckIntPart() -> bool; auto CheckFractionalPart() -> bool; @@ -324,11 +322,6 @@ auto NumericLiteral::Parser::CheckDigitSequence(llvm::StringRef text, return {.ok = false}; } - // Check that digit separators occur in exactly the expected positions. - if (num_digit_separators) { - CheckDigitSeparatorPlacement(text, radix, num_digit_separators); - } - if (!CanLexInt(emitter_, text)) { return {.ok = false}; } @@ -336,51 +329,6 @@ auto NumericLiteral::Parser::CheckDigitSequence(llvm::StringRef text, return {.ok = true, .has_digit_separators = (num_digit_separators != 0)}; } -// Given a number with digit separators, check that the digit separators are -// correctly positioned. -auto NumericLiteral::Parser::CheckDigitSeparatorPlacement( - llvm::StringRef text, Radix radix, int num_digit_separators) -> void { - CARBON_DCHECK(std::count(text.begin(), text.end(), '_') == - num_digit_separators) - << "given wrong number of digit separators: " << num_digit_separators; - - if (radix == Radix::Binary) { - // There are no restrictions on digit separator placement for binary - // literals. - return; - } - - auto diagnose_irregular_digit_separators = [&]() { - CARBON_DIAGNOSTIC( - IrregularDigitSeparators, Error, - "Digit separators in {0} number should appear every {1} characters " - "from the right.", - NumericLiteral::Radix, int); - emitter_.Emit(text.begin(), IrregularDigitSeparators, radix, - radix == Radix::Decimal ? 3 : 4); - }; - - // For decimal and hexadecimal digit sequences, digit separators must form - // groups of 3 or 4 digits (4 or 5 characters), respectively. - int stride = (radix == Radix::Decimal ? 4 : 5); - int remaining_digit_separators = num_digit_separators; - const auto* pos = text.end(); - while (pos - text.begin() >= stride) { - pos -= stride; - if (*pos != '_') { - diagnose_irregular_digit_separators(); - return; - } - - --remaining_digit_separators; - } - - // Check there weren't any other digit separators. - if (remaining_digit_separators) { - diagnose_irregular_digit_separators(); - } -} - // Check that we don't have a '0' prefix on a non-zero decimal integer. auto NumericLiteral::Parser::CheckLeadingZero() -> bool { if (radix_ == Radix::Decimal && int_part_.starts_with("0") && diff --git a/toolchain/lex/numeric_literal_test.cpp b/toolchain/lex/numeric_literal_test.cpp index 0efe4ea4419eb..81be741dc9277 100644 --- a/toolchain/lex/numeric_literal_test.cpp +++ b/toolchain/lex/numeric_literal_test.cpp @@ -136,17 +136,22 @@ TEST_F(NumericLiteralTest, ValidatesBaseSpecifier) { TEST_F(NumericLiteralTest, ValidatesIntDigitSeparators) { llvm::StringLiteral valid[] = { - // Decimal literals optionally have digit separators every 3 places. + // Decimal literals. "1_234", "123_456", "1_234_567", + "12_34", + "123_4_6_789", + "12_3456_789", - // Hexadecimal literals optionally have digit separators every 4 places. + // Hexadecimal literals. "0x1_0000", "0x1000_0000", "0x1_0000_0000", + "0x12_3", + "0x1234_567", - // Binary integer literals can have digit separators anywhere.. + // Binary literals. "0b1_0_1_0_1_0", "0b111_0000", }; @@ -158,18 +163,13 @@ TEST_F(NumericLiteralTest, ValidatesIntDigitSeparators) { llvm::StringLiteral invalid[] = { // Decimal literals. - "12_34", - "123_4_6_789", - "12_3456_789", "12__345", "1_", // Hexadecimal literals. "0x_1234", "0x123_", - "0x12_3", "0x_234_5678", - "0x1234_567", // Binary literals. "0b_10101", @@ -257,17 +257,6 @@ TEST_F(NumericLiteralTest, HandlesRealLiteralOverflow) { } TEST_F(NumericLiteralTest, ValidatesRealLiterals) { - llvm::StringLiteral invalid_digit_separators[] = { - // Invalid digit separators. - "12_34.5", "123.4_567", "123.456_7", "1_2_3.4", - "123.4e56_78", "0x12_34.5", "0x12.3_4", "0x12.34p5_6", - }; - for (llvm::StringLiteral literal : invalid_digit_separators) { - error_tracker.Reset(); - EXPECT_THAT(Parse(literal), HasRealValue({})) << literal; - EXPECT_TRUE(error_tracker.seen_error()) << literal; - } - llvm::StringLiteral invalid[] = { // No digits in integer part. "0x.0", diff --git a/toolchain/lex/tokenized_buffer.cpp b/toolchain/lex/tokenized_buffer.cpp index e9b18f22e09c3..733e42b5acaff 100644 --- a/toolchain/lex/tokenized_buffer.cpp +++ b/toolchain/lex/tokenized_buffer.cpp @@ -340,6 +340,13 @@ auto TokenizedBuffer::AddToken(TokenInfo info) -> TokenIndex { return TokenIndex(static_cast(token_infos_.size()) - 1); } +auto TokenizedBuffer::CollectMemUsage(MemUsage& mem_usage, + llvm::StringRef label) const -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "allocator_"), allocator_); + mem_usage.Add(MemUsage::ConcatLabel(label, "token_infos_"), token_infos_); + mem_usage.Add(MemUsage::ConcatLabel(label, "line_infos_"), line_infos_); +} + auto TokenIterator::Print(llvm::raw_ostream& output) const -> void { output << token_.index; } diff --git a/toolchain/lex/tokenized_buffer.h b/toolchain/lex/tokenized_buffer.h index 4fdfd9d4a3403..0432480a1236c 100644 --- a/toolchain/lex/tokenized_buffer.h +++ b/toolchain/lex/tokenized_buffer.h @@ -18,6 +18,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/raw_ostream.h" #include "toolchain/base/index_base.h" +#include "toolchain/base/mem_usage.h" #include "toolchain/base/value_store.h" #include "toolchain/diagnostics/diagnostic_emitter.h" #include "toolchain/lex/token_index.h" @@ -204,6 +205,10 @@ class TokenizedBuffer : public Printable { auto PrintToken(llvm::raw_ostream& output_stream, TokenIndex token) const -> void; + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void; + // Returns true if the buffer has errors that were detected at lexing time. auto has_errors() const -> bool { return has_errors_; } diff --git a/toolchain/lower/file_context.cpp b/toolchain/lower/file_context.cpp index 44cabf76fa2d2..ae264c64677d3 100644 --- a/toolchain/lower/file_context.cpp +++ b/toolchain/lower/file_context.cpp @@ -13,6 +13,7 @@ #include "toolchain/sem_ir/entry_point.h" #include "toolchain/sem_ir/file.h" #include "toolchain/sem_ir/function.h" +#include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst.h" #include "toolchain/sem_ir/typed_insts.h" @@ -35,12 +36,12 @@ FileContext::FileContext(llvm::LLVMContext& llvm_context, auto FileContext::Run() -> std::unique_ptr { CARBON_CHECK(llvm_module_) << "Run can only be called once."; - // Lower all types that were required to be complete. Note that this may - // leave some entries in `types_` null, if those types were mentioned but not - // used. - types_.resize(sem_ir_->types().size()); - for (auto type_id : sem_ir_->complete_types()) { - types_[type_id.index] = BuildType(sem_ir_->types().GetInstId(type_id)); + // Lower all types that were required to be complete. + types_.resize(sem_ir_->insts().size()); + for (auto type_id : sem_ir_->types().complete_types()) { + if (type_id.index >= 0) { + types_[type_id.index] = BuildType(sem_ir_->types().GetInstId(type_id)); + } } // Lower function declarations. @@ -81,7 +82,7 @@ auto FileContext::GetGlobal(SemIR::InstId inst_id) -> llvm::Value* { // If we want a pointer to the constant, materialize a global to hold it. // TODO: We could reuse the same global if the constant is used more than // once. - auto value_rep = SemIR::GetValueRepr(sem_ir(), inst.type_id()); + auto value_rep = SemIR::ValueRepr::ForType(sem_ir(), inst.type_id()); if (value_rep.kind == SemIR::ValueRepr::Pointer) { // Include both the name of the constant, if any, and the point of use in // the name of the variable. @@ -122,9 +123,11 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) -> llvm::Function* { const auto& function = sem_ir().functions().Get(function_id); - // Don't lower associated functions. - // TODO: We shouldn't lower any function that has generic parameters. - if (sem_ir().insts().Is( + // Don't lower generic functions or associated functions. + // TODO: Associated functions have `Self` in scope so should be treated as + // generic functions. + if (function.generic_id.is_valid() || + sem_ir().insts().Is( sem_ir().name_scopes().Get(function.parent_scope_id).inst_id)) { return nullptr; } @@ -134,23 +137,23 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) return nullptr; } - // Don't lower unused functions. - if (function.return_slot == SemIR::Function::ReturnSlot::NotComputed) { - return nullptr; - } + // TODO: Consider tracking whether the function has been used, and only + // lowering it if it's needed. + + // TODO: Pass in a specific ID for generic functions. + const auto specific_id = SemIR::SpecificId::Invalid; + + const auto return_info = + SemIR::ReturnTypeInfo::ForFunction(sem_ir(), function, specific_id); + CARBON_CHECK(return_info.is_valid()) << "Should not lower invalid functions."; - const bool has_return_slot = function.has_return_slot(); auto implicit_param_refs = sem_ir().inst_blocks().GetOrEmpty(function.implicit_param_refs_id); // TODO: Include parameters corresponding to positional parameters. auto param_refs = sem_ir().inst_blocks().GetOrEmpty(function.param_refs_id); - auto return_type_id = function.declared_return_type(sem_ir()); - SemIR::InitRepr return_rep = - return_type_id.is_valid() - ? SemIR::GetInitRepr(sem_ir(), return_type_id) - : SemIR::InitRepr{.kind = SemIR::InitRepr::None}; - CARBON_CHECK(return_rep.has_return_slot() == has_return_slot); + auto* return_type = + return_info.type_id.is_valid() ? GetType(return_info.type_id) : nullptr; llvm::SmallVector param_types; // TODO: Consider either storing `param_inst_ids` somewhere so that we can @@ -158,12 +161,12 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) // out a mechanism to compute the mapping between parameters and arguments on // demand. llvm::SmallVector param_inst_ids; - auto max_llvm_params = - has_return_slot + implicit_param_refs.size() + param_refs.size(); + auto max_llvm_params = (return_info.has_return_slot() ? 1 : 0) + + implicit_param_refs.size() + param_refs.size(); param_types.reserve(max_llvm_params); param_inst_ids.reserve(max_llvm_params); - if (has_return_slot) { - param_types.push_back(GetType(return_type_id)->getPointerTo()); + if (return_info.has_return_slot()) { + param_types.push_back(return_type->getPointerTo()); param_inst_ids.push_back(function.return_storage_id); } for (auto param_ref_id : @@ -171,7 +174,7 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) auto param_type_id = SemIR::Function::GetParamFromParamRefId(sem_ir(), param_ref_id) .second.type_id; - switch (auto value_rep = SemIR::GetValueRepr(sem_ir(), param_type_id); + switch (auto value_rep = SemIR::ValueRepr::ForType(sem_ir(), param_type_id); value_rep.kind) { case SemIR::ValueRepr::Unknown: CARBON_FATAL() @@ -187,11 +190,12 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) } } - // If the initializing representation doesn't produce a value, set the return - // type to void. - llvm::Type* return_type = return_rep.kind == SemIR::InitRepr::ByCopy - ? GetType(return_type_id) - : llvm::Type::getVoidTy(llvm_context()); + // Compute the return type to use for the LLVM function. If the initializing + // representation doesn't produce a value, set the return type to void. + llvm::Type* function_return_type = + return_info.init_repr.kind == SemIR::InitRepr::ByCopy + ? return_type + : llvm::Type::getVoidTy(llvm_context()); std::string mangled_name; if (SemIR::IsEntryPoint(sem_ir(), function_id)) { @@ -206,8 +210,8 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) << function.name_id; } - llvm::FunctionType* function_type = - llvm::FunctionType::get(return_type, param_types, /*isVarArg=*/false); + llvm::FunctionType* function_type = llvm::FunctionType::get( + function_return_type, param_types, /*isVarArg=*/false); auto* llvm_function = llvm::Function::Create(function_type, llvm::Function::ExternalLinkage, mangled_name, llvm_module()); @@ -218,8 +222,8 @@ auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id) auto name_id = SemIR::NameId::Invalid; if (inst_id == function.return_storage_id) { name_id = SemIR::NameId::ReturnSlot; - arg.addAttr(llvm::Attribute::getWithStructRetType( - llvm_context(), GetType(return_type_id))); + arg.addAttr( + llvm::Attribute::getWithStructRetType(llvm_context(), return_type)); } else { name_id = SemIR::Function::GetParamFromParamRefId(sem_ir(), inst_id) .second.name_id; @@ -240,9 +244,16 @@ auto FileContext::BuildFunctionDefinition(SemIR::FunctionId function_id) } llvm::Function* llvm_function = GetFunction(function_id); + if (!llvm_function) { + // We chose not to lower this function at all, for example because it's a + // generic function. + return; + } + FunctionContext function_lowering(*this, llvm_function, vlog_stream_); - const bool has_return_slot = function.has_return_slot(); + // TODO: Pass in a specific ID for generic functions. + const auto specific_id = SemIR::SpecificId::Invalid; // Add parameters to locals. // TODO: This duplicates the mapping between sem_ir instructions and LLVM @@ -252,7 +263,8 @@ auto FileContext::BuildFunctionDefinition(SemIR::FunctionId function_id) sem_ir().inst_blocks().GetOrEmpty(function.implicit_param_refs_id); auto param_refs = sem_ir().inst_blocks().GetOrEmpty(function.param_refs_id); int param_index = 0; - if (has_return_slot) { + if (SemIR::ReturnTypeInfo::ForFunction(sem_ir(), function, specific_id) + .has_return_slot()) { function_lowering.SetLocal(function.return_storage_id, llvm_function->getArg(param_index)); ++param_index; @@ -265,7 +277,7 @@ auto FileContext::BuildFunctionDefinition(SemIR::FunctionId function_id) // Get the value of the parameter from the function argument. auto param_type_id = param.type_id; llvm::Value* param_value = llvm::PoisonValue::get(GetType(param_type_id)); - if (SemIR::GetValueRepr(sem_ir(), param_type_id).kind != + if (SemIR::ValueRepr::ForType(sem_ir(), param_type_id).kind != SemIR::ValueRepr::None) { param_value = llvm_function->getArg(param_index); ++param_index; @@ -320,8 +332,10 @@ static auto BuildTypeForInst(FileContext& context, SemIR::BuiltinInst inst) -> llvm::Type* { switch (inst.builtin_inst_kind) { case SemIR::BuiltinInstKind::Invalid: - case SemIR::BuiltinInstKind::Error: CARBON_FATAL() << "Unexpected builtin type in lowering."; + case SemIR::BuiltinInstKind::Error: + // This is a complete type but uses of it should never be lowered. + return nullptr; case SemIR::BuiltinInstKind::TypeType: return context.GetTypeType(); case SemIR::BuiltinInstKind::FloatType: diff --git a/toolchain/lower/file_context.h b/toolchain/lower/file_context.h index e42332472bc21..62e37543908b7 100644 --- a/toolchain/lower/file_context.h +++ b/toolchain/lower/file_context.h @@ -33,9 +33,6 @@ class FileContext { // Returns a lowered type for the given type_id. auto GetType(SemIR::TypeId type_id) -> llvm::Type* { // InvalidType should not be passed in. - if (type_id == SemIR::TypeId::TypeType) { - return GetTypeType(); - } CARBON_CHECK(type_id.index >= 0) << type_id; CARBON_CHECK(types_[type_id.index]) << "Missing type " << type_id; return types_[type_id.index]; diff --git a/toolchain/lower/function_context.cpp b/toolchain/lower/function_context.cpp index 4a8400c56dc63..858c0b3a3cfec 100644 --- a/toolchain/lower/function_context.cpp +++ b/toolchain/lower/function_context.cpp @@ -133,7 +133,7 @@ auto FunctionContext::MakeSyntheticBlock() -> llvm::BasicBlock* { auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id, SemIR::InstId source_id) -> void { - switch (SemIR::GetInitRepr(sem_ir(), type_id).kind) { + switch (SemIR::InitRepr::ForType(sem_ir(), type_id).kind) { case SemIR::InitRepr::None: break; case SemIR::InitRepr::InPlace: @@ -146,12 +146,15 @@ auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id, case SemIR::InitRepr::ByCopy: CopyValue(type_id, source_id, dest_id); break; + case SemIR::InitRepr::Incomplete: + CARBON_FATAL() << "Lowering aggregate initialization of incomplete type " + << sem_ir().types().GetAsInst(type_id); } } auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::InstId source_id, SemIR::InstId dest_id) -> void { - switch (auto rep = SemIR::GetValueRepr(sem_ir(), type_id); rep.kind) { + switch (auto rep = SemIR::ValueRepr::ForType(sem_ir(), type_id); rep.kind) { case SemIR::ValueRepr::Unknown: CARBON_FATAL() << "Attempt to copy incomplete type"; case SemIR::ValueRepr::None: diff --git a/toolchain/lower/handle.cpp b/toolchain/lower/handle.cpp index 38140e144c78f..656bec92d891d 100644 --- a/toolchain/lower/handle.cpp +++ b/toolchain/lower/handle.cpp @@ -194,7 +194,7 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/, auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/, SemIR::ReturnExpr inst) -> void { auto result_type_id = context.sem_ir().insts().Get(inst.expr_id).type_id(); - switch (SemIR::GetInitRepr(context.sem_ir(), result_type_id).kind) { + switch (SemIR::InitRepr::ForType(context.sem_ir(), result_type_id).kind) { case SemIR::InitRepr::None: // Nothing to return. context.builder().CreateRetVoid(); @@ -207,6 +207,9 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/, // The expression produces the value representation for the type. context.builder().CreateRet(context.GetValue(inst.expr_id)); return; + case SemIR::InitRepr::Incomplete: + CARBON_FATAL() << "Lowering return of incomplete type " + << context.sem_ir().types().GetAsInst(result_type_id); } } diff --git a/toolchain/lower/handle_aggregates.cpp b/toolchain/lower/handle_aggregates.cpp index c94958c7ba28d..40fac01fa2e7a 100644 --- a/toolchain/lower/handle_aggregates.cpp +++ b/toolchain/lower/handle_aggregates.cpp @@ -38,7 +38,7 @@ static auto GetAggregateElement(FunctionContext& context, case SemIR::ExprCategory::Value: { auto value_rep = - SemIR::GetValueRepr(context.sem_ir(), aggr_inst.type_id()); + SemIR::ValueRepr::ForType(context.sem_ir(), aggr_inst.type_id()); CARBON_CHECK(value_rep.aggregate_kind != SemIR::ValueRepr::NotAggregate) << "aggregate type should have aggregate value representation"; switch (value_rep.kind) { @@ -67,7 +67,8 @@ static auto GetAggregateElement(FunctionContext& context, // `elem_ptr` points to a value representation. Load it. auto result_value_type_id = - SemIR::GetValueRepr(context.sem_ir(), result_type_id).type_id; + SemIR::ValueRepr::ForType(context.sem_ir(), result_type_id) + .type_id; return context.builder().CreateLoad( context.GetType(result_value_type_id), elem_ptr, name + ".load"); } @@ -123,7 +124,7 @@ static auto EmitAggregateInitializer(FunctionContext& context, llvm::Twine name) -> llvm::Value* { auto* llvm_type = context.GetType(type_id); - switch (SemIR::GetInitRepr(context.sem_ir(), type_id).kind) { + switch (SemIR::InitRepr::ForType(context.sem_ir(), type_id).kind) { case SemIR::InitRepr::None: case SemIR::InitRepr::InPlace: // TODO: Add a helper to poison a value slot. @@ -139,6 +140,10 @@ static auto EmitAggregateInitializer(FunctionContext& context, llvm::PoisonValue::get(llvm_type), context.GetValue(refs[0]), {0}, name); } + + case SemIR::InitRepr::Incomplete: + CARBON_FATAL() << "Lowering aggregate initialization of incomplete type " + << context.sem_ir().types().GetAsInst(type_id); } } @@ -169,7 +174,7 @@ auto HandleInst(FunctionContext& /*context*/, SemIR::InstId /*inst_id*/, static auto EmitAggregateValueRepr(FunctionContext& context, SemIR::TypeId type_id, SemIR::InstBlockId refs_id) -> llvm::Value* { - auto value_rep = SemIR::GetValueRepr(context.sem_ir(), type_id); + auto value_rep = SemIR::ValueRepr::ForType(context.sem_ir(), type_id); switch (value_rep.kind) { case SemIR::ValueRepr::Unknown: CARBON_FATAL() << "Incomplete aggregate type in lowering"; diff --git a/toolchain/lower/handle_call.cpp b/toolchain/lower/handle_call.cpp index 4e2685548fc64..d3281f1186d86 100644 --- a/toolchain/lower/handle_call.cpp +++ b/toolchain/lower/handle_call.cpp @@ -312,14 +312,15 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, std::vector args; - if (SemIR::GetInitRepr(context.sem_ir(), inst.type_id).has_return_slot()) { + if (SemIR::ReturnTypeInfo::ForType(context.sem_ir(), inst.type_id) + .has_return_slot()) { args.push_back(context.GetValue(arg_ids.back())); arg_ids = arg_ids.drop_back(); } for (auto arg_id : arg_ids) { auto arg_type_id = context.sem_ir().insts().Get(arg_id).type_id(); - if (SemIR::GetValueRepr(context.sem_ir(), arg_type_id).kind != + if (SemIR::ValueRepr::ForType(context.sem_ir(), arg_type_id).kind != SemIR::ValueRepr::None) { args.push_back(context.GetValue(arg_id)); } diff --git a/toolchain/lower/handle_expr_category.cpp b/toolchain/lower/handle_expr_category.cpp index c19d24f6239fb..7a6739229a6b4 100644 --- a/toolchain/lower/handle_expr_category.cpp +++ b/toolchain/lower/handle_expr_category.cpp @@ -9,7 +9,7 @@ namespace Carbon::Lower { auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, SemIR::BindValue inst) -> void { - switch (auto rep = SemIR::GetValueRepr(context.sem_ir(), inst.type_id); + switch (auto rep = SemIR::ValueRepr::ForType(context.sem_ir(), inst.type_id); rep.kind) { case SemIR::ValueRepr::Unknown: CARBON_FATAL() @@ -51,7 +51,7 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, SemIR::ValueAsRef inst) -> void { CARBON_CHECK(SemIR::GetExprCategory(context.sem_ir(), inst.value_id) == SemIR::ExprCategory::Value); - CARBON_CHECK(SemIR::GetValueRepr(context.sem_ir(), inst.type_id).kind == + CARBON_CHECK(SemIR::ValueRepr::ForType(context.sem_ir(), inst.type_id).kind == SemIR::ValueRepr::Pointer); context.SetLocal(inst_id, context.GetValue(inst.value_id)); } @@ -60,9 +60,9 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, SemIR::ValueOfInitializer inst) -> void { CARBON_CHECK(SemIR::GetExprCategory(context.sem_ir(), inst.init_id) == SemIR::ExprCategory::Initializing); - CARBON_CHECK(SemIR::GetValueRepr(context.sem_ir(), inst.type_id).kind == + CARBON_CHECK(SemIR::ValueRepr::ForType(context.sem_ir(), inst.type_id).kind == SemIR::ValueRepr::Copy); - CARBON_CHECK(SemIR::GetInitRepr(context.sem_ir(), inst.type_id).kind == + CARBON_CHECK(SemIR::InitRepr::ForType(context.sem_ir(), inst.type_id).kind == SemIR::InitRepr::ByCopy); context.SetLocal(inst_id, context.GetValue(inst.init_id)); } diff --git a/toolchain/lower/testdata/class/value_access.carbon b/toolchain/lower/testdata/class/value_access.carbon index d9774f6c3a311..dcf7abb2e548b 100644 --- a/toolchain/lower/testdata/class/value_access.carbon +++ b/toolchain/lower/testdata/class/value_access.carbon @@ -16,7 +16,7 @@ fn F(c: C) -> i32 { // TODO: `c.a` is a value expression here, which forces a value binding as // part of the member access, creating a tuple value temporary. We could // defer performing the value binding to avoid creating this temporary. - return c.a[1]; + return c.a.1; } // CHECK:STDOUT: ; ModuleID = 'value_access.carbon' @@ -38,7 +38,7 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: store i32 %.loc19_11.5, ptr %tuple2, align 4 // CHECK:STDOUT: %tuple3 = getelementptr inbounds { i32, i32, i32 }, ptr %tuple, i32 0, i32 2 // CHECK:STDOUT: store i32 %.loc19_11.7, ptr %tuple3, align 4 -// CHECK:STDOUT: %.loc19_15.tuple.index = getelementptr inbounds { i32, i32, i32 }, ptr %tuple, i32 0, i32 1 -// CHECK:STDOUT: %.loc19_15.tuple.index.load = load i32, ptr %.loc19_15.tuple.index, align 4 -// CHECK:STDOUT: ret i32 %.loc19_15.tuple.index.load +// CHECK:STDOUT: %.loc19_13.tuple.index = getelementptr inbounds { i32, i32, i32 }, ptr %tuple, i32 0, i32 1 +// CHECK:STDOUT: %.loc19_13.tuple.index.load = load i32, ptr %.loc19_13.tuple.index, align 4 +// CHECK:STDOUT: ret i32 %.loc19_13.tuple.index.load // CHECK:STDOUT: } diff --git a/toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon b/toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon index 20ed9d875c330..8ebfa18bc234f 100644 --- a/toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon +++ b/toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/function/call/tuple_param_with_return_slot.carbon fn F(a: (), b: (i32,), c: (i32, i32)) -> (i32, i32, i32) { - return (b[0], c[0], c[1]); + return (b.0, c.0, c.1); } fn Main() { @@ -23,17 +23,17 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: define void @F(ptr sret({ i32, i32, i32 }) %return, { i32 } %b, ptr %c) { // CHECK:STDOUT: entry: -// CHECK:STDOUT: %.loc12_14.tuple.index = extractvalue { i32 } %b, 0 -// CHECK:STDOUT: %.loc12_20.tuple.index = getelementptr inbounds { i32, i32 }, ptr %c, i32 0, i32 0 -// CHECK:STDOUT: %.loc12_20.tuple.index.load = load i32, ptr %.loc12_20.tuple.index, align 4 -// CHECK:STDOUT: %.loc12_26.tuple.index = getelementptr inbounds { i32, i32 }, ptr %c, i32 0, i32 1 -// CHECK:STDOUT: %.loc12_26.tuple.index.load = load i32, ptr %.loc12_26.tuple.index, align 4 -// CHECK:STDOUT: %.loc12_27.2.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %return, i32 0, i32 0 -// CHECK:STDOUT: store i32 %.loc12_14.tuple.index, ptr %.loc12_27.2.tuple.elem, align 4 -// CHECK:STDOUT: %.loc12_27.4.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %return, i32 0, i32 1 -// CHECK:STDOUT: store i32 %.loc12_20.tuple.index.load, ptr %.loc12_27.4.tuple.elem, align 4 -// CHECK:STDOUT: %.loc12_27.6.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %return, i32 0, i32 2 -// CHECK:STDOUT: store i32 %.loc12_26.tuple.index.load, ptr %.loc12_27.6.tuple.elem, align 4 +// CHECK:STDOUT: %.loc12_12.tuple.index = extractvalue { i32 } %b, 0 +// CHECK:STDOUT: %.loc12_17.tuple.index = getelementptr inbounds { i32, i32 }, ptr %c, i32 0, i32 0 +// CHECK:STDOUT: %.loc12_17.tuple.index.load = load i32, ptr %.loc12_17.tuple.index, align 4 +// CHECK:STDOUT: %.loc12_22.tuple.index = getelementptr inbounds { i32, i32 }, ptr %c, i32 0, i32 1 +// CHECK:STDOUT: %.loc12_22.tuple.index.load = load i32, ptr %.loc12_22.tuple.index, align 4 +// CHECK:STDOUT: %.loc12_24.2.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %return, i32 0, i32 0 +// CHECK:STDOUT: store i32 %.loc12_12.tuple.index, ptr %.loc12_24.2.tuple.elem, align 4 +// CHECK:STDOUT: %.loc12_24.4.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %return, i32 0, i32 1 +// CHECK:STDOUT: store i32 %.loc12_17.tuple.index.load, ptr %.loc12_24.4.tuple.elem, align 4 +// CHECK:STDOUT: %.loc12_24.6.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %return, i32 0, i32 2 +// CHECK:STDOUT: store i32 %.loc12_22.tuple.index.load, ptr %.loc12_24.6.tuple.elem, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/lower/testdata/function/generic/type_param.carbon b/toolchain/lower/testdata/function/generic/type_param.carbon index 1ec8520e1de81..d827a3eb7a34c 100644 --- a/toolchain/lower/testdata/function/generic/type_param.carbon +++ b/toolchain/lower/testdata/function/generic/type_param.carbon @@ -15,13 +15,3 @@ fn F(T:! type) { // CHECK:STDOUT: ; ModuleID = 'type_param.carbon' // CHECK:STDOUT: source_filename = "type_param.carbon" -// CHECK:STDOUT: -// CHECK:STDOUT: %type = type {} -// CHECK:STDOUT: -// CHECK:STDOUT: define void @F(%type %T) { -// CHECK:STDOUT: entry: -// CHECK:STDOUT: %p.var = alloca ptr, align 8 -// CHECK:STDOUT: %.loc13_15 = load ptr, ptr %p.var, align 8 -// CHECK:STDOUT: %.loc13_14.2 = load {}, ptr %.loc13_15, align 1 -// CHECK:STDOUT: ret void -// CHECK:STDOUT: } diff --git a/toolchain/lower/testdata/index/array_element_access.carbon b/toolchain/lower/testdata/index/array_element_access.carbon index 6148769ae494d..d4ae415be1fb1 100644 --- a/toolchain/lower/testdata/index/array_element_access.carbon +++ b/toolchain/lower/testdata/index/array_element_access.carbon @@ -13,7 +13,7 @@ fn B() -> [i32; 2] { return (1, 2); } fn Run() { var a: [i32; 2] = A(); - var b: i32 = A()[0]; + var b: i32 = 1; var c: i32 = a[b]; var d: i32 = B()[1]; } @@ -54,11 +54,7 @@ fn Run() { // CHECK:STDOUT: %.loc15_22.11.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 1 // CHECK:STDOUT: store i32 %.loc15_22.9, ptr %.loc15_22.11.array.index, align 4 // CHECK:STDOUT: %b.var = alloca i32, align 4 -// CHECK:STDOUT: %.loc16_17.1.temp = alloca { i32, i32 }, align 8 -// CHECK:STDOUT: call void @A(ptr %.loc16_17.1.temp) -// CHECK:STDOUT: %.loc16_21.1.tuple.index = getelementptr inbounds { i32, i32 }, ptr %.loc16_17.1.temp, i32 0, i32 0 -// CHECK:STDOUT: %.loc16_21.2 = load i32, ptr %.loc16_21.1.tuple.index, align 4 -// CHECK:STDOUT: store i32 %.loc16_21.2, ptr %b.var, align 4 +// CHECK:STDOUT: store i32 1, ptr %b.var, align 4 // CHECK:STDOUT: %c.var = alloca i32, align 4 // CHECK:STDOUT: %.loc17_18 = load i32, ptr %b.var, align 4 // CHECK:STDOUT: %.loc17_19.1.array.index = getelementptr inbounds [2 x i32], ptr %a.var, i32 0, i32 %.loc17_18 diff --git a/toolchain/lower/testdata/index/tuple_element_access.carbon b/toolchain/lower/testdata/index/tuple_element_access.carbon index a045dba4add02..cd7eefd1cc2f4 100644 --- a/toolchain/lower/testdata/index/tuple_element_access.carbon +++ b/toolchain/lower/testdata/index/tuple_element_access.carbon @@ -10,8 +10,8 @@ fn Run() -> i32 { var a: (i32, i32, i32) = (0, 1, 2); - var b: i32 = a[0]; - var c: i32 = a[2]; + var b: i32 = a.0; + var c: i32 = a.2; return 0; } @@ -28,13 +28,13 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc12_36.6.tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %a.var, i32 0, i32 2 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.loc12_37, i64 12, i1 false) // CHECK:STDOUT: %b.var = alloca i32, align 4 -// CHECK:STDOUT: %.loc13_19.1.tuple.index = getelementptr inbounds { i32, i32, i32 }, ptr %a.var, i32 0, i32 0 -// CHECK:STDOUT: %.loc13_19.2 = load i32, ptr %.loc13_19.1.tuple.index, align 4 -// CHECK:STDOUT: store i32 %.loc13_19.2, ptr %b.var, align 4 +// CHECK:STDOUT: %.loc13_17.1.tuple.index = getelementptr inbounds { i32, i32, i32 }, ptr %a.var, i32 0, i32 0 +// CHECK:STDOUT: %.loc13_17.2 = load i32, ptr %.loc13_17.1.tuple.index, align 4 +// CHECK:STDOUT: store i32 %.loc13_17.2, ptr %b.var, align 4 // CHECK:STDOUT: %c.var = alloca i32, align 4 -// CHECK:STDOUT: %.loc14_19.1.tuple.index = getelementptr inbounds { i32, i32, i32 }, ptr %a.var, i32 0, i32 2 -// CHECK:STDOUT: %.loc14_19.2 = load i32, ptr %.loc14_19.1.tuple.index, align 4 -// CHECK:STDOUT: store i32 %.loc14_19.2, ptr %c.var, align 4 +// CHECK:STDOUT: %.loc14_17.1.tuple.index = getelementptr inbounds { i32, i32, i32 }, ptr %a.var, i32 0, i32 2 +// CHECK:STDOUT: %.loc14_17.2 = load i32, ptr %.loc14_17.1.tuple.index, align 4 +// CHECK:STDOUT: store i32 %.loc14_17.2, ptr %c.var, align 4 // CHECK:STDOUT: ret i32 0 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/lower/testdata/index/tuple_return_value_access.carbon b/toolchain/lower/testdata/index/tuple_return_value_access.carbon index 35630114dbdac..9cbbfc4136d28 100644 --- a/toolchain/lower/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/lower/testdata/index/tuple_return_value_access.carbon @@ -11,7 +11,7 @@ fn F() -> (i32, i32) { return (12, 24); } fn Run() { - var t: i32 = F()[1]; + var t: i32 = F().1; } // CHECK:STDOUT: ; ModuleID = 'tuple_return_value_access.carbon' @@ -32,9 +32,9 @@ fn Run() { // CHECK:STDOUT: %t.var = alloca i32, align 4 // CHECK:STDOUT: %.loc14_17.1.temp = alloca { i32, i32 }, align 8 // CHECK:STDOUT: call void @F(ptr %.loc14_17.1.temp) -// CHECK:STDOUT: %.loc14_21.1.tuple.index = getelementptr inbounds { i32, i32 }, ptr %.loc14_17.1.temp, i32 0, i32 1 -// CHECK:STDOUT: %.loc14_21.2 = load i32, ptr %.loc14_21.1.tuple.index, align 4 -// CHECK:STDOUT: store i32 %.loc14_21.2, ptr %t.var, align 4 +// CHECK:STDOUT: %.loc14_19.1.tuple.index = getelementptr inbounds { i32, i32 }, ptr %.loc14_17.1.temp, i32 0, i32 1 +// CHECK:STDOUT: %.loc14_19.2 = load i32, ptr %.loc14_19.1.tuple.index, align 4 +// CHECK:STDOUT: store i32 %.loc14_19.2, ptr %t.var, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/lower/testdata/let/tuple.carbon b/toolchain/lower/testdata/let/tuple.carbon index 3affa6586e60a..c73b4771ee5d9 100644 --- a/toolchain/lower/testdata/let/tuple.carbon +++ b/toolchain/lower/testdata/let/tuple.carbon @@ -12,7 +12,7 @@ fn F() -> i32 { var a: (i32, i32, i32) = (1, 2, 3); var b: (i32, i32) = (4, 5); let c: ((i32, i32, i32), (i32, i32)) = (a, b); - return c[1][1]; + return c.1.(1); } // CHECK:STDOUT: ; ModuleID = 'tuple.carbon' @@ -59,11 +59,11 @@ fn F() -> i32 { // CHECK:STDOUT: store ptr %tuple.loc14_43, ptr %tuple.loc14_476, align 8 // CHECK:STDOUT: %tuple.loc14_477 = getelementptr inbounds { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1 // CHECK:STDOUT: store ptr %tuple.loc14_46, ptr %tuple.loc14_477, align 8 -// CHECK:STDOUT: %.loc15_13.tuple.index = getelementptr inbounds { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1 -// CHECK:STDOUT: %.loc15_13.tuple.index.load = load ptr, ptr %.loc15_13.tuple.index, align 8 -// CHECK:STDOUT: %.loc15_16.tuple.index = getelementptr inbounds { i32, i32 }, ptr %.loc15_13.tuple.index.load, i32 0, i32 1 -// CHECK:STDOUT: %.loc15_16.tuple.index.load = load i32, ptr %.loc15_16.tuple.index, align 4 -// CHECK:STDOUT: ret i32 %.loc15_16.tuple.index.load +// CHECK:STDOUT: %.loc15_11.tuple.index = getelementptr inbounds { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1 +// CHECK:STDOUT: %.loc15_11.tuple.index.load = load ptr, ptr %.loc15_11.tuple.index, align 8 +// CHECK:STDOUT: %.loc15_13.tuple.index = getelementptr inbounds { i32, i32 }, ptr %.loc15_11.tuple.index.load, i32 0, i32 1 +// CHECK:STDOUT: %.loc15_13.tuple.index.load = load i32, ptr %.loc15_13.tuple.index, align 4 +// CHECK:STDOUT: ret i32 %.loc15_13.tuple.index.load // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite) diff --git a/toolchain/parse/BUILD b/toolchain/parse/BUILD index 449d291dfc336..3022b91bc2561 100644 --- a/toolchain/parse/BUILD +++ b/toolchain/parse/BUILD @@ -106,8 +106,12 @@ cc_library( srcs = [ "extract.cpp", "tree.cpp", + "tree_and_subtrees.cpp", + ], + hdrs = [ + "tree.h", + "tree_and_subtrees.h", ], - hdrs = ["tree.h"], deps = [ ":node_kind", "//common:check", diff --git a/toolchain/parse/context.cpp b/toolchain/parse/context.cpp index b79400e385f74..b886a0169b74a 100644 --- a/toolchain/parse/context.cpp +++ b/toolchain/parse/context.cpp @@ -68,18 +68,15 @@ Context::Context(Tree& tree, Lex::TokenizedBuffer& tokens, auto Context::AddLeafNode(NodeKind kind, Lex::TokenIndex token, bool has_error) -> void { - tree_->node_impls_.push_back( - Tree::NodeImpl(kind, has_error, token, /*subtree_size=*/1)); + tree_->node_impls_.push_back(Tree::NodeImpl(kind, has_error, token)); if (has_error) { tree_->has_errors_ = true; } } -auto Context::AddNode(NodeKind kind, Lex::TokenIndex token, int subtree_start, - bool has_error) -> void { - int subtree_size = tree_->size() - subtree_start + 1; - tree_->node_impls_.push_back( - Tree::NodeImpl(kind, has_error, token, subtree_size)); +auto Context::AddNode(NodeKind kind, Lex::TokenIndex token, bool has_error) + -> void { + tree_->node_impls_.push_back(Tree::NodeImpl(kind, has_error, token)); if (has_error) { tree_->has_errors_ = true; } @@ -91,7 +88,6 @@ auto Context::ReplacePlaceholderNode(int32_t position, NodeKind kind, CARBON_CHECK(position >= 0 && position < tree_->size()) << "position: " << position << " size: " << tree_->size(); auto* node_impl = &tree_->node_impls_[position]; - CARBON_CHECK(node_impl->subtree_size == 1); CARBON_CHECK(node_impl->kind == NodeKind::Placeholder); node_impl->kind = kind; node_impl->has_error = has_error; @@ -123,9 +119,9 @@ auto Context::ConsumeAndAddCloseSymbol(Lex::TokenIndex expected_open, Lex::TokenKind open_token_kind = tokens().GetKind(expected_open); if (!open_token_kind.is_opening_symbol()) { - AddNode(close_kind, state.token, state.subtree_start, /*has_error=*/true); + AddNode(close_kind, state.token, /*has_error=*/true); } else if (auto close_token = ConsumeIf(open_token_kind.closing_symbol())) { - AddNode(close_kind, *close_token, state.subtree_start, state.has_error); + AddNode(close_kind, *close_token, state.has_error); } else { // TODO: Include the location of the matching opening delimiter in the // diagnostic. @@ -135,7 +131,7 @@ auto Context::ConsumeAndAddCloseSymbol(Lex::TokenIndex expected_open, open_token_kind.closing_symbol().fixed_spelling()); SkipTo(tokens().GetMatchedClosingToken(expected_open)); - AddNode(close_kind, Consume(), state.subtree_start, /*has_error=*/true); + AddNode(close_kind, Consume(), /*has_error=*/true); } } @@ -415,7 +411,7 @@ auto Context::AddNodeExpectingDeclSemi(StateStackEntry state, } if (auto semi = ConsumeIf(Lex::TokenKind::Semi)) { - AddNode(node_kind, *semi, state.subtree_start, /*has_error=*/false); + AddNode(node_kind, *semi, /*has_error=*/false); } else { if (is_def_allowed) { DiagnoseExpectedDeclSemiOrDefinition(decl_kind); @@ -433,8 +429,42 @@ auto Context::RecoverFromDeclError(StateStackEntry state, NodeKind node_kind, if (skip_past_likely_end) { token = SkipPastLikelyEnd(token); } - AddNode(node_kind, token, state.subtree_start, - /*has_error=*/true); + AddNode(node_kind, token, /*has_error=*/true); +} + +auto Context::ParseLibraryName(bool accept_default) + -> std::optional { + if (auto library_name_token = ConsumeIf(Lex::TokenKind::StringLiteral)) { + AddLeafNode(NodeKind::LibraryName, *library_name_token); + return tokens().GetStringLiteralValue(*library_name_token); + } + + if (accept_default) { + if (auto default_token = ConsumeIf(Lex::TokenKind::Default)) { + AddLeafNode(NodeKind::DefaultLibrary, *default_token); + return StringLiteralValueId::Invalid; + } + } + + CARBON_DIAGNOSTIC( + ExpectedLibraryNameOrDefault, Error, + "Expected `default` or a string literal to specify the library name."); + CARBON_DIAGNOSTIC(ExpectedLibraryName, Error, + "Expected a string literal to specify the library name."); + emitter().Emit(*position(), accept_default ? ExpectedLibraryNameOrDefault + : ExpectedLibraryName); + return std::nullopt; +} + +auto Context::ParseLibrarySpecifier(bool accept_default) + -> std::optional { + auto library_token = ConsumeChecked(Lex::TokenKind::Library); + auto library_id = ParseLibraryName(accept_default); + if (!library_id) { + AddLeafNode(NodeKind::LibraryName, *position_, /*has_error=*/true); + } + AddNode(NodeKind::LibrarySpecifier, library_token, /*has_error=*/false); + return library_id; } auto Context::DiagnoseExpectedDeclSemi(Lex::TokenKind expected_kind) -> void { @@ -466,8 +496,7 @@ static auto ParsingInDeferredDefinitionScope(Context& context) -> bool { state == State::DeclDefinitionFinishAsNamedConstraint; } -auto Context::AddFunctionDefinitionStart(Lex::TokenIndex token, - int subtree_start, bool has_error) +auto Context::AddFunctionDefinitionStart(Lex::TokenIndex token, bool has_error) -> void { if (ParsingInDeferredDefinitionScope(*this)) { deferred_definition_stack_.push_back(tree_->deferred_definitions_.Add( @@ -475,11 +504,11 @@ auto Context::AddFunctionDefinitionStart(Lex::TokenIndex token, FunctionDefinitionStartId(NodeId(tree_->node_impls_.size()))})); } - AddNode(NodeKind::FunctionDefinitionStart, token, subtree_start, has_error); + AddNode(NodeKind::FunctionDefinitionStart, token, has_error); } -auto Context::AddFunctionDefinition(Lex::TokenIndex token, int subtree_start, - bool has_error) -> void { +auto Context::AddFunctionDefinition(Lex::TokenIndex token, bool has_error) + -> void { if (ParsingInDeferredDefinitionScope(*this)) { auto definition_index = deferred_definition_stack_.pop_back_val(); auto& definition = tree_->deferred_definitions_.Get(definition_index); @@ -489,7 +518,7 @@ auto Context::AddFunctionDefinition(Lex::TokenIndex token, int subtree_start, DeferredDefinitionIndex(tree_->deferred_definitions().size()); } - AddNode(NodeKind::FunctionDefinition, token, subtree_start, has_error); + AddNode(NodeKind::FunctionDefinition, token, has_error); } auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void { diff --git a/toolchain/parse/context.h b/toolchain/parse/context.h index 0ccf6f944bbaa..03e4da0461003 100644 --- a/toolchain/parse/context.h +++ b/toolchain/parse/context.h @@ -100,8 +100,7 @@ class Context { -> void; // Adds a node to the parse tree that has children. - auto AddNode(NodeKind kind, Lex::TokenIndex token, int subtree_start, - bool has_error) -> void; + auto AddNode(NodeKind kind, Lex::TokenIndex token, bool has_error) -> void; // Replaces the placeholder node at the indicated position with a leaf node. // @@ -302,6 +301,18 @@ class Context { auto RecoverFromDeclError(StateStackEntry state, NodeKind node_kind, bool skip_past_likely_end) -> void; + // Handles parsing of the library name. Returns the name's ID on success, + // which may be invalid for `default`. + // TODO: Add an invalid node on error, fix callers to adapt. + auto ParseLibraryName(bool accept_default) + -> std::optional; + + // Handles parsing `library `. Requires that the position is a `library` + // token. Returns the name's ID on success, which may be invalid for + // `default`. + auto ParseLibrarySpecifier(bool accept_default) + -> std::optional; + // Sets the package declaration information. Called at most once. auto set_packaging_decl(Tree::PackagingNames packaging_names, bool is_impl) -> void { @@ -316,12 +327,11 @@ class Context { // Adds a function definition start node, and begins tracking a deferred // definition if necessary. - auto AddFunctionDefinitionStart(Lex::TokenIndex token, int subtree_start, - bool has_error) -> void; + auto AddFunctionDefinitionStart(Lex::TokenIndex token, bool has_error) + -> void; // Adds a function definition node, and ends tracking a deferred definition if // necessary. - auto AddFunctionDefinition(Lex::TokenIndex token, int subtree_start, - bool has_error) -> void; + auto AddFunctionDefinition(Lex::TokenIndex token, bool has_error) -> void; // Prints information for a stack dump. auto PrintForStackDump(llvm::raw_ostream& output) const -> void; diff --git a/toolchain/parse/extract.cpp b/toolchain/parse/extract.cpp index 2b7c2fac47794..a71daf0f7625a 100644 --- a/toolchain/parse/extract.cpp +++ b/toolchain/parse/extract.cpp @@ -9,6 +9,7 @@ #include "common/error.h" #include "common/struct_reflection.h" #include "toolchain/parse/tree.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/parse/typed_nodes.h" namespace Carbon::Parse { @@ -20,12 +21,12 @@ namespace { class NodeExtractor { public: struct CheckpointState { - Tree::SiblingIterator it; + TreeAndSubtrees::SiblingIterator it; }; - NodeExtractor(const Tree* tree, Lex::TokenizedBuffer* tokens, + NodeExtractor(const TreeAndSubtrees* tree, const Lex::TokenizedBuffer* tokens, ErrorBuilder* trace, NodeId node_id, - llvm::iterator_range children) + llvm::iterator_range children) : tree_(tree), tokens_(tokens), trace_(trace), @@ -34,9 +35,11 @@ class NodeExtractor { end_(children.end()) {} auto at_end() const -> bool { return it_ == end_; } - auto kind() const -> NodeKind { return tree_->node_kind(*it_); } + auto kind() const -> NodeKind { return tree_->tree().node_kind(*it_); } auto has_token() const -> bool { return node_id_.is_valid(); } - auto token() const -> Lex::TokenIndex { return tree_->node_token(node_id_); } + auto token() const -> Lex::TokenIndex { + return tree_->tree().node_token(node_id_); + } auto token_kind() const -> Lex::TokenKind { return tokens_->GetKind(token()); } @@ -73,12 +76,12 @@ class NodeExtractor { std::tuple* /*type*/) -> std::optional; private: - const Tree* tree_; - Lex::TokenizedBuffer* tokens_; + const TreeAndSubtrees* tree_; + const Lex::TokenizedBuffer* tokens_; ErrorBuilder* trace_; NodeId node_id_; - Tree::SiblingIterator it_; - Tree::SiblingIterator end_; + TreeAndSubtrees::SiblingIterator it_; + TreeAndSubtrees::SiblingIterator end_; }; } // namespace @@ -97,8 +100,8 @@ namespace { // }; // ``` // -// Note that `Tree::SiblingIterator`s iterate in reverse order through the -// children of a node. +// Note that `TreeAndSubtrees::SiblingIterator`s iterate in reverse order +// through the children of a node. // // This class is only in this file. template @@ -320,7 +323,7 @@ auto NodeExtractor::MatchesTokenKind(Lex::TokenKind expected_kind) const if (token_kind() != expected_kind) { if (trace_) { *trace_ << "Token " << expected_kind << " expected for " - << tree_->node_kind(node_id_) << ", found " << token_kind() + << tree_->tree().node_kind(node_id_) << ", found " << token_kind() << "\n"; } return false; @@ -405,14 +408,15 @@ struct Extractable { } // namespace template -auto Tree::TryExtractNodeFromChildren( - NodeId node_id, llvm::iterator_range children, +auto TreeAndSubtrees::TryExtractNodeFromChildren( + NodeId node_id, + llvm::iterator_range children, ErrorBuilder* trace) const -> std::optional { NodeExtractor extractor(this, tokens_, trace, node_id, children); auto result = Extractable::ExtractImpl(extractor); if (!extractor.at_end()) { if (trace) { - *trace << "Error: " << node_kind(extractor.ExtractNode()) + *trace << "Error: " << tree_->node_kind(extractor.ExtractNode()) << " node left unconsumed."; } return std::nullopt; @@ -421,16 +425,17 @@ auto Tree::TryExtractNodeFromChildren( } // Manually instantiate Tree::TryExtractNodeFromChildren -#define CARBON_PARSE_NODE_KIND(KindName) \ - template auto Tree::TryExtractNodeFromChildren( \ - NodeId node_id, llvm::iterator_range children, \ +#define CARBON_PARSE_NODE_KIND(KindName) \ + template auto TreeAndSubtrees::TryExtractNodeFromChildren( \ + NodeId node_id, \ + llvm::iterator_range children, \ ErrorBuilder * trace) const -> std::optional; // Also instantiate for `File`, even though it isn't a parse node. CARBON_PARSE_NODE_KIND(File) #include "toolchain/parse/node_kind.def" -auto Tree::ExtractFile() const -> File { +auto TreeAndSubtrees::ExtractFile() const -> File { return ExtractNodeFromChildren(NodeId::Invalid, roots()); } diff --git a/toolchain/parse/handle_array_expr.cpp b/toolchain/parse/handle_array_expr.cpp index 5111003ebff19..52197f8341afa 100644 --- a/toolchain/parse/handle_array_expr.cpp +++ b/toolchain/parse/handle_array_expr.cpp @@ -24,14 +24,12 @@ auto HandleArrayExprSemi(Context& context) -> void { auto state = context.PopState(); auto semi = context.ConsumeIf(Lex::TokenKind::Semi); if (!semi) { - context.AddNode(NodeKind::ArrayExprSemi, *context.position(), - state.subtree_start, true); + context.AddNode(NodeKind::ArrayExprSemi, *context.position(), true); CARBON_DIAGNOSTIC(ExpectedArraySemi, Error, "Expected `;` in array type."); context.emitter().Emit(*context.position(), ExpectedArraySemi); state.has_error = true; } else { - context.AddNode(NodeKind::ArrayExprSemi, *semi, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ArrayExprSemi, *semi, state.has_error); } context.PushState(state, State::ArrayExprFinish); if (!context.PositionIs(Lex::TokenKind::CloseSquareBracket)) { diff --git a/toolchain/parse/handle_binding_pattern.cpp b/toolchain/parse/handle_binding_pattern.cpp index 2a8e6bdfaf9b0..06230d0f4b657 100644 --- a/toolchain/parse/handle_binding_pattern.cpp +++ b/toolchain/parse/handle_binding_pattern.cpp @@ -76,7 +76,7 @@ static auto HandleBindingPatternFinish(Context& context, NodeKind node_kind) -> void { auto state = context.PopState(); - context.AddNode(node_kind, state.token, state.subtree_start, state.has_error); + context.AddNode(node_kind, state.token, state.has_error); // Propagate errors to the parent state so that they can take different // actions on invalid patterns. @@ -96,8 +96,7 @@ auto HandleBindingPatternFinishAsRegular(Context& context) -> void { auto HandleBindingPatternAddr(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::Addr, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::Addr, state.token, state.has_error); // If an error was encountered, propagate it while adding a node. if (state.has_error) { @@ -108,8 +107,7 @@ auto HandleBindingPatternAddr(Context& context) -> void { auto HandleBindingPatternTemplate(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::Template, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::Template, state.token, state.has_error); // If an error was encountered, propagate it while adding a node. if (state.has_error) { diff --git a/toolchain/parse/handle_brace_expr.cpp b/toolchain/parse/handle_brace_expr.cpp index fb8ef801706c8..b0f1ba9b517a1 100644 --- a/toolchain/parse/handle_brace_expr.cpp +++ b/toolchain/parse/handle_brace_expr.cpp @@ -151,8 +151,7 @@ static auto HandleBraceExprParamFinish(Context& context, NodeKind node_kind, /*has_error=*/true); context.ReturnErrorOnState(); } else { - context.AddNode(node_kind, state.token, state.subtree_start, - /*has_error=*/false); + context.AddNode(node_kind, state.token, /*has_error=*/false); } if (context.ConsumeListToken( @@ -183,8 +182,7 @@ static auto HandleBraceExprFinish(Context& context, NodeKind start_kind, auto state = context.PopState(); context.ReplacePlaceholderNode(state.subtree_start, start_kind, state.token); - context.AddNode(end_kind, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(end_kind, context.Consume(), state.has_error); } auto HandleBraceExprFinishAsType(Context& context) -> void { diff --git a/toolchain/parse/handle_call_expr.cpp b/toolchain/parse/handle_call_expr.cpp index c480ff27ca37e..b02e06b261f8a 100644 --- a/toolchain/parse/handle_call_expr.cpp +++ b/toolchain/parse/handle_call_expr.cpp @@ -11,8 +11,7 @@ auto HandleCallExpr(Context& context) -> void { auto state = context.PopState(); context.PushState(state, State::CallExprFinish); - context.AddNode(NodeKind::CallExprStart, context.Consume(), - state.subtree_start, state.has_error); + context.AddNode(NodeKind::CallExprStart, context.Consume(), state.has_error); if (!context.PositionIs(Lex::TokenKind::CloseParen)) { context.PushState(State::CallExprParamFinish); context.PushState(State::Expr); @@ -37,8 +36,7 @@ auto HandleCallExprParamFinish(Context& context) -> void { auto HandleCallExprFinish(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::CallExpr, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(NodeKind::CallExpr, context.Consume(), state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_choice.cpp b/toolchain/parse/handle_choice.cpp index a8a646055b70e..7ea27e492c335 100644 --- a/toolchain/parse/handle_choice.cpp +++ b/toolchain/parse/handle_choice.cpp @@ -24,17 +24,17 @@ auto HandleChoiceDefinitionStart(Context& context) -> void { } context.AddNode(NodeKind::ChoiceDefinitionStart, *context.position(), - state.subtree_start, /*has_error=*/true); + /*has_error=*/true); context.AddNode(NodeKind::ChoiceDefinition, *context.position(), - state.subtree_start, /*has_error=*/true); + /*has_error=*/true); context.SkipPastLikelyEnd(*context.position()); return; } context.AddNode(NodeKind::ChoiceDefinitionStart, context.Consume(), - state.subtree_start, state.has_error); + state.has_error); state.has_error = false; state.state = State::ChoiceDefinitionFinish; @@ -94,6 +94,6 @@ auto HandleChoiceDefinitionFinish(Context& context) -> void { context.AddNode(NodeKind::ChoiceDefinition, context.ConsumeChecked(Lex::TokenKind::CloseCurlyBrace), - state.subtree_start, state.has_error); + state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_code_block.cpp b/toolchain/parse/handle_code_block.cpp index 2772ead4f2ab0..ca8974eecdd41 100644 --- a/toolchain/parse/handle_code_block.cpp +++ b/toolchain/parse/handle_code_block.cpp @@ -31,11 +31,9 @@ auto HandleCodeBlockFinish(Context& context) -> void { // If the block started with an open curly, this is a close curly. if (context.tokens().GetKind(state.token) == Lex::TokenKind::OpenCurlyBrace) { - context.AddNode(NodeKind::CodeBlock, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(NodeKind::CodeBlock, context.Consume(), state.has_error); } else { - context.AddNode(NodeKind::CodeBlock, state.token, state.subtree_start, - /*has_error=*/true); + context.AddNode(NodeKind::CodeBlock, state.token, /*has_error=*/true); } } diff --git a/toolchain/parse/handle_decl_definition.cpp b/toolchain/parse/handle_decl_definition.cpp index 822a9703a94e1..dd55fc36faf53 100644 --- a/toolchain/parse/handle_decl_definition.cpp +++ b/toolchain/parse/handle_decl_definition.cpp @@ -23,8 +23,7 @@ static auto HandleDeclOrDefinition(Context& context, NodeKind decl_kind, context.PushState(state, definition_finish_state); context.PushState(State::DeclScopeLoop); - context.AddNode(definition_start_kind, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(definition_start_kind, context.Consume(), state.has_error); } auto HandleDeclOrDefinitionAsClass(Context& context) -> void { @@ -56,8 +55,7 @@ static auto HandleDeclDefinitionFinish(Context& context, NodeKind definition_kind) -> void { auto state = context.PopState(); - context.AddNode(definition_kind, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(definition_kind, context.Consume(), state.has_error); } auto HandleDeclDefinitionFinishAsClass(Context& context) -> void { diff --git a/toolchain/parse/handle_decl_name_and_params.cpp b/toolchain/parse/handle_decl_name_and_params.cpp index 0706ee93970fa..b9cc659300c8b 100644 --- a/toolchain/parse/handle_decl_name_and_params.cpp +++ b/toolchain/parse/handle_decl_name_and_params.cpp @@ -41,7 +41,7 @@ auto HandleDeclNameAndParams(Context& context) -> void { case Lex::TokenKind::Period: context.AddNode(NodeKind::NameQualifier, context.ConsumeChecked(Lex::TokenKind::Period), - state.subtree_start, state.has_error); + state.has_error); context.PushState(State::DeclNameAndParams); break; @@ -83,8 +83,7 @@ auto HandleDeclNameAndParamsAfterParams(Context& context) -> void { auto state = context.PopState(); if (auto period = context.ConsumeIf(Lex::TokenKind::Period)) { - context.AddNode(NodeKind::NameQualifier, *period, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::NameQualifier, *period, state.has_error); context.PushState(State::DeclNameAndParams); } } diff --git a/toolchain/parse/handle_decl_scope_loop.cpp b/toolchain/parse/handle_decl_scope_loop.cpp index 45d899bfc0692..2f6dc305930dc 100644 --- a/toolchain/parse/handle_decl_scope_loop.cpp +++ b/toolchain/parse/handle_decl_scope_loop.cpp @@ -18,8 +18,7 @@ static auto FinishAndSkipInvalidDecl(Context& context, int32_t subtree_start) context.ReplacePlaceholderNode(subtree_start, NodeKind::InvalidParseStart, cursor, /*has_error=*/true); context.AddNode(NodeKind::InvalidParseSubtree, - context.SkipPastLikelyEnd(cursor), subtree_start, - /*has_error=*/true); + context.SkipPastLikelyEnd(cursor), /*has_error=*/true); } // Prints a diagnostic and calls FinishAndSkipInvalidDecl. @@ -177,6 +176,7 @@ static auto ResolveAmbiguousTokenAsDeclaration(Context& context, case Lex::TokenKind::Alias: case Lex::TokenKind::Class: case Lex::TokenKind::Constraint: + case Lex::TokenKind::Extern: case Lex::TokenKind::Fn: case Lex::TokenKind::Import: case Lex::TokenKind::Interface: @@ -221,6 +221,22 @@ static auto TryHandleAsModifier(Context& context) -> bool { return true; #include "toolchain/parse/node_kind.def" + case Lex::TokenKind::Extern: { + auto extern_token = context.Consume(); + if (context.PositionIs(Lex::TokenKind::Library)) { + // `extern library ` syntax. + context.ParseLibrarySpecifier(/*accept_default=*/true); + // TODO: Consider error recovery when a non-declaration token is next, + // like a typo of the library name. + context.AddNode(NodeKind::ExternModifierWithLibrary, extern_token, + /*has_error=*/false); + } else { + // `extern` syntax without a library. + context.AddLeafNode(NodeKind::ExternModifier, extern_token); + } + return true; + } + default: return false; } diff --git a/toolchain/parse/handle_expr.cpp b/toolchain/parse/handle_expr.cpp index 890f0b3039163..7c69771a0e5e3 100644 --- a/toolchain/parse/handle_expr.cpp +++ b/toolchain/parse/handle_expr.cpp @@ -276,12 +276,12 @@ auto HandleExprLoop(Context& context) -> void { // node so that checking can insert control flow here. case Lex::TokenKind::And: context.AddNode(NodeKind::ShortCircuitOperandAnd, state.token, - state.subtree_start, state.has_error); + state.has_error); state.state = State::ExprLoopForShortCircuitOperatorAsAnd; break; case Lex::TokenKind::Or: context.AddNode(NodeKind::ShortCircuitOperandOr, state.token, - state.subtree_start, state.has_error); + state.has_error); state.state = State::ExprLoopForShortCircuitOperatorAsOr; break; @@ -307,8 +307,7 @@ auto HandleExprLoop(Context& context) -> void { << operator_kind; } - context.AddNode(node_kind, state.token, state.subtree_start, - state.has_error); + context.AddNode(node_kind, state.token, state.has_error); state.has_error = false; context.PushState(state); } @@ -318,7 +317,7 @@ auto HandleExprLoop(Context& context) -> void { static auto HandleExprLoopForOperator(Context& context, Context::StateStackEntry state, NodeKind node_kind) -> void { - context.AddNode(node_kind, state.token, state.subtree_start, state.has_error); + context.AddNode(node_kind, state.token, state.has_error); state.has_error = false; context.PushState(state, State::ExprLoop); } @@ -371,8 +370,7 @@ auto HandleExprLoopForShortCircuitOperatorAsOr(Context& context) -> void { auto HandleIfExprFinishCondition(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::IfExprIf, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::IfExprIf, state.token, state.has_error); if (context.PositionIs(Lex::TokenKind::Then)) { context.PushState(State::IfExprFinishThen); @@ -397,8 +395,7 @@ auto HandleIfExprFinishCondition(Context& context) -> void { auto HandleIfExprFinishThen(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::IfExprThen, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::IfExprThen, state.token, state.has_error); if (context.PositionIs(Lex::TokenKind::Else)) { context.PushState(State::IfExprFinishElse); @@ -431,16 +428,14 @@ auto HandleIfExprFinishElse(Context& context) -> void { auto HandleIfExprFinish(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::IfExprElse, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::IfExprElse, state.token, state.has_error); } auto HandleExprStatementFinish(Context& context) -> void { auto state = context.PopState(); if (auto semi = context.ConsumeIf(Lex::TokenKind::Semi)) { - context.AddNode(NodeKind::ExprStatement, *semi, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ExprStatement, *semi, state.has_error); return; } @@ -451,8 +446,7 @@ auto HandleExprStatementFinish(Context& context) -> void { } context.AddNode(NodeKind::ExprStatement, - context.SkipPastLikelyEnd(state.token), state.subtree_start, - /*has_error=*/true); + context.SkipPastLikelyEnd(state.token), /*has_error=*/true); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_function.cpp b/toolchain/parse/handle_function.cpp index 14fe977b7fd86..6d4e9caaddc8c 100644 --- a/toolchain/parse/handle_function.cpp +++ b/toolchain/parse/handle_function.cpp @@ -31,8 +31,7 @@ auto HandleFunctionAfterParams(Context& context) -> void { auto HandleFunctionReturnTypeFinish(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::ReturnType, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ReturnType, state.token, state.has_error); } auto HandleFunctionSignatureFinish(Context& context) -> void { @@ -41,12 +40,11 @@ auto HandleFunctionSignatureFinish(Context& context) -> void { switch (context.PositionKind()) { case Lex::TokenKind::Semi: { context.AddNode(NodeKind::FunctionDecl, context.Consume(), - state.subtree_start, state.has_error); + state.has_error); break; } case Lex::TokenKind::OpenCurlyBrace: { - context.AddFunctionDefinitionStart(context.Consume(), state.subtree_start, - state.has_error); + context.AddFunctionDefinitionStart(context.Consume(), state.has_error); // Any error is recorded on the FunctionDefinitionStart. state.has_error = false; context.PushState(state, State::FunctionDefinitionFinish); @@ -55,7 +53,7 @@ auto HandleFunctionSignatureFinish(Context& context) -> void { } case Lex::TokenKind::Equal: { context.AddNode(NodeKind::BuiltinFunctionDefinitionStart, - context.Consume(), state.subtree_start, state.has_error); + context.Consume(), state.has_error); if (!context.ConsumeAndAddLeafNodeIf(Lex::TokenKind::StringLiteral, NodeKind::BuiltinName)) { CARBON_DIAGNOSTIC(ExpectedBuiltinName, Error, @@ -73,7 +71,7 @@ auto HandleFunctionSignatureFinish(Context& context) -> void { /*skip_past_likely_end=*/true); } else { context.AddNode(NodeKind::BuiltinFunctionDefinition, *semi, - state.subtree_start, state.has_error); + state.has_error); } break; } @@ -94,8 +92,7 @@ auto HandleFunctionSignatureFinish(Context& context) -> void { auto HandleFunctionDefinitionFinish(Context& context) -> void { auto state = context.PopState(); - context.AddFunctionDefinition(context.Consume(), state.subtree_start, - state.has_error); + context.AddFunctionDefinition(context.Consume(), state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_impl.cpp b/toolchain/parse/handle_impl.cpp index e186e0a60c523..bd1a7b49a3be4 100644 --- a/toolchain/parse/handle_impl.cpp +++ b/toolchain/parse/handle_impl.cpp @@ -54,8 +54,7 @@ auto HandleImplAfterForall(Context& context) -> void { if (state.has_error) { context.ReturnErrorOnState(); } - context.AddNode(NodeKind::ImplForall, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ImplForall, state.token, state.has_error); // One of: // as ... // as ... @@ -65,8 +64,7 @@ auto HandleImplAfterForall(Context& context) -> void { auto HandleImplBeforeAs(Context& context) -> void { auto state = context.PopState(); if (auto as = context.ConsumeIf(Lex::TokenKind::As)) { - context.AddNode(NodeKind::TypeImplAs, *as, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::TypeImplAs, *as, state.has_error); context.PushState(State::Expr); } else { if (!state.has_error) { diff --git a/toolchain/parse/handle_import_and_package.cpp b/toolchain/parse/handle_import_and_package.cpp index 4ccba7b1ad7ce..f60f649b14e55 100644 --- a/toolchain/parse/handle_import_and_package.cpp +++ b/toolchain/parse/handle_import_and_package.cpp @@ -16,7 +16,7 @@ namespace Carbon::Parse { static auto OnParseError(Context& context, Context::StateStackEntry state, NodeKind declaration) -> void { return context.AddNode(declaration, context.SkipPastLikelyEnd(state.token), - state.subtree_start, /*has_error=*/true); + /*has_error=*/true); } // Determines whether the specified modifier appears within the introducer of @@ -34,34 +34,6 @@ static auto HasModifier(Context& context, Context::StateStackEntry state, return false; } -// Handles parsing of the library name. Returns the name's ID on success, which -// may be invalid for `default`. -static auto HandleLibraryName(Context& context, bool accept_default) - -> std::optional { - if (auto library_name_token = - context.ConsumeIf(Lex::TokenKind::StringLiteral)) { - context.AddLeafNode(NodeKind::LibraryName, *library_name_token); - return context.tokens().GetStringLiteralValue(*library_name_token); - } - - if (accept_default) { - if (auto default_token = context.ConsumeIf(Lex::TokenKind::Default)) { - context.AddLeafNode(NodeKind::DefaultLibrary, *default_token); - return StringLiteralValueId::Invalid; - } - } - - CARBON_DIAGNOSTIC( - ExpectedLibraryNameOrDefault, Error, - "Expected `default` or a string literal to specify the library name."); - CARBON_DIAGNOSTIC(ExpectedLibraryName, Error, - "Expected a string literal to specify the library name."); - context.emitter().Emit(*context.position(), accept_default - ? ExpectedLibraryNameOrDefault - : ExpectedLibraryName); - return std::nullopt; -} - // Handles everything after the declaration's introducer. static auto HandleDeclContent(Context& context, Context::StateStackEntry state, NodeKind declaration, bool is_export, @@ -102,7 +74,7 @@ static auto HandleDeclContent(Context& context, Context::StateStackEntry state, // Parse the optional library keyword. bool accept_default = !names.package_id.is_valid(); if (declaration == NodeKind::LibraryDecl) { - auto library_id = HandleLibraryName(context, accept_default); + auto library_id = context.ParseLibraryName(accept_default); if (!library_id) { on_parse_error(); return; @@ -111,17 +83,12 @@ static auto HandleDeclContent(Context& context, Context::StateStackEntry state, } else { auto next_kind = context.PositionKind(); if (next_kind == Lex::TokenKind::Library) { - auto library_token = context.ConsumeChecked(Lex::TokenKind::Library); - auto library_subtree_start = context.tree().size(); - auto library_id = HandleLibraryName(context, accept_default); - if (!library_id) { + if (auto library_id = context.ParseLibrarySpecifier(accept_default)) { + names.library_id = *library_id; + } else { on_parse_error(); return; } - names.library_id = *library_id; - context.AddNode(NodeKind::LibrarySpecifier, library_token, - library_subtree_start, - /*has_error=*/false); } else if (next_kind == Lex::TokenKind::StringLiteral || (accept_default && next_kind == Lex::TokenKind::Default)) { // If we come across a string literal and we didn't parse `library @@ -142,7 +109,7 @@ static auto HandleDeclContent(Context& context, Context::StateStackEntry state, context.set_packaging_decl(names, is_impl); } - context.AddNode(declaration, *semi, state.subtree_start, state.has_error); + context.AddNode(declaration, *semi, state.has_error); } else { context.DiagnoseExpectedDeclSemi(context.tokens().GetKind(state.token)); on_parse_error(); diff --git a/toolchain/parse/handle_index_expr.cpp b/toolchain/parse/handle_index_expr.cpp index 6a03633fabb70..5a92324995e82 100644 --- a/toolchain/parse/handle_index_expr.cpp +++ b/toolchain/parse/handle_index_expr.cpp @@ -13,7 +13,7 @@ auto HandleIndexExpr(Context& context) -> void { context.PushState(state, State::IndexExprFinish); context.AddNode(NodeKind::IndexExprStart, context.ConsumeChecked(Lex::TokenKind::OpenSquareBracket), - state.subtree_start, state.has_error); + state.has_error); context.PushState(State::Expr); } diff --git a/toolchain/parse/handle_let.cpp b/toolchain/parse/handle_let.cpp index 5a529bec6d740..72a587c918799 100644 --- a/toolchain/parse/handle_let.cpp +++ b/toolchain/parse/handle_let.cpp @@ -45,8 +45,7 @@ auto HandleLetFinish(Context& context) -> void { state.has_error = true; end_token = context.SkipPastLikelyEnd(state.token); } - context.AddNode(NodeKind::LetDecl, end_token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::LetDecl, end_token, state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_match.cpp b/toolchain/parse/handle_match.cpp index 05d93f6d90d09..01f8733895ea5 100644 --- a/toolchain/parse/handle_match.cpp +++ b/toolchain/parse/handle_match.cpp @@ -20,8 +20,8 @@ static auto HandleStatementsBlockStart(Context& context, State finish, } context.AddLeafNode(equal_greater, *context.position(), true); - context.AddNode(starter, *context.position(), state.subtree_start, true); - context.AddNode(complete, *context.position(), state.subtree_start, true); + context.AddNode(starter, *context.position(), true); + context.AddNode(complete, *context.position(), true); context.SkipPastLikelyEnd(*context.position()); return; } @@ -35,14 +35,13 @@ static auto HandleStatementsBlockStart(Context& context, State finish, context.emitter().Emit(*context.position(), ExpectedMatchCaseBlock); } - context.AddNode(starter, *context.position(), state.subtree_start, true); - context.AddNode(complete, *context.position(), state.subtree_start, true); + context.AddNode(starter, *context.position(), true); + context.AddNode(complete, *context.position(), true); context.SkipPastLikelyEnd(*context.position()); return; } - context.AddNode(starter, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(starter, context.Consume(), state.has_error); context.PushState(state, finish); context.PushState(State::StatementScopeLoop); } @@ -77,16 +76,14 @@ auto HandleMatchConditionFinish(Context& context) -> void { context.emitter().Emit(*context.position(), ExpectedMatchCasesBlock); } - context.AddNode(NodeKind::MatchStatementStart, *context.position(), - state.subtree_start, true); - context.AddNode(NodeKind::MatchStatement, *context.position(), - state.subtree_start, true); + context.AddNode(NodeKind::MatchStatementStart, *context.position(), true); + context.AddNode(NodeKind::MatchStatement, *context.position(), true); context.SkipPastLikelyEnd(*context.position()); return; } context.AddNode(NodeKind::MatchStatementStart, context.Consume(), - state.subtree_start, state.has_error); + state.has_error); state.has_error = false; if (context.PositionIs(Lex::TokenKind::CloseCurlyBrace)) { @@ -145,10 +142,8 @@ auto HandleMatchCaseIntroducer(Context& context) -> void { auto HandleMatchCaseAfterPattern(Context& context) -> void { auto state = context.PopState(); if (state.has_error) { - context.AddNode(NodeKind::MatchCaseStart, *context.position(), - state.subtree_start, true); - context.AddNode(NodeKind::MatchCase, *context.position(), - state.subtree_start, true); + context.AddNode(NodeKind::MatchCaseStart, *context.position(), true); + context.AddNode(NodeKind::MatchCase, *context.position(), true); context.SkipPastLikelyEnd(*context.position()); return; } @@ -166,13 +161,10 @@ auto HandleMatchCaseAfterPattern(Context& context) -> void { true); context.AddLeafNode(NodeKind::InvalidParse, *context.position(), true); state = context.PopState(); - context.AddNode(NodeKind::MatchCaseGuard, *context.position(), - state.subtree_start, true); + context.AddNode(NodeKind::MatchCaseGuard, *context.position(), true); state = context.PopState(); - context.AddNode(NodeKind::MatchCaseStart, *context.position(), - state.subtree_start, true); - context.AddNode(NodeKind::MatchCase, *context.position(), - state.subtree_start, true); + context.AddNode(NodeKind::MatchCaseStart, *context.position(), true); + context.AddNode(NodeKind::MatchCase, *context.position(), true); context.SkipPastLikelyEnd(*context.position()); return; } @@ -184,11 +176,9 @@ auto HandleMatchCaseGuardFinish(Context& context) -> void { auto close_paren = context.ConsumeIf(Lex::TokenKind::CloseParen); if (close_paren) { - context.AddNode(NodeKind::MatchCaseGuard, *close_paren, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::MatchCaseGuard, *close_paren, state.has_error); } else { - context.AddNode(NodeKind::MatchCaseGuard, *context.position(), - state.subtree_start, true); + context.AddNode(NodeKind::MatchCaseGuard, *context.position(), true); context.ReturnErrorOnState(); context.SkipPastLikelyEnd(*context.position()); return; @@ -205,7 +195,7 @@ auto HandleMatchCaseFinish(Context& context) -> void { auto state = context.PopState(); context.AddNode(NodeKind::MatchCase, context.ConsumeChecked(Lex::TokenKind::CloseCurlyBrace), - state.subtree_start, state.has_error); + state.has_error); } auto HandleMatchDefaultIntroducer(Context& context) -> void { @@ -220,14 +210,14 @@ auto HandleMatchDefaultFinish(Context& context) -> void { auto state = context.PopState(); context.AddNode(NodeKind::MatchDefault, context.ConsumeChecked(Lex::TokenKind::CloseCurlyBrace), - state.subtree_start, state.has_error); + state.has_error); } auto HandleMatchStatementFinish(Context& context) -> void { auto state = context.PopState(); context.AddNode(NodeKind::MatchStatement, context.ConsumeChecked(Lex::TokenKind::CloseCurlyBrace), - state.subtree_start, state.has_error); + state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_paren_expr.cpp b/toolchain/parse/handle_paren_expr.cpp index b09b8eae48d86..e54510c1a18f5 100644 --- a/toolchain/parse/handle_paren_expr.cpp +++ b/toolchain/parse/handle_paren_expr.cpp @@ -21,8 +21,7 @@ auto HandleOnlyParenExpr(Context& context) -> void { static auto FinishParenExpr(Context& context, const Context::StateStackEntry& state) -> void { - context.AddNode(NodeKind::ParenExpr, context.Consume(), state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ParenExpr, context.Consume(), state.has_error); } auto HandleOnlyParenExprFinish(Context& context) -> void { @@ -108,8 +107,7 @@ auto HandleTupleLiteralFinish(Context& context) -> void { context.ReplacePlaceholderNode(state.subtree_start, NodeKind::TupleLiteralStart, state.token); - context.AddNode(NodeKind::TupleLiteral, context.Consume(), - state.subtree_start, state.has_error); + context.AddNode(NodeKind::TupleLiteral, context.Consume(), state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_pattern_list.cpp b/toolchain/parse/handle_pattern_list.cpp index 20cf25a23dc80..5ad16769b375c 100644 --- a/toolchain/parse/handle_pattern_list.cpp +++ b/toolchain/parse/handle_pattern_list.cpp @@ -88,7 +88,7 @@ static auto HandlePatternListFinish(Context& context, NodeKind node_kind, auto state = context.PopState(); context.AddNode(node_kind, context.ConsumeChecked(token_kind), - state.subtree_start, state.has_error); + state.has_error); } auto HandlePatternListFinishAsImplicit(Context& context) -> void { diff --git a/toolchain/parse/handle_period.cpp b/toolchain/parse/handle_period.cpp index 0c5890e6573c8..28e821a013622 100644 --- a/toolchain/parse/handle_period.cpp +++ b/toolchain/parse/handle_period.cpp @@ -23,6 +23,9 @@ static auto HandlePeriodOrArrow(Context& context, NodeKind node_kind, // OK, `.` identifier. } else if (context.ConsumeAndAddLeafNodeIf(Lex::TokenKind::Base, NodeKind::BaseName)) { + // OK, '.42'. + } else if (context.ConsumeAndAddLeafNodeIf(Lex::TokenKind::IntLiteral, + NodeKind::IntLiteral)) { // OK, `.base`. } else if (paren_state != State::Invalid && context.PositionIs(Lex::TokenKind::OpenParen)) { @@ -50,7 +53,7 @@ static auto HandlePeriodOrArrow(Context& context, NodeKind node_kind, } } - context.AddNode(node_kind, dot, state.subtree_start, state.has_error); + context.AddNode(node_kind, dot, state.has_error); } auto HandlePeriodAsExpr(Context& context) -> void { @@ -72,14 +75,13 @@ auto HandleArrowExpr(Context& context) -> void { auto HandleCompoundMemberAccess(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::MemberAccessExpr, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::MemberAccessExpr, state.token, state.has_error); } auto HandleCompoundPointerMemberAccess(Context& context) -> void { auto state = context.PopState(); context.AddNode(NodeKind::PointerMemberAccessExpr, state.token, - state.subtree_start, state.has_error); + state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_statement.cpp b/toolchain/parse/handle_statement.cpp index 7b8da294241db..4cfeb7822a07f 100644 --- a/toolchain/parse/handle_statement.cpp +++ b/toolchain/parse/handle_statement.cpp @@ -85,7 +85,7 @@ static auto HandleStatementKeywordFinish(Context& context, NodeKind node_kind) // Recover to the next semicolon if possible. semi = context.SkipPastLikelyEnd(state.token); } - context.AddNode(node_kind, *semi, state.subtree_start, state.has_error); + context.AddNode(node_kind, *semi, state.has_error); } auto HandleStatementBreakFinish(Context& context) -> void { @@ -141,8 +141,7 @@ auto HandleStatementForHeaderFinish(Context& context) -> void { auto HandleStatementForFinish(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::ForStatement, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ForStatement, state.token, state.has_error); } auto HandleStatementIf(Context& context) -> void { @@ -170,15 +169,13 @@ auto HandleStatementIfThenBlockFinish(Context& context) -> void { ? State::StatementIf : State::CodeBlock); } else { - context.AddNode(NodeKind::IfStatement, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::IfStatement, state.token, state.has_error); } } auto HandleStatementIfElseBlockFinish(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::IfStatement, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::IfStatement, state.token, state.has_error); } auto HandleStatementReturn(Context& context) -> void { @@ -234,8 +231,7 @@ auto HandleStatementWhileConditionFinish(Context& context) -> void { auto HandleStatementWhileBlockFinish(Context& context) -> void { auto state = context.PopState(); - context.AddNode(NodeKind::WhileStatement, state.token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::WhileStatement, state.token, state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/handle_var.cpp b/toolchain/parse/handle_var.cpp index 90712cff0d3bf..8b4c0e6ca175b 100644 --- a/toolchain/parse/handle_var.cpp +++ b/toolchain/parse/handle_var.cpp @@ -85,8 +85,7 @@ auto HandleVarFinishAsDecl(Context& context) -> void { state.has_error = true; end_token = context.SkipPastLikelyEnd(state.token); } - context.AddNode(NodeKind::VariableDecl, end_token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::VariableDecl, end_token, state.has_error); } auto HandleVarFinishAsFor(Context& context) -> void { @@ -108,8 +107,7 @@ auto HandleVarFinishAsFor(Context& context) -> void { state.has_error = true; } - context.AddNode(NodeKind::ForIn, end_token, state.subtree_start, - state.has_error); + context.AddNode(NodeKind::ForIn, end_token, state.has_error); } } // namespace Carbon::Parse diff --git a/toolchain/parse/node_ids.h b/toolchain/parse/node_ids.h index 3aaf3754ce78a..5835a1a61fae4 100644 --- a/toolchain/parse/node_ids.h +++ b/toolchain/parse/node_ids.h @@ -20,7 +20,7 @@ struct InvalidNodeId {}; // contain any of the information about the node, and serve as a handle that // can be used with the underlying tree to query for detailed information. struct NodeId : public IdBase { - // An explicitly invalid instance. + // An explicitly invalid node ID. static constexpr InvalidNodeId Invalid; using IdBase::IdBase; @@ -71,8 +71,9 @@ struct NodeIdInCategory : public NodeId { using AnyDeclId = NodeIdInCategory; using AnyExprId = NodeIdInCategory; using AnyImplAsId = NodeIdInCategory; -using AnyMemberNameOrMemberExprId = - NodeIdInCategory; +using AnyMemberAccessId = + NodeIdInCategory; using AnyModifierId = NodeIdInCategory; using AnyPatternId = NodeIdInCategory; using AnyStatementId = NodeIdInCategory; diff --git a/toolchain/parse/node_kind.def b/toolchain/parse/node_kind.def index 097daaf68ca8e..f92d31fbe6cac 100644 --- a/toolchain/parse/node_kind.def +++ b/toolchain/parse/node_kind.def @@ -208,13 +208,14 @@ CARBON_PARSE_NODE_KIND(CallExprStart) CARBON_PARSE_NODE_KIND(CallExprComma) CARBON_PARSE_NODE_KIND(CallExpr) +CARBON_PARSE_NODE_KIND(IntLiteral) + CARBON_PARSE_NODE_KIND(MemberAccessExpr) CARBON_PARSE_NODE_KIND(PointerMemberAccessExpr) CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(BoolLiteralFalse, False) CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(BoolLiteralTrue, True) -CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(IntLiteral, IntLiteral) CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(RealLiteral, RealLiteral) CARBON_PARSE_NODE_KIND_TOKEN_LITERAL(StringLiteral, StringLiteral) @@ -286,12 +287,14 @@ CARBON_PARSE_NODE_KIND(StructComma) CARBON_PARSE_NODE_KIND(StructLiteral) CARBON_PARSE_NODE_KIND(StructTypeLiteral) +CARBON_PARSE_NODE_KIND(ExternModifierWithLibrary) +CARBON_PARSE_NODE_KIND(ExternModifier) + CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Abstract) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Base) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Default) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Export) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Extend) -CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Extern) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Final) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Impl) CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Private) diff --git a/toolchain/parse/node_kind.h b/toolchain/parse/node_kind.h index 281713c74c508..d2d291ec2aeac 100644 --- a/toolchain/parse/node_kind.h +++ b/toolchain/parse/node_kind.h @@ -33,9 +33,10 @@ class NodeCategory : public Printable { Modifier = 1 << 5, Pattern = 1 << 6, Statement = 1 << 7, + IntConst = 1 << 8, None = 0, - LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Statement) + LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/IntConst) }; // Support implicit conversion so that the difference with the member enum is diff --git a/toolchain/parse/testdata/basics/fail_invalid_designators.carbon b/toolchain/parse/testdata/basics/fail_invalid_designators.carbon index f789aec319585..56e0e358d0917 100644 --- a/toolchain/parse/testdata/basics/fail_invalid_designators.carbon +++ b/toolchain/parse/testdata/basics/fail_invalid_designators.carbon @@ -15,15 +15,10 @@ fn F() { // CHECK:STDERR: ^ // CHECK:STDERR: a.; - // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+4]]:5: ERROR: Expected identifier after `.`. + // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+3]]:5: ERROR: Expected identifier after `.`. // CHECK:STDERR: a.fn; // CHECK:STDERR: ^~ - // CHECK:STDERR: a.fn; - // CHECK:STDERR: fail_invalid_designators.carbon:[[@LINE+3]]:5: ERROR: Expected identifier after `.`. - // CHECK:STDERR: a.42; - // CHECK:STDERR: ^~ - a.42; } // CHECK:STDOUT: - filename: fail_invalid_designators.carbon @@ -42,10 +37,6 @@ fn F() { // CHECK:STDOUT: {kind: 'IdentifierName', text: 'fn', has_error: yes}, // CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'}, -// CHECK:STDOUT: {kind: 'IdentifierName', text: '42', has_error: yes}, -// CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/function/declaration/basic.carbon b/toolchain/parse/testdata/function/declaration/basic.carbon index 38a051f9355a1..42aaefbd458a5 100644 --- a/toolchain/parse/testdata/function/declaration/basic.carbon +++ b/toolchain/parse/testdata/function/declaration/basic.carbon @@ -9,7 +9,6 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/function/declaration/basic.carbon fn F(); -extern fn G(); // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ @@ -19,11 +18,5 @@ extern fn G(); // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, -// CHECK:STDOUT: {kind: 'ExternModifier', text: 'extern'}, -// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, -// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, -// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/function/declaration/extern.carbon b/toolchain/parse/testdata/function/declaration/extern.carbon new file mode 100644 index 0000000000000..4e9ebcab0966d --- /dev/null +++ b/toolchain/parse/testdata/function/declaration/extern.carbon @@ -0,0 +1,101 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/function/declaration/extern.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/function/declaration/extern.carbon + +// --- extern.carbon + +extern fn G(); + +// --- library.carbon + +extern library "foo" fn G(); + +// --- default_library.carbon + +extern library default fn G(); + +// --- fail_name_missing.carbon + +// CHECK:STDERR: fail_name_missing.carbon:[[@LINE+4]]:16: ERROR: Expected `default` or a string literal to specify the library name. +// CHECK:STDERR: extern library fn G(); +// CHECK:STDERR: ^~ +// CHECK:STDERR: +extern library fn G(); + +// --- fail_identifier.carbon + +// CHECK:STDERR: fail_identifier.carbon:[[@LINE+7]]:16: ERROR: Expected `default` or a string literal to specify the library name. +// CHECK:STDERR: extern library foo fn G(); +// CHECK:STDERR: ^~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_identifier.carbon:[[@LINE+3]]:16: ERROR: Unrecognized declaration introducer. +// CHECK:STDERR: extern library foo fn G(); +// CHECK:STDERR: ^~~ +extern library foo fn G(); + +// CHECK:STDOUT: - filename: extern.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, +// CHECK:STDOUT: {kind: 'ExternModifier', text: 'extern'}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: library.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, +// CHECK:STDOUT: {kind: 'LibraryName', text: '"foo"'}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'ExternModifierWithLibrary', text: 'extern', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: default_library.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, +// CHECK:STDOUT: {kind: 'DefaultLibrary', text: 'default'}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'ExternModifierWithLibrary', text: 'extern', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: fail_name_missing.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, +// CHECK:STDOUT: {kind: 'LibraryName', text: 'fn', has_error: yes}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'ExternModifierWithLibrary', text: 'extern', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: fail_identifier.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'InvalidParseStart', text: 'foo', has_error: yes}, +// CHECK:STDOUT: {kind: 'LibraryName', text: 'foo', has_error: yes}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'ExternModifierWithLibrary', text: 'extern', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'InvalidParseSubtree', text: ';', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/function/definition/basic.carbon b/toolchain/parse/testdata/function/definition/basic.carbon index d4c42806db0c7..135d9643022c9 100644 --- a/toolchain/parse/testdata/function/definition/basic.carbon +++ b/toolchain/parse/testdata/function/definition/basic.carbon @@ -9,7 +9,6 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/function/definition/basic.carbon fn F() {} -extern fn G() {} // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ @@ -20,12 +19,5 @@ extern fn G() {} // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, -// CHECK:STDOUT: {kind: 'ExternModifier', text: 'extern'}, -// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, -// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, -// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 7}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/function/definition/extern.carbon b/toolchain/parse/testdata/function/definition/extern.carbon new file mode 100644 index 0000000000000..3e93334769fe7 --- /dev/null +++ b/toolchain/parse/testdata/function/definition/extern.carbon @@ -0,0 +1,44 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/function/definition/extern.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/function/definition/extern.carbon + +// --- extern.carbon + +extern fn G() {} + +// --- library.carbon + +extern library "foo" fn G() {} + +// CHECK:STDOUT: - filename: extern.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, +// CHECK:STDOUT: {kind: 'ExternModifier', text: 'extern'}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: - filename: library.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, +// CHECK:STDOUT: {kind: 'LibraryName', text: '"foo"'}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'ExternModifierWithLibrary', text: 'extern', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'G'}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/index/tuple_index.carbon b/toolchain/parse/testdata/index/tuple_index.carbon new file mode 100644 index 0000000000000..004d11c2abe9f --- /dev/null +++ b/toolchain/parse/testdata/index/tuple_index.carbon @@ -0,0 +1,26 @@ +// 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 +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/index/tuple_index.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/index/tuple_index.carbon + +let first: i32 = tuple.0; + +// CHECK:STDOUT: - filename: tuple_index.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'LetIntroducer', text: 'let'}, +// CHECK:STDOUT: {kind: 'IdentifierName', text: 'first'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'LetInitializer', text: '='}, +// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'tuple'}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, +// CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'LetDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/packages/import/fail_library_is_identifier.carbon b/toolchain/parse/testdata/packages/import/fail_library_is_identifier.carbon index 417044a989eb8..de2d019caa76f 100644 --- a/toolchain/parse/testdata/packages/import/fail_library_is_identifier.carbon +++ b/toolchain/parse/testdata/packages/import/fail_library_is_identifier.carbon @@ -18,6 +18,8 @@ import Geometry library Shapes; // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'}, // CHECK:STDOUT: {kind: 'PackageName', text: 'Geometry'}, -// CHECK:STDOUT: {kind: 'ImportDecl', text: ';', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'LibraryName', text: 'Shapes', has_error: yes}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'ImportDecl', text: ';', has_error: yes, subtree_size: 5}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/packages/package/fail_library_is_identifier.carbon b/toolchain/parse/testdata/packages/package/fail_library_is_identifier.carbon index 400ddf1368195..456d5c68ea73b 100644 --- a/toolchain/parse/testdata/packages/package/fail_library_is_identifier.carbon +++ b/toolchain/parse/testdata/packages/package/fail_library_is_identifier.carbon @@ -18,6 +18,8 @@ package Geometry library Shapes; // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'PackageName', text: 'Geometry'}, -// CHECK:STDOUT: {kind: 'PackageDecl', text: ';', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'LibraryName', text: 'Shapes', has_error: yes}, +// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'PackageDecl', text: ';', has_error: yes, subtree_size: 5}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/tree.cpp b/toolchain/parse/tree.cpp index 7a1f248f54ed1..2edaf51417413 100644 --- a/toolchain/parse/tree.cpp +++ b/toolchain/parse/tree.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/SmallVector.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/node_kind.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/parse/typed_nodes.h" namespace Carbon::Parse { @@ -20,32 +21,6 @@ auto Tree::postorder() const -> llvm::iterator_range { PostorderIterator(NodeId(node_impls_.size()))); } -auto Tree::postorder(NodeId n) const - -> llvm::iterator_range { - CARBON_CHECK(n.is_valid()); - // The postorder ends after this node, the root, and begins at the start of - // its subtree. - int end_index = n.index + 1; - int start_index = end_index - node_impls_[n.index].subtree_size; - return llvm::iterator_range( - PostorderIterator(NodeId(start_index)), - PostorderIterator(NodeId(end_index))); -} - -auto Tree::children(NodeId n) const -> llvm::iterator_range { - CARBON_CHECK(n.is_valid()); - int end_index = n.index - node_impls_[n.index].subtree_size; - return llvm::iterator_range( - SiblingIterator(*this, NodeId(n.index - 1)), - SiblingIterator(*this, NodeId(end_index))); -} - -auto Tree::roots() const -> llvm::iterator_range { - return llvm::iterator_range( - SiblingIterator(*this, NodeId(static_cast(node_impls_.size()) - 1)), - SiblingIterator(*this, NodeId(-1))); -} - auto Tree::node_has_error(NodeId n) const -> bool { CARBON_CHECK(n.is_valid()); return node_impls_[n.index].has_error; @@ -61,244 +36,55 @@ auto Tree::node_token(NodeId n) const -> Lex::TokenIndex { return node_impls_[n.index].token; } -auto Tree::node_subtree_size(NodeId n) const -> int32_t { - CARBON_CHECK(n.is_valid()); - return node_impls_[n.index].subtree_size; -} - -auto Tree::PrintNode(llvm::raw_ostream& output, NodeId n, int depth, - bool preorder) const -> bool { - const auto& n_impl = node_impls_[n.index]; - output.indent(2 * (depth + 2)); - output << "{"; - // If children are being added, include node_index in order to disambiguate - // nodes. - if (preorder) { - output << "node_index: " << n << ", "; - } - output << "kind: '" << n_impl.kind << "', text: '" - << tokens_->GetTokenText(n_impl.token) << "'"; - - if (n_impl.has_error) { - output << ", has_error: yes"; - } - - if (n_impl.subtree_size > 1) { - output << ", subtree_size: " << n_impl.subtree_size; - if (preorder) { - output << ", children: [\n"; - return true; - } - } - output << "}"; - return false; -} - auto Tree::Print(llvm::raw_ostream& output) const -> void { - output << "- filename: " << tokens_->source().filename() << "\n" - << " parse_tree: [\n"; - - // Walk the tree just to calculate depths for each node. - llvm::SmallVector indents; - indents.append(size(), 0); - - llvm::SmallVector, 16> node_stack; - for (NodeId n : roots()) { - node_stack.push_back({n, 0}); - } - - while (!node_stack.empty()) { - NodeId n = NodeId::Invalid; - int depth; - std::tie(n, depth) = node_stack.pop_back_val(); - for (NodeId sibling_n : children(n)) { - indents[sibling_n.index] = depth + 1; - node_stack.push_back({sibling_n, depth + 1}); - } - } - - for (NodeId n : postorder()) { - PrintNode(output, n, indents[n.index], /*preorder=*/false); - output << ",\n"; - } - output << " ]\n"; -} - -auto Tree::Print(llvm::raw_ostream& output, bool preorder) const -> void { - if (!preorder) { - Print(output); - return; - } - - output << "- filename: " << tokens_->source().filename() << "\n" - << " parse_tree: [\n"; - - // The parse tree is stored in postorder. The preorder can be constructed - // by reversing the order of each level of siblings within an RPO. The - // sibling iterators are directly built around RPO and so can be used with a - // stack to produce preorder. - - // The roots, like siblings, are in RPO (so reversed), but we add them in - // order here because we'll pop off the stack effectively reversing then. - llvm::SmallVector, 16> node_stack; - for (NodeId n : roots()) { - node_stack.push_back({n, 0}); - } - - while (!node_stack.empty()) { - NodeId n = NodeId::Invalid; - int depth; - std::tie(n, depth) = node_stack.pop_back_val(); - - if (PrintNode(output, n, depth, /*preorder=*/true)) { - // Has children, so we descend. We append the children in order here as - // well because they will get reversed when popped off the stack. - for (NodeId sibling_n : children(n)) { - node_stack.push_back({sibling_n, depth + 1}); - } - continue; - } - - int next_depth = node_stack.empty() ? 0 : node_stack.back().second; - CARBON_CHECK(next_depth <= depth) << "Cannot have the next depth increase!"; - for (int close_children_count : llvm::seq(0, depth - next_depth)) { - (void)close_children_count; - output << "]}"; - } - - // We always end with a comma and a new line as we'll move to the next - // node at whatever the current level ends up being. - output << " ,\n"; - } - output << " ]\n"; -} - -auto Tree::VerifyExtract(NodeId node_id, NodeKind kind, - ErrorBuilder* trace) const -> bool { - switch (kind) { -#define CARBON_PARSE_NODE_KIND(Name) \ - case NodeKind::Name: \ - return VerifyExtractAs(node_id, trace).has_value(); -#include "toolchain/parse/node_kind.def" - } + TreeAndSubtrees(*tokens_, *this).Print(output); } auto Tree::Verify() const -> ErrorOr { llvm::SmallVector nodes; // Traverse the tree in postorder. for (NodeId n : postorder()) { - const auto& n_impl = node_impls_[n.index]; - - if (n_impl.has_error && !has_errors_) { + if (node_has_error(n) && !has_errors()) { return Error(llvm::formatv( - "NodeId #{0} has errors, but the tree is not marked as having any.", - n.index)); + "Node {0} has errors, but the tree is not marked as having any.", n)); } - if (n_impl.kind == NodeKind::Placeholder) { + if (node_kind(n) == NodeKind::Placeholder) { return Error(llvm::formatv( - "Node #{0} is a placeholder node that wasn't replaced.", n.index)); + "Node {0} is a placeholder node that wasn't replaced.", n)); } - // Should extract successfully if node not marked as having an error. - // Without this code, a 10 mloc test case of lex & parse takes - // 4.129 s ± 0.041 s. With this additional verification, it takes - // 5.768 s ± 0.036 s. - if (!n_impl.has_error && !VerifyExtract(n, n_impl.kind, nullptr)) { - ErrorBuilder trace; - trace << llvm::formatv( - "NodeId #{0} couldn't be extracted as a {1}. Trace:\n", n, - n_impl.kind); - VerifyExtract(n, n_impl.kind, &trace); - return trace; - } - - int subtree_size = 1; - if (n_impl.kind.has_bracket()) { - int child_count = 0; - while (true) { - if (nodes.empty()) { - return Error( - llvm::formatv("NodeId #{0} is a {1} with bracket {2}, but didn't " - "find the bracket.", - n, n_impl.kind, n_impl.kind.bracket())); - } - auto child_impl = node_impls_[nodes.pop_back_val().index]; - subtree_size += child_impl.subtree_size; - ++child_count; - if (n_impl.kind.bracket() == child_impl.kind) { - // If there's a bracketing node and a child count, verify the child - // count too. - if (n_impl.kind.has_child_count() && - child_count != n_impl.kind.child_count()) { - return Error(llvm::formatv( - "NodeId #{0} is a {1} with child_count {2}, but encountered " - "{3} nodes before we reached the bracketing node.", - n, n_impl.kind, n_impl.kind.child_count(), child_count)); - } - break; - } - } - } else { - for (int i : llvm::seq(n_impl.kind.child_count())) { - if (nodes.empty()) { - return Error(llvm::formatv( - "NodeId #{0} is a {1} with child_count {2}, but only had {3} " - "nodes to consume.", - n, n_impl.kind, n_impl.kind.child_count(), i)); - } - auto child_impl = node_impls_[nodes.pop_back_val().index]; - subtree_size += child_impl.subtree_size; - } - } - if (n_impl.subtree_size != subtree_size) { - return Error(llvm::formatv( - "NodeId #{0} is a {1} with subtree_size of {2}, but calculated {3}.", - n, n_impl.kind, n_impl.subtree_size, subtree_size)); - } - nodes.push_back(n); } - // Remaining nodes should all be roots in the tree; make sure they line up. - CARBON_CHECK(nodes.back().index == - static_cast(node_impls_.size()) - 1) - << nodes.back() << " " << node_impls_.size() - 1; - int prev_index = -1; - for (const auto& n : nodes) { - const auto& n_impl = node_impls_[n.index]; - - if (n.index - n_impl.subtree_size != prev_index) { - return Error( - llvm::formatv("NodeId #{0} is a root {1} with subtree_size {2}, but " - "previous root was at #{3}.", - n, n_impl.kind, n_impl.subtree_size, prev_index)); - } - prev_index = n.index; + if (!has_errors() && + static_cast(size()) != tokens_->expected_parse_tree_size()) { + return Error(llvm::formatv( + "Tree has {0} nodes and no errors, but " + "Lex::TokenizedBuffer expected {1} nodes for {2} tokens.", + size(), tokens_->expected_parse_tree_size(), tokens_->size())); } - // Validate the roots, ensures Tree::ExtractFile() doesn't CHECK-fail. - if (!TryExtractNodeFromChildren(NodeId::Invalid, roots(), nullptr)) { - ErrorBuilder trace; - trace << "Roots of tree couldn't be extracted as a `File`. Trace:\n"; - TryExtractNodeFromChildren(NodeId::Invalid, roots(), &trace); - return trace; - } +#ifndef NDEBUG + TreeAndSubtrees subtrees(*tokens_, *this); + CARBON_RETURN_IF_ERROR(subtrees.Verify()); +#endif // NDEBUG - if (!has_errors_ && static_cast(node_impls_.size()) != - tokens_->expected_parse_tree_size()) { - return Error( - llvm::formatv("Tree has {0} nodes and no errors, but " - "Lex::TokenizedBuffer expected {1} nodes for {2} tokens.", - node_impls_.size(), tokens_->expected_parse_tree_size(), - tokens_->size())); - } return Success(); } -auto Tree::PostorderIterator::Print(llvm::raw_ostream& output) const -> void { - output << node_; +auto Tree::CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "node_impls_"), node_impls_); + mem_usage.Add(MemUsage::ConcatLabel(label, "imports_"), imports_); +} + +auto Tree::PostorderIterator::MakeRange(NodeId begin, NodeId end) + -> llvm::iterator_range { + CARBON_CHECK(begin.is_valid() && end.is_valid()); + return llvm::iterator_range( + PostorderIterator(begin), PostorderIterator(NodeId(end.index + 1))); } -auto Tree::SiblingIterator::Print(llvm::raw_ostream& output) const -> void { +auto Tree::PostorderIterator::Print(llvm::raw_ostream& output) const -> void { output << node_; } diff --git a/toolchain/parse/tree.h b/toolchain/parse/tree.h index b7017e12307ec..699b25b29cdfe 100644 --- a/toolchain/parse/tree.h +++ b/toolchain/parse/tree.h @@ -78,13 +78,6 @@ struct File; class Tree : public Printable { public: class PostorderIterator; - class SiblingIterator; - - // For PackagingDecl. - enum class ApiOrImpl : uint8_t { - Api, - Impl, - }; // Names in packaging, whether the file's packaging or an import. Links back // to the node for diagnostics. @@ -120,20 +113,6 @@ class Tree : public Printable { // postorder. auto postorder() const -> llvm::iterator_range; - // Returns an iterable range over the parse tree node and all of its - // descendants in depth-first postorder. - auto postorder(NodeId n) const -> llvm::iterator_range; - - // Returns an iterable range over the direct children of a node in the parse - // tree. This is a forward range, but is constant time to increment. The order - // of children is the same as would be found in a reverse postorder traversal. - auto children(NodeId n) const -> llvm::iterator_range; - - // Returns an iterable range over the roots of the parse tree. This is a - // forward range, but is constant time to increment. The order of roots is the - // same as would be found in a reverse postorder traversal. - auto roots() const -> llvm::iterator_range; - // Tests whether a particular node contains an error and may not match the // full expected structure of the grammar. auto node_has_error(NodeId n) const -> bool; @@ -189,92 +168,19 @@ class Tree : public Printable { return deferred_definitions_; } - // See the other Print comments. + // Builds TreeAndSubtrees to print the tree. auto Print(llvm::raw_ostream& output) const -> void; - // Prints a description of the parse tree to the provided `raw_ostream`. - // - // The tree may be printed in either preorder or postorder. Output represents - // each node as a YAML record; in preorder, children are nested. - // - // In both, a node is formatted as: - // ``` - // {kind: 'foo', text: '...'} - // ``` - // - // The top level is formatted as an array of these nodes. - // ``` - // [ - // {kind: 'foo', text: '...'}, - // {kind: 'foo', text: '...'}, - // ... - // ] - // ``` - // - // In postorder, nodes are indented in order to indicate depth. For example, a - // node with two children, one of them with an error: - // ``` - // {kind: 'bar', text: '...', has_error: yes}, - // {kind: 'baz', text: '...'} - // {kind: 'foo', text: '...', subtree_size: 2} - // ``` - // - // In preorder, nodes are marked as children with postorder (storage) index. - // For example, a node with two children, one of them with an error: - // ``` - // {node_index: 2, kind: 'foo', text: '...', subtree_size: 2, children: [ - // {node_index: 0, kind: 'bar', text: '...', has_error: yes}, - // {node_index: 1, kind: 'baz', text: '...'}]} - // ``` - // - // This can be parsed as YAML using tools like `python-yq` combined with `jq` - // on the command line. The format is also reasonably amenable to other - // line-oriented shell tools from `grep` to `awk`. - auto Print(llvm::raw_ostream& output, bool preorder) const -> void; - - // The following `Extract*` function provide an alternative way of accessing - // the nodes of a tree. It is intended to be more convenient and type-safe, - // but slower and can't be used on nodes that are marked as having an error. - // It is appropriate for uses that are less performance sensitive, like - // diagnostics. Example usage: - // ``` - // auto file = tree->ExtractFile(); - // for (AnyDeclId decl_id : file.decls) { - // // `decl_id` is convertible to a `NodeId`. - // if (std::optional fn_decl = - // tree->ExtractAs(decl_id)) { - // // fn_decl->params is a `TuplePatternId` (which extends `NodeId`) - // // that is guaranteed to reference a `TuplePattern`. - // std::optional params = tree->Extract(fn_decl->params); - // // `params` has a value unless there was an error in that node. - // } else if (auto class_def = tree->ExtractAs(decl_id)) { - // // ... - // } - // } - // ``` - - // Extract a `File` object representing the parse tree for the whole file. - // #include "toolchain/parse/typed_nodes.h" to get the definition of `File` - // and the types representing its children nodes. This is implemented in - // extract.cpp. - auto ExtractFile() const -> File; - - // Converts this node_id to a typed node of a specified type, if it is a valid - // node of that kind. - template - auto ExtractAs(NodeId node_id) const -> std::optional; - - // Converts to a typed node, if it is not an error. - template - auto Extract(IdT id) const - -> std::optional::TypedNode>; + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void; // Verifies the parse tree structure. Checks invariants of the parse tree // structure and returns verification errors. // - // This is fairly slow, and is primarily intended to be used as a debugging - // aid. This routine doesn't directly CHECK so that it can be used within a - // debugger. + // In opt builds, this does some minimal checking. In debug builds, it'll + // build a TreeAndSubtrees and run further verification. This doesn't directly + // CHECK so that it can be used within a debugger. auto Verify() const -> ErrorOr; private: @@ -287,12 +193,8 @@ class Tree : public Printable { // The in-memory representation of data used for a particular node in the // tree. struct NodeImpl { - explicit NodeImpl(NodeKind kind, bool has_error, Lex::TokenIndex token, - int subtree_size) - : kind(kind), - has_error(has_error), - token(token), - subtree_size(subtree_size) {} + explicit NodeImpl(NodeKind kind, bool has_error, Lex::TokenIndex token) + : kind(kind), has_error(has_error), token(token) {} // The kind of this node. Note that this is only a single byte. NodeKind kind; @@ -317,38 +219,11 @@ class Tree : public Printable { // The token root of this node. Lex::TokenIndex token; - - // The size of this node's subtree of the parse tree. This is the number of - // nodes (and thus tokens) that are covered by this node (and its - // descendents) in the parse tree. - // - // During a *reverse* postorder (RPO) traversal of the parse tree, this can - // also be thought of as the offset to the next non-descendant node. When - // this node is not the first child of its parent (which is the last child - // visited in RPO), that is the offset to the next sibling. When this node - // *is* the first child of its parent, this will be an offset to the node's - // parent's next sibling, or if it the parent is also a first child, the - // grandparent's next sibling, and so on. - // - // This field should always be a positive integer as at least this node is - // part of its subtree. - int32_t subtree_size; }; - static_assert(sizeof(NodeImpl) == 12, + static_assert(sizeof(NodeImpl) == 8, "Unexpected size of node implementation!"); - // Like ExtractAs(), but malformed tree errors are not fatal. Should only be - // used by `Verify()` or by tests. - template - auto VerifyExtractAs(NodeId node_id, ErrorBuilder* trace) const - -> std::optional; - - // Wrapper around `VerifyExtractAs` to dispatch based on a runtime node kind. - // Returns true if extraction was successful. - auto VerifyExtract(NodeId node_id, NodeKind kind, ErrorBuilder* trace) const - -> bool; - // Sets the kind of a node. This is intended to allow putting the tree into a // state where verification can fail, in order to make the failure path of // `Verify` testable. @@ -356,26 +231,6 @@ class Tree : public Printable { node_impls_[node_id.index].kind = kind; } - // Prints a single node for Print(). Returns true when preorder and there are - // children. - auto PrintNode(llvm::raw_ostream& output, NodeId n, int depth, - bool preorder) const -> bool; - - // Extract a node of type `T` from a sibling range. This is expected to - // consume the complete sibling range. Malformed tree errors are written - // to `*trace`, if `trace != nullptr`. This is implemented in extract.cpp. - template - auto TryExtractNodeFromChildren( - NodeId node_id, llvm::iterator_range children, - ErrorBuilder* trace) const -> std::optional; - - // Extract a node of type `T` from a sibling range. This is expected to - // consume the complete sibling range. Malformed tree errors are fatal. - template - auto ExtractNodeFromChildren( - NodeId node_id, - llvm::iterator_range children) const -> T; - // Depth-first postorder sequence of node implementation data. llvm::SmallVector node_impls_; @@ -405,6 +260,15 @@ class Tree::PostorderIterator int, const NodeId*, NodeId>, public Printable { public: + // Returns an iterable range between the two parse tree nodes, in depth-first + // postorder. The range is inclusive of the bounds: [begin, end]. + static auto MakeRange(NodeId begin, NodeId end) + -> llvm::iterator_range; + + // Prefer using the `postorder` range calls, but direct construction is + // allowed if needed. + explicit PostorderIterator(NodeId n) : node_(n) {} + PostorderIterator() = delete; auto operator==(const PostorderIterator& rhs) const -> bool { @@ -439,107 +303,9 @@ class Tree::PostorderIterator private: friend class Tree; - explicit PostorderIterator(NodeId n) : node_(n) {} - NodeId node_; }; -// A forward iterator across the siblings at a particular level in the parse -// tree. It produces `Tree::NodeId` objects which are opaque handles and must -// be used in conjunction with the `Tree` itself. -// -// While this is a forward iterator and may not have good locality within the -// `Tree` data structure, it is still constant time to increment and -// suitable for algorithms relying on that property. -// -// The siblings are discovered through a reverse postorder (RPO) tree traversal -// (which is made constant time through cached distance information), and so the -// relative order of siblings matches their RPO order. -class Tree::SiblingIterator - : public llvm::iterator_facade_base, - public Printable { - public: - explicit SiblingIterator() = delete; - - auto operator==(const SiblingIterator& rhs) const -> bool { - return node_ == rhs.node_; - } - - auto operator*() const -> NodeId { return node_; } - - using iterator_facade_base::operator++; - auto operator++() -> SiblingIterator& { - node_.index -= std::abs(tree_->node_impls_[node_.index].subtree_size); - return *this; - } - - // Prints the underlying node index. - auto Print(llvm::raw_ostream& output) const -> void; - - private: - friend class Tree; - - explicit SiblingIterator(const Tree& tree_arg, NodeId n) - : tree_(&tree_arg), node_(n) {} - - const Tree* tree_; - - NodeId node_; -}; - -template -auto Tree::ExtractNodeFromChildren( - NodeId node_id, llvm::iterator_range children) const - -> T { - auto result = TryExtractNodeFromChildren(node_id, children, nullptr); - if (!result.has_value()) { - // On error try again, this time capturing a trace. - ErrorBuilder trace; - TryExtractNodeFromChildren(node_id, children, &trace); - CARBON_FATAL() << "Malformed parse node:\n" - << static_cast(trace).message(); - } - return *result; -} - -template -auto Tree::ExtractAs(NodeId node_id) const -> std::optional { - static_assert(HasKindMember, "Not a parse node type"); - if (!IsValid(node_id)) { - return std::nullopt; - } - - return ExtractNodeFromChildren(node_id, children(node_id)); -} - -template -auto Tree::VerifyExtractAs(NodeId node_id, ErrorBuilder* trace) const - -> std::optional { - static_assert(HasKindMember, "Not a parse node type"); - if (!IsValid(node_id)) { - if (trace) { - *trace << "VerifyExtractAs error: wrong kind " << node_kind(node_id) - << ", expected " << T::Kind << "\n"; - } - return std::nullopt; - } - - return TryExtractNodeFromChildren(node_id, children(node_id), trace); -} - -template -auto Tree::Extract(IdT id) const - -> std::optional::TypedNode> { - if (!IsValid(id)) { - return std::nullopt; - } - - using T = typename NodeForId::TypedNode; - return ExtractNodeFromChildren(id, children(id)); -} - template struct Tree::ConvertTo> { static auto AllowedFor(NodeKind kind) -> bool { return kind == K; } diff --git a/toolchain/parse/tree_and_subtrees.cpp b/toolchain/parse/tree_and_subtrees.cpp new file mode 100644 index 0000000000000..a4792c935c5b8 --- /dev/null +++ b/toolchain/parse/tree_and_subtrees.cpp @@ -0,0 +1,244 @@ +// 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 + +#include "toolchain/parse/tree_and_subtrees.h" + +namespace Carbon::Parse { + +TreeAndSubtrees::TreeAndSubtrees(const Lex::TokenizedBuffer& tokens, + const Tree& tree) + : tokens_(&tokens), tree_(&tree) { + subtree_sizes_.reserve(tree_->size()); + + // A stack of nodes which haven't yet been used as children. + llvm::SmallVector size_stack; + for (auto n : tree.postorder()) { + // Nodes always include themselves. + int32_t size = 1; + auto kind = tree.node_kind(n); + if (kind.has_child_count()) { + // When the child count is set, remove the specific number from the stack. + CARBON_CHECK(static_cast(size_stack.size()) >= + kind.child_count()) + << "Need " << kind.child_count() << " children for " << kind + << ", have " << size_stack.size() << " available"; + for (auto i : llvm::seq(kind.child_count())) { + auto child = size_stack.pop_back_val(); + CARBON_CHECK((size_t)child.index < subtree_sizes_.size()); + size += subtree_sizes_[child.index]; + if (kind.has_bracket() && i == kind.child_count() - 1) { + CARBON_CHECK(kind.bracket() == tree.node_kind(child)) + << "Node " << kind << " needs bracket " << kind.bracket() + << ", found wrong bracket " << tree.node_kind(child); + } + } + } else { + while (true) { + CARBON_CHECK(!size_stack.empty()) + << "Node " << kind << " is missing bracket " << kind.bracket(); + auto child = size_stack.pop_back_val(); + size += subtree_sizes_[child.index]; + if (kind.bracket() == tree.node_kind(child)) { + break; + } + } + } + size_stack.push_back(n); + subtree_sizes_.push_back(size); + } + + CARBON_CHECK(static_cast(subtree_sizes_.size()) == tree_->size()); + + // Remaining nodes should all be roots in the tree; make sure they line up. + CARBON_CHECK(size_stack.back().index == + static_cast(tree_->size()) - 1) + << size_stack.back() << " " << tree_->size() - 1; + int prev_index = -1; + for (const auto& n : size_stack) { + CARBON_CHECK(n.index - subtree_sizes_[n.index] == prev_index) + << "NodeId " << n << " is a root " << tree_->node_kind(n) + << " with subtree_size " << subtree_sizes_[n.index] + << ", but previous root was at " << prev_index << "."; + prev_index = n.index; + } +} + +auto TreeAndSubtrees::VerifyExtract(NodeId node_id, NodeKind kind, + ErrorBuilder* trace) const -> bool { + switch (kind) { +#define CARBON_PARSE_NODE_KIND(Name) \ + case NodeKind::Name: \ + return VerifyExtractAs(node_id, trace).has_value(); +#include "toolchain/parse/node_kind.def" + } +} + +auto TreeAndSubtrees::Verify() const -> ErrorOr { + // Validate that each node extracts successfully when not marked as having an + // error. + // + // Without this code, a 10 mloc test case of lex & parse takes 4.129 s ± 0.041 + // s. With this additional verification, it takes 5.768 s ± 0.036 s. + for (NodeId n : tree_->postorder()) { + if (tree_->node_has_error(n)) { + continue; + } + + auto node_kind = tree_->node_kind(n); + if (!VerifyExtract(n, node_kind, nullptr)) { + ErrorBuilder trace; + trace << llvm::formatv( + "NodeId #{0} couldn't be extracted as a {1}. Trace:\n", n, node_kind); + VerifyExtract(n, node_kind, &trace); + return trace; + } + } + + // Validate the roots. Also ensures Tree::ExtractFile() doesn't error. + if (!TryExtractNodeFromChildren(NodeId::Invalid, roots(), nullptr)) { + ErrorBuilder trace; + trace << "Roots of tree couldn't be extracted as a `File`. Trace:\n"; + TryExtractNodeFromChildren(NodeId::Invalid, roots(), &trace); + return trace; + } + + return Success(); +} + +auto TreeAndSubtrees::postorder(NodeId n) const + -> llvm::iterator_range { + // The postorder ends after this node, the root, and begins at the start of + // its subtree. + int start_index = n.index - subtree_sizes_[n.index] + 1; + return Tree::PostorderIterator::MakeRange(NodeId(start_index), n); +} + +auto TreeAndSubtrees::children(NodeId n) const + -> llvm::iterator_range { + CARBON_CHECK(n.is_valid()); + int end_index = n.index - subtree_sizes_[n.index]; + return llvm::iterator_range( + SiblingIterator(*this, NodeId(n.index - 1)), + SiblingIterator(*this, NodeId(end_index))); +} + +auto TreeAndSubtrees::roots() const -> llvm::iterator_range { + return llvm::iterator_range( + SiblingIterator(*this, + NodeId(static_cast(subtree_sizes_.size()) - 1)), + SiblingIterator(*this, NodeId(-1))); +} + +auto TreeAndSubtrees::PrintNode(llvm::raw_ostream& output, NodeId n, int depth, + bool preorder) const -> bool { + output.indent(2 * (depth + 2)); + output << "{"; + // If children are being added, include node_index in order to disambiguate + // nodes. + if (preorder) { + output << "node_index: " << n << ", "; + } + output << "kind: '" << tree_->node_kind(n) << "', text: '" + << tokens_->GetTokenText(tree_->node_token(n)) << "'"; + + if (tree_->node_has_error(n)) { + output << ", has_error: yes"; + } + + if (subtree_sizes_[n.index] > 1) { + output << ", subtree_size: " << subtree_sizes_[n.index]; + if (preorder) { + output << ", children: [\n"; + return true; + } + } + output << "}"; + return false; +} + +auto TreeAndSubtrees::Print(llvm::raw_ostream& output) const -> void { + output << "- filename: " << tokens_->source().filename() << "\n" + << " parse_tree: [\n"; + + // Walk the tree just to calculate depths for each node. + llvm::SmallVector indents; + indents.resize(subtree_sizes_.size(), 0); + + llvm::SmallVector, 16> node_stack; + for (NodeId n : roots()) { + node_stack.push_back({n, 0}); + } + + while (!node_stack.empty()) { + NodeId n = NodeId::Invalid; + int depth; + std::tie(n, depth) = node_stack.pop_back_val(); + for (NodeId sibling_n : children(n)) { + indents[sibling_n.index] = depth + 1; + node_stack.push_back({sibling_n, depth + 1}); + } + } + + for (NodeId n : tree_->postorder()) { + PrintNode(output, n, indents[n.index], /*preorder=*/false); + output << ",\n"; + } + output << " ]\n"; +} + +auto TreeAndSubtrees::PrintPreorder(llvm::raw_ostream& output) const -> void { + output << "- filename: " << tokens_->source().filename() << "\n" + << " parse_tree: [\n"; + + // The parse tree is stored in postorder. The preorder can be constructed + // by reversing the order of each level of siblings within an RPO. The + // sibling iterators are directly built around RPO and so can be used with a + // stack to produce preorder. + + // The roots, like siblings, are in RPO (so reversed), but we add them in + // order here because we'll pop off the stack effectively reversing then. + llvm::SmallVector, 16> node_stack; + for (NodeId n : roots()) { + node_stack.push_back({n, 0}); + } + + while (!node_stack.empty()) { + NodeId n = NodeId::Invalid; + int depth; + std::tie(n, depth) = node_stack.pop_back_val(); + + if (PrintNode(output, n, depth, /*preorder=*/true)) { + // Has children, so we descend. We append the children in order here as + // well because they will get reversed when popped off the stack. + for (NodeId sibling_n : children(n)) { + node_stack.push_back({sibling_n, depth + 1}); + } + continue; + } + + int next_depth = node_stack.empty() ? 0 : node_stack.back().second; + CARBON_CHECK(next_depth <= depth) << "Cannot have the next depth increase!"; + for (int close_children_count : llvm::seq(0, depth - next_depth)) { + (void)close_children_count; + output << "]}"; + } + + // We always end with a comma and a new line as we'll move to the next + // node at whatever the current level ends up being. + output << " ,\n"; + } + output << " ]\n"; +} + +auto TreeAndSubtrees::CollectMemUsage(MemUsage& mem_usage, + llvm::StringRef label) const -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "subtree_sizes_"), subtree_sizes_); +} + +auto TreeAndSubtrees::SiblingIterator::Print(llvm::raw_ostream& output) const + -> void { + output << node_; +} + +} // namespace Carbon::Parse diff --git a/toolchain/parse/tree_and_subtrees.h b/toolchain/parse/tree_and_subtrees.h new file mode 100644 index 0000000000000..783991e0477c2 --- /dev/null +++ b/toolchain/parse/tree_and_subtrees.h @@ -0,0 +1,277 @@ +// 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 + +#ifndef CARBON_TOOLCHAIN_PARSE_TREE_AND_SUBTREES_H_ +#define CARBON_TOOLCHAIN_PARSE_TREE_AND_SUBTREES_H_ + +#include "llvm/ADT/SmallVector.h" +#include "toolchain/parse/tree.h" + +namespace Carbon::Parse { + +// Calculates and stores subtree data for a parse tree. Supports APIs that +// require subtree knowledge. +// +// This requires a complete tree. +class TreeAndSubtrees { + public: + class SiblingIterator; + + explicit TreeAndSubtrees(const Lex::TokenizedBuffer& tokens, + const Tree& tree); + + // The following `Extract*` function provide an alternative way of accessing + // the nodes of a tree. It is intended to be more convenient and type-safe, + // but slower and can't be used on nodes that are marked as having an error. + // It is appropriate for uses that are less performance sensitive, like + // diagnostics. Example usage: + // ``` + // auto file = tree->ExtractFile(); + // for (AnyDeclId decl_id : file.decls) { + // // `decl_id` is convertible to a `NodeId`. + // if (std::optional fn_decl = + // tree->ExtractAs(decl_id)) { + // // fn_decl->params is a `TuplePatternId` (which extends `NodeId`) + // // that is guaranteed to reference a `TuplePattern`. + // std::optional params = tree->Extract(fn_decl->params); + // // `params` has a value unless there was an error in that node. + // } else if (auto class_def = tree->ExtractAs(decl_id)) { + // // ... + // } + // } + // ``` + + // Extract a `File` object representing the parse tree for the whole file. + // #include "toolchain/parse/typed_nodes.h" to get the definition of `File` + // and the types representing its children nodes. This is implemented in + // extract.cpp. + auto ExtractFile() const -> File; + + // Converts this node_id to a typed node of a specified type, if it is a valid + // node of that kind. + template + auto ExtractAs(NodeId node_id) const -> std::optional; + + // Converts to a typed node, if it is not an error. + template + auto Extract(IdT id) const + -> std::optional::TypedNode>; + + // Verifies that each node in the tree can be successfully extracted. + // + // This is fairly slow, and is primarily intended to be used as a debugging + // aid. This doesn't directly CHECK so that it can be used within a debugger. + auto Verify() const -> ErrorOr; + + // Prints the parse tree in postorder format. See also use PrintPreorder. + // + // Output represents each node as a YAML record. A node is formatted as: + // ``` + // {kind: 'foo', text: '...'} + // ``` + // + // The top level is formatted as an array of these nodes. + // ``` + // [ + // {kind: 'foo', text: '...'}, + // {kind: 'foo', text: '...'}, + // ... + // ] + // ``` + // + // Nodes are indented in order to indicate depth. For example, a node with two + // children, one of them with an error: + // ``` + // {kind: 'bar', text: '...', has_error: yes}, + // {kind: 'baz', text: '...'} + // {kind: 'foo', text: '...', subtree_size: 2} + // ``` + // + // This can be parsed as YAML using tools like `python-yq` combined with `jq` + // on the command line. The format is also reasonably amenable to other + // line-oriented shell tools from `grep` to `awk`. + auto Print(llvm::raw_ostream& output) const -> void; + + // Prints the parse tree in preorder. The format is YAML, and similar to + // Print. However, nodes are marked as children with postorder (storage) + // index. For example, a node with two children, one of them with an error: + // ``` + // {node_index: 2, kind: 'foo', text: '...', subtree_size: 2, children: [ + // {node_index: 0, kind: 'bar', text: '...', has_error: yes}, + // {node_index: 1, kind: 'baz', text: '...'}]} + // ``` + auto PrintPreorder(llvm::raw_ostream& output) const -> void; + + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void; + + // Returns an iterable range over the parse tree node and all of its + // descendants in depth-first postorder. + auto postorder(NodeId n) const + -> llvm::iterator_range; + + // Returns an iterable range over the direct children of a node in the parse + // tree. This is a forward range, but is constant time to increment. The order + // of children is the same as would be found in a reverse postorder traversal. + auto children(NodeId n) const -> llvm::iterator_range; + + // Returns an iterable range over the roots of the parse tree. This is a + // forward range, but is constant time to increment. The order of roots is the + // same as would be found in a reverse postorder traversal. + auto roots() const -> llvm::iterator_range; + + auto tree() const -> const Tree& { return *tree_; } + + private: + friend class TypedNodesTestPeer; + + // Extract a node of type `T` from a sibling range. This is expected to + // consume the complete sibling range. Malformed tree errors are written + // to `*trace`, if `trace != nullptr`. This is implemented in extract.cpp. + template + auto TryExtractNodeFromChildren( + NodeId node_id, llvm::iterator_range children, + ErrorBuilder* trace) const -> std::optional; + + // Extract a node of type `T` from a sibling range. This is expected to + // consume the complete sibling range. Malformed tree errors are fatal. + template + auto ExtractNodeFromChildren( + NodeId node_id, llvm::iterator_range children) const + -> T; + + // Like ExtractAs(), but malformed tree errors are not fatal. Should only be + // used by `Verify()` or by tests. + template + auto VerifyExtractAs(NodeId node_id, ErrorBuilder* trace) const + -> std::optional; + + // Wrapper around `VerifyExtractAs` to dispatch based on a runtime node kind. + // Returns true if extraction was successful. + auto VerifyExtract(NodeId node_id, NodeKind kind, ErrorBuilder* trace) const + -> bool; + + // Prints a single node for Print(). Returns true when preorder and there are + // children. + auto PrintNode(llvm::raw_ostream& output, NodeId n, int depth, + bool preorder) const -> bool; + + // The associated tokens. + const Lex::TokenizedBuffer* tokens_; + + // The associated tree. + const Tree* tree_; + + // For each node in the tree, the size of the node's subtree. This is the + // number of nodes (and thus tokens) that are covered by the node (and its + // descendents) in the parse tree. It's one for nodes with no children. + // + // During a *reverse* postorder (RPO) traversal of the parse tree, this can + // also be thought of as the offset to the next non-descendant node. When the + // node is not the first child of its parent (which is the last child visited + // in RPO), that is the offset to the next sibling. When the node *is* the + // first child of its parent, this will be an offset to the node's parent's + // next sibling, or if it the parent is also a first child, the grandparent's + // next sibling, and so on. + llvm::SmallVector subtree_sizes_; +}; + +// A forward iterator across the siblings at a particular level in the parse +// tree. It produces `Tree::NodeId` objects which are opaque handles and must +// be used in conjunction with the `Tree` itself. +// +// While this is a forward iterator and may not have good locality within the +// `Tree` data structure, it is still constant time to increment and +// suitable for algorithms relying on that property. +// +// The siblings are discovered through a reverse postorder (RPO) tree traversal +// (which is made constant time through cached distance information), and so the +// relative order of siblings matches their RPO order. +class TreeAndSubtrees::SiblingIterator + : public llvm::iterator_facade_base, + public Printable { + public: + explicit SiblingIterator() = delete; + + auto operator==(const SiblingIterator& rhs) const -> bool { + return node_ == rhs.node_; + } + + auto operator*() const -> NodeId { return node_; } + + using iterator_facade_base::operator++; + auto operator++() -> SiblingIterator& { + node_.index -= std::abs(tree_->subtree_sizes_[node_.index]); + return *this; + } + + // Prints the underlying node index. + auto Print(llvm::raw_ostream& output) const -> void; + + private: + friend class TreeAndSubtrees; + + explicit SiblingIterator(const TreeAndSubtrees& tree, NodeId node) + : tree_(&tree), node_(node) {} + + const TreeAndSubtrees* tree_; + NodeId node_; +}; + +template +auto TreeAndSubtrees::ExtractNodeFromChildren( + NodeId node_id, llvm::iterator_range children) const -> T { + auto result = TryExtractNodeFromChildren(node_id, children, nullptr); + if (!result.has_value()) { + // On error try again, this time capturing a trace. + ErrorBuilder trace; + TryExtractNodeFromChildren(node_id, children, &trace); + CARBON_FATAL() << "Malformed parse node:\n" + << static_cast(trace).message(); + } + return *result; +} + +template +auto TreeAndSubtrees::ExtractAs(NodeId node_id) const -> std::optional { + static_assert(HasKindMember, "Not a parse node type"); + if (!tree_->IsValid(node_id)) { + return std::nullopt; + } + + return ExtractNodeFromChildren(node_id, children(node_id)); +} + +template +auto TreeAndSubtrees::VerifyExtractAs(NodeId node_id, ErrorBuilder* trace) const + -> std::optional { + static_assert(HasKindMember, "Not a parse node type"); + if (!tree_->IsValid(node_id)) { + if (trace) { + *trace << "VerifyExtractAs error: wrong kind " + << tree_->node_kind(node_id) << ", expected " << T::Kind << "\n"; + } + return std::nullopt; + } + + return TryExtractNodeFromChildren(node_id, children(node_id), trace); +} + +template +auto TreeAndSubtrees::Extract(IdT id) const + -> std::optional::TypedNode> { + if (!tree_->IsValid(id)) { + return std::nullopt; + } + + using T = typename NodeForId::TypedNode; + return ExtractNodeFromChildren(id, children(id)); +} + +} // namespace Carbon::Parse + +#endif // CARBON_TOOLCHAIN_PARSE_TREE_AND_SUBTREES_H_ diff --git a/toolchain/parse/tree_node_diagnostic_converter.h b/toolchain/parse/tree_node_diagnostic_converter.h index c5ad601cf1d75..2d1a4dd3dd90a 100644 --- a/toolchain/parse/tree_node_diagnostic_converter.h +++ b/toolchain/parse/tree_node_diagnostic_converter.h @@ -5,9 +5,12 @@ #ifndef CARBON_TOOLCHAIN_PARSE_TREE_NODE_DIAGNOSTIC_CONVERTER_H_ #define CARBON_TOOLCHAIN_PARSE_TREE_NODE_DIAGNOSTIC_CONVERTER_H_ +#include + #include "toolchain/diagnostics/diagnostic_emitter.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/tree.h" +#include "toolchain/parse/tree_and_subtrees.h" namespace Carbon::Parse { @@ -32,11 +35,12 @@ class NodeLoc { class NodeLocConverter : public DiagnosticConverter { public: - explicit NodeLocConverter(const Lex::TokenizedBuffer* tokens, - llvm::StringRef filename, const Tree* parse_tree) + explicit NodeLocConverter( + const Lex::TokenizedBuffer* tokens, llvm::StringRef filename, + llvm::function_ref get_tree_and_subtrees) : token_converter_(tokens), filename_(filename), - parse_tree_(parse_tree) {} + get_tree_and_subtrees_(get_tree_and_subtrees) {} // Map the given token into a diagnostic location. auto ConvertLoc(NodeLoc node_loc, ContextFnT context_fn) const @@ -47,17 +51,19 @@ class NodeLocConverter : public DiagnosticConverter { return {.filename = filename_}; } + const auto& tree = get_tree_and_subtrees_(); + if (node_loc.token_only()) { return token_converter_.ConvertLoc( - parse_tree_->node_token(node_loc.node_id()), context_fn); + tree.tree().node_token(node_loc.node_id()), context_fn); } // Construct a location that encompasses all tokens that descend from this // node (including the root). - Lex::TokenIndex start_token = parse_tree_->node_token(node_loc.node_id()); + Lex::TokenIndex start_token = tree.tree().node_token(node_loc.node_id()); Lex::TokenIndex end_token = start_token; - for (NodeId desc : parse_tree_->postorder(node_loc.node_id())) { - Lex::TokenIndex desc_token = parse_tree_->node_token(desc); + for (NodeId desc : tree.postorder(node_loc.node_id())) { + Lex::TokenIndex desc_token = tree.tree().node_token(desc); if (!desc_token.is_valid()) { continue; } @@ -89,7 +95,9 @@ class NodeLocConverter : public DiagnosticConverter { private: Lex::TokenDiagnosticConverter token_converter_; llvm::StringRef filename_; - const Tree* parse_tree_; + + // Returns a lazily constructed TreeAndSubtrees. + llvm::function_ref get_tree_and_subtrees_; }; } // namespace Carbon::Parse diff --git a/toolchain/parse/tree_test.cpp b/toolchain/parse/tree_test.cpp index cf2c8955e54d2..5938e3caac6ac 100644 --- a/toolchain/parse/tree_test.cpp +++ b/toolchain/parse/tree_test.cpp @@ -16,6 +16,7 @@ #include "toolchain/lex/lex.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/parse.h" +#include "toolchain/parse/tree_and_subtrees.h" #include "toolchain/testing/yaml_test_helpers.h" namespace Carbon::Parse { @@ -60,7 +61,8 @@ TEST_F(TreeTest, AsAndTryAs) { Lex::TokenizedBuffer& tokens = GetTokenizedBuffer("fn F();"); Tree tree = Parse(tokens, consumer_, /*vlog_stream=*/nullptr); ASSERT_FALSE(tree.has_errors()); - auto it = tree.roots().begin(); + TreeAndSubtrees tree_and_subtrees(tokens, tree); + auto it = tree_and_subtrees.roots().begin(); // A FileEnd node, so won't match. NodeId n = *it; @@ -134,8 +136,9 @@ TEST_F(TreeTest, PrintPreorderAsYAML) { Lex::TokenizedBuffer& tokens = GetTokenizedBuffer("fn F();"); Tree tree = Parse(tokens, consumer_, /*vlog_stream=*/nullptr); EXPECT_FALSE(tree.has_errors()); + TreeAndSubtrees tree_and_subtrees(tokens, tree); TestRawOstream print_stream; - tree.Print(print_stream, /*preorder=*/true); + tree_and_subtrees.PrintPreorder(print_stream); auto param_list = Yaml::Sequence(ElementsAre(Yaml::Mapping( ElementsAre(Pair("node_index", "3"), Pair("kind", "TuplePatternStart"), diff --git a/toolchain/parse/typed_nodes.h b/toolchain/parse/typed_nodes.h index 41a342e3bc81f..ddf0da98d2a9a 100644 --- a/toolchain/parse/typed_nodes.h +++ b/toolchain/parse/typed_nodes.h @@ -859,7 +859,7 @@ struct MemberAccessExpr { AnyExprId lhs; Lex::PeriodTokenIndex token; - AnyMemberNameOrMemberExprId rhs; + AnyMemberAccessId rhs; }; // An indirect member access expression: `a->b` or `a->(b)`. @@ -869,7 +869,7 @@ struct PointerMemberAccessExpr { AnyExprId lhs; Lex::MinusGreaterTokenIndex token; - AnyMemberNameOrMemberExprId rhs; + AnyMemberAccessId rhs; }; // A prefix operator expression. @@ -924,6 +924,22 @@ struct PostfixOperator { PostfixOperator; #include "toolchain/parse/node_kind.def" +using IntLiteral = LeafNode; + +// `extern` as a standalone modifier. +using ExternModifier = LeafNode; + +// `extern library ` modifiers. +struct ExternModifierWithLibrary { + static constexpr auto Kind = NodeKind::ExternModifierWithLibrary.Define( + {.category = NodeCategory::Modifier, .child_count = 1}); + + Lex::ExternTokenIndex token; + LibrarySpecifierId library; +}; + // The first operand of a short-circuiting infix operator: `a and` or `a or`. // The complete operator expression will be an InfixOperator with this as the // `lhs`. diff --git a/toolchain/parse/typed_nodes_test.cpp b/toolchain/parse/typed_nodes_test.cpp index 594aa24695f09..636133581d572 100644 --- a/toolchain/parse/typed_nodes_test.cpp +++ b/toolchain/parse/typed_nodes_test.cpp @@ -12,6 +12,7 @@ #include "toolchain/lex/lex.h" #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/parse.h" +#include "toolchain/parse/tree_and_subtrees.h" namespace Carbon::Parse { @@ -20,7 +21,7 @@ namespace Carbon::Parse { class TypedNodesTestPeer { public: template - static auto VerifyExtractAs(const Tree* tree, NodeId node_id, + static auto VerifyExtractAs(const TreeAndSubtrees* tree, NodeId node_id, ErrorBuilder* trace) -> std::optional { return tree->VerifyExtractAs(node_id, trace); } @@ -57,14 +58,16 @@ class TypedNodeTest : public ::testing::Test { return token_storage_.front(); } - auto GetTree(llvm::StringRef t) -> Tree& { + auto GetTree(llvm::StringRef t) -> TreeAndSubtrees& { tree_storage_.push_front(Parse(GetTokenizedBuffer(t), consumer_, /*vlog_stream=*/nullptr)); - return tree_storage_.front(); + tree_and_subtrees_storage_.push_front( + TreeAndSubtrees(token_storage_.front(), tree_storage_.front())); + return tree_and_subtrees_storage_.front(); } auto GetTokenizedBufferAndTree(llvm::StringRef t) - -> std::pair { + -> std::pair { auto* tree = &GetTree(t); return {&token_storage_.front(), tree}; } @@ -74,6 +77,7 @@ class TypedNodeTest : public ::testing::Test { std::forward_list source_storage_; std::forward_list token_storage_; std::forward_list tree_storage_; + std::forward_list tree_and_subtrees_storage_; DiagnosticConsumer& consumer_ = ConsoleDiagnosticConsumer(); }; @@ -81,15 +85,15 @@ TEST_F(TypedNodeTest, Empty) { auto* tree = &GetTree(""); auto file = tree->ExtractFile(); - EXPECT_TRUE(tree->IsValid(file.start)); + EXPECT_TRUE(tree->tree().IsValid(file.start)); EXPECT_TRUE(tree->ExtractAs(file.start).has_value()); EXPECT_TRUE(tree->Extract(file.start).has_value()); - EXPECT_TRUE(tree->IsValid(file.end)); + EXPECT_TRUE(tree->tree().IsValid(file.end)); EXPECT_TRUE(tree->ExtractAs(file.end).has_value()); EXPECT_TRUE(tree->Extract(file.end).has_value()); - EXPECT_FALSE(tree->IsValid(file.start)); + EXPECT_FALSE(tree->tree().IsValid(file.start)); EXPECT_FALSE(tree->ExtractAs(file.start).has_value()); } @@ -342,7 +346,7 @@ TEST_F(TypedNodeTest, VerifyInvalid) { ASSERT_TRUE(f_intro.has_value()); // Change the kind of the introducer and check we get a good trace log. - TypedNodesTestPeer::SetNodeKind(tree, f_sig->introducer, + TypedNodesTestPeer::SetNodeKind(&tree_storage_.front(), f_sig->introducer, NodeKind::ClassIntroducer); // The introducer should not extract as a FunctionIntroducer any more because diff --git a/toolchain/sem_ir/BUILD b/toolchain/sem_ir/BUILD index 41703714ccc72..7d6294368d35c 100644 --- a/toolchain/sem_ir/BUILD +++ b/toolchain/sem_ir/BUILD @@ -88,13 +88,15 @@ cc_library( "function.cpp", "generic.cpp", "name.cpp", + "type_info.cpp", ], hdrs = [ - "bind_name.h", "builtin_function_kind.h", "class.h", "constant.h", "copy_on_write_block.h", + "entity_name.h", + "entity_with_params_base.h", "file.h", "function.h", "generic.h", @@ -104,6 +106,7 @@ cc_library( "name.h", "name_scope.h", "type.h", + "type_info.h", ], textual_hdrs = [ "builtin_function_kind.def", @@ -114,12 +117,12 @@ cc_library( ":ids", ":inst", ":inst_kind", - ":type_info", "//common:check", "//common:enum_base", "//common:error", "//common:hashing", "//common:map", + "//common:ostream", "//common:set", "//toolchain/base:kind_switch", "//toolchain/base:value_store", @@ -175,16 +178,6 @@ cc_library( ], ) -cc_library( - name = "type_info", - hdrs = ["type_info.h"], - deps = [ - ":ids", - ":inst", - "//common:ostream", - ], -) - cc_test( name = "typed_insts_test", size = "small", diff --git a/toolchain/sem_ir/block_value_store.h b/toolchain/sem_ir/block_value_store.h index c1436ce452e35..9e17280d9ed55 100644 --- a/toolchain/sem_ir/block_value_store.h +++ b/toolchain/sem_ir/block_value_store.h @@ -81,6 +81,14 @@ class BlockValueStore : public Yaml::Printable> { }); } + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Collect(MemUsage::ConcatLabel(label, "values_"), values_); + mem_usage.Add(MemUsage::ConcatLabel(label, "canonical_blocks_"), + canonical_blocks_, KeyContext(this)); + } + auto size() const -> int { return values_.size(); } protected: diff --git a/toolchain/sem_ir/class.h b/toolchain/sem_ir/class.h index 96a6aac668108..2a00beaa1c402 100644 --- a/toolchain/sem_ir/class.h +++ b/toolchain/sem_ir/class.h @@ -5,12 +5,13 @@ #ifndef CARBON_TOOLCHAIN_SEM_IR_CLASS_H_ #define CARBON_TOOLCHAIN_SEM_IR_CLASS_H_ +#include "toolchain/sem_ir/entity_with_params_base.h" #include "toolchain/sem_ir/ids.h" namespace Carbon::SemIR { -// A class. -struct Class : public Printable { +// Class-specific fields. +struct ClassFields { enum InheritanceKind : int8_t { // `abstract class` Abstract, @@ -20,44 +21,17 @@ struct Class : public Printable { Final, }; - auto Print(llvm::raw_ostream& out) const -> void { - out << "{name: " << name_id << ", parent_scope: " << parent_scope_id << "}"; - } - - // Determines whether this class has been fully defined. This is false until - // we reach the `}` of the class definition. - auto is_defined() const -> bool { return object_repr_id.is_valid(); } - - // Determines whether this is a generic class. - auto is_generic() const -> bool { - return implicit_param_refs_id.is_valid() || param_refs_id.is_valid(); - } - // The following members always have values, and do not change throughout the // lifetime of the class. - // The class name. - NameId name_id; - // The parent scope. - NameScopeId parent_scope_id; - // If this is a generic function, information about the generic. - GenericId generic_id; - // A block containing a single reference instruction per implicit parameter. - InstBlockId implicit_param_refs_id; - // A block containing a single reference instruction per parameter. - InstBlockId param_refs_id; // The class type, which is the type of `Self` in the class definition. TypeId self_type_id; - // The first declaration of the class. This is a ClassDecl. - InstId decl_id = InstId::Invalid; // The kind of inheritance that this class supports. // TODO: The rules here are not yet decided. See #3384. InheritanceKind inheritance_kind; // The following members are set at the `{` of the class definition. - // The definition of the class. This is a ClassDecl. - InstId definition_id = InstId::Invalid; // The class scope. NameScopeId scope_id = NameScopeId::Invalid; // The first block of the class body. @@ -83,6 +57,21 @@ struct Class : public Printable { TypeId object_repr_id = TypeId::Invalid; }; +// A class. See EntityWithParamsBase regarding the inheritance here. +struct Class : public EntityWithParamsBase, + public ClassFields, + public Printable { + auto Print(llvm::raw_ostream& out) const -> void { + out << "{"; + PrintBaseFields(out); + out << "}"; + } + + // Determines whether this class has been fully defined. This is false until + // we reach the `}` of the class definition. + auto is_defined() const -> bool { return object_repr_id.is_valid(); } +}; + } // namespace Carbon::SemIR #endif // CARBON_TOOLCHAIN_SEM_IR_CLASS_H_ diff --git a/toolchain/sem_ir/constant.cpp b/toolchain/sem_ir/constant.cpp index 80387dbff33ba..4a68947ec28c4 100644 --- a/toolchain/sem_ir/constant.cpp +++ b/toolchain/sem_ir/constant.cpp @@ -29,7 +29,9 @@ auto ConstantStore::GetOrAdd(Inst inst, bool is_symbolic) -> ConstantId { return const_id; }); CARBON_CHECK(result.value() != ConstantId::Invalid); - CARBON_CHECK(result.value().is_symbolic() == is_symbolic); + CARBON_CHECK(result.value().is_symbolic() == is_symbolic) + << "Constant " << inst + << " registered as both symbolic and template constant."; return result.value(); } diff --git a/toolchain/sem_ir/constant.h b/toolchain/sem_ir/constant.h index 18af50611a570..1684403e9f3d3 100644 --- a/toolchain/sem_ir/constant.h +++ b/toolchain/sem_ir/constant.h @@ -6,6 +6,7 @@ #define CARBON_TOOLCHAIN_SEM_IR_CONSTANT_H_ #include "common/map.h" +#include "toolchain/base/yaml.h" #include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst.h" @@ -13,7 +14,7 @@ namespace Carbon::SemIR { // Information about a symbolic constant value. These are indexed by // `ConstantId`s for which `is_symbolic` is true. -struct SymbolicConstant { +struct SymbolicConstant : Printable { // The constant instruction that defines the value of this symbolic constant. InstId inst_id; // The enclosing generic. If this is invalid, then this is an abstract @@ -23,6 +24,11 @@ struct SymbolicConstant { // The index of this symbolic constant within the generic's list of symbolic // constants, or invalid if `generic_id` is invalid. GenericInstIndex index; + + auto Print(llvm::raw_ostream& out) const -> void { + out << "{inst: " << inst_id << ", generic: " << generic_id + << ", index: " << index << "}"; + } }; // Provides a ValueStore wrapper for tracking the constant values of @@ -96,11 +102,25 @@ class ConstantValueStore { return symbolic_constants_[const_id.symbolic_index()]; } + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "values_"), values_); + mem_usage.Add(MemUsage::ConcatLabel(label, "symbolic_constants_"), + symbolic_constants_); + } + // Returns the constant values mapping as an ArrayRef whose keys are // instruction indexes. Some of the elements in this mapping may be Invalid or // NotConstant. auto array_ref() const -> llvm::ArrayRef { return values_; } + // Returns the symbolic constants mapping as an ArrayRef whose keys are + // symbolic indexes of constants. + auto symbolic_constants() const -> llvm::ArrayRef { + return symbolic_constants_; + } + private: const ConstantId default_; @@ -133,6 +153,13 @@ class ConstantStore { // constant is new. auto GetOrAdd(Inst inst, bool is_symbolic) -> ConstantId; + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "map_"), map_); + mem_usage.Add(MemUsage::ConcatLabel(label, "constants_"), constants_); + } + // Returns a copy of the constant IDs as a vector, in an arbitrary but // stable order. This should not be used anywhere performance-sensitive. auto array_ref() const -> llvm::ArrayRef { return constants_; } diff --git a/toolchain/sem_ir/bind_name.h b/toolchain/sem_ir/entity_name.h similarity index 51% rename from toolchain/sem_ir/bind_name.h rename to toolchain/sem_ir/entity_name.h index 9328acfbefe59..d4a6e0eed9bab 100644 --- a/toolchain/sem_ir/bind_name.h +++ b/toolchain/sem_ir/entity_name.h @@ -2,8 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef CARBON_TOOLCHAIN_SEM_IR_BIND_NAME_H_ -#define CARBON_TOOLCHAIN_SEM_IR_BIND_NAME_H_ +#ifndef CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ +#define CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ #include "common/hashing.h" #include "common/set.h" @@ -12,15 +12,15 @@ namespace Carbon::SemIR { -struct BindNameInfo : public Printable { +struct EntityName : public Printable { auto Print(llvm::raw_ostream& out) const -> void { out << "{name: " << name_id << ", parent_scope: " << parent_scope_id << ", index: " << bind_index << "}"; } - friend auto CarbonHashtableEq(const BindNameInfo& lhs, - const BindNameInfo& rhs) -> bool { - return std::memcmp(&lhs, &rhs, sizeof(BindNameInfo)) == 0; + friend auto CarbonHashtableEq(const EntityName& lhs, const EntityName& rhs) + -> bool { + return std::memcmp(&lhs, &rhs, sizeof(EntityName)) == 0; } // The name. @@ -31,46 +31,46 @@ struct BindNameInfo : public Printable { CompileTimeBindIndex bind_index; }; -// Hashing for BindNameInfo. See common/hashing.h. -inline auto CarbonHashValue(const BindNameInfo& value, uint64_t seed) +// Hashing for EntityName. See common/hashing.h. +inline auto CarbonHashValue(const EntityName& value, uint64_t seed) -> HashCode { Hasher hasher(seed); hasher.HashRaw(value); return static_cast(hasher); } -// Value store for BindNameInfo. In addition to the regular ValueStore -// functionality, this can provide optional canonical IDs for BindNameInfos. -struct BindNameStore : public ValueStore { +// Value store for EntityName. In addition to the regular ValueStore +// functionality, this can provide optional canonical IDs for EntityNames. +struct EntityNameStore : public ValueStore { public: // Convert an ID to a canonical ID. All calls to this with equivalent - // `BindNameInfo`s will return the same `BindNameId`. - auto MakeCanonical(BindNameId id) -> BindNameId; + // `EntityName`s will return the same `EntityNameId`. + auto MakeCanonical(EntityNameId id) -> EntityNameId; private: class KeyContext; - Set canonical_ids_; + Set canonical_ids_; }; -class BindNameStore::KeyContext : public TranslatingKeyContext { +class EntityNameStore::KeyContext : public TranslatingKeyContext { public: - explicit KeyContext(const BindNameStore* store) : store_(store) {} + explicit KeyContext(const EntityNameStore* store) : store_(store) {} // Note that it is safe to return a `const` reference here as the underlying // object's lifetime is provided by the `store_`. - auto TranslateKey(BindNameId id) const -> const BindNameInfo& { + auto TranslateKey(EntityNameId id) const -> const EntityName& { return store_->Get(id); } private: - const BindNameStore* store_; + const EntityNameStore* store_; }; -inline auto BindNameStore::MakeCanonical(BindNameId id) -> BindNameId { +inline auto EntityNameStore::MakeCanonical(EntityNameId id) -> EntityNameId { return canonical_ids_.Insert(id, KeyContext(this)).key(); } } // namespace Carbon::SemIR -#endif // CARBON_TOOLCHAIN_SEM_IR_BIND_NAME_H_ +#endif // CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ diff --git a/toolchain/sem_ir/entity_with_params_base.h b/toolchain/sem_ir/entity_with_params_base.h new file mode 100644 index 0000000000000..e4d6da09a0639 --- /dev/null +++ b/toolchain/sem_ir/entity_with_params_base.h @@ -0,0 +1,91 @@ +// 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 + +#ifndef CARBON_TOOLCHAIN_SEM_IR_ENTITY_WITH_PARAMS_BASE_H_ +#define CARBON_TOOLCHAIN_SEM_IR_ENTITY_WITH_PARAMS_BASE_H_ + +#include "toolchain/sem_ir/ids.h" + +namespace Carbon::SemIR { + +// Common entity fields. +// +// `EntityWithParamsBase` would be a base class of entities like `Function`, +// except that then we couldn't use named initialization (or would need to +// disable warnings about mixing named and unnamed initialization) due to how +// C++ handles initialization of base structs. Instead, this is composed with a +// `Fields` struct to provide an entity's actual struct. +// +// For example: +// struct FunctionFields { +// ... data members ... +// }; +// +// struct Function : public EntityWithParamsBase, +// public FunctionFields, public Printable { +// ... methods ... +// }; +// +// This achieves a few things: +// - Allows named initialization, such as: +// `{{.name_id = ...}, {.function_field = ...}}` +// - Makes `entity.name_id` access work. +// - Allows passing a `EntityWithParamsBase*` when only common fields are +// needed. +// - Does all this in a way that's vanilla C++. +struct EntityWithParamsBase { + auto PrintBaseFields(llvm::raw_ostream& out) const -> void { + out << "name: " << name_id << ", parent_scope: " << parent_scope_id; + } + + // When merging a declaration and definition, prefer things which would point + // at the definition for diagnostics. + auto MergeDefinition(const EntityWithParamsBase& definition) -> void { + first_param_node_id = definition.first_param_node_id; + last_param_node_id = definition.last_param_node_id; + implicit_param_refs_id = definition.implicit_param_refs_id; + param_refs_id = definition.param_refs_id; + definition_id = definition.definition_id; + } + + // Returns the instruction for the latest declaration. + auto latest_decl_id() const -> SemIR::InstId { + return definition_id.is_valid() ? definition_id : decl_id; + } + + // Determines whether this is a generic entity. + auto is_generic() const -> bool { + return implicit_param_refs_id.is_valid() || param_refs_id.is_valid(); + } + + // The following members always have values, and do not change throughout the + // lifetime of the entity. + + // The class name. + NameId name_id; + // The parent scope. + NameScopeId parent_scope_id; + // If this is a generic function, information about the generic. + GenericId generic_id; + // Parse tree bounds for the parameters, including both implicit and explicit + // parameters. These will be compared to match between declaration and + // definition. + Parse::NodeId first_param_node_id; + Parse::NodeId last_param_node_id; + // A block containing a single reference instruction per implicit parameter. + InstBlockId implicit_param_refs_id; + // A block containing a single reference instruction per parameter. + InstBlockId param_refs_id; + // The first declaration of the entity. This will be a Decl. + InstId decl_id = InstId::Invalid; + + // The following members are set at the `{` of the definition. + + // The first declaration of the entity. This will be a Decl. + InstId definition_id = InstId::Invalid; +}; + +} // namespace Carbon::SemIR + +#endif // CARBON_TOOLCHAIN_SEM_IR_ENTITY_WITH_PARAMS_BASE_H_ diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index 560cc038d4180..caa33caf40b76 100644 --- a/toolchain/sem_ir/file.cpp +++ b/toolchain/sem_ir/file.cpp @@ -19,52 +19,12 @@ namespace Carbon::SemIR { -auto Function::GetParamFromParamRefId(const File& sem_ir, InstId param_ref_id) - -> std::pair { - auto ref = sem_ir.insts().Get(param_ref_id); - - if (auto addr_pattern = ref.TryAs()) { - param_ref_id = addr_pattern->inner_id; - ref = sem_ir.insts().Get(param_ref_id); - } - - if (auto bind_name = ref.TryAs()) { - param_ref_id = bind_name->value_id; - ref = sem_ir.insts().Get(param_ref_id); - } - - return {param_ref_id, ref.As()}; -} - -auto ValueRepr::Print(llvm::raw_ostream& out) const -> void { - out << "{kind: "; - switch (kind) { - case Unknown: - out << "unknown"; - break; - case None: - out << "none"; - break; - case Copy: - out << "copy"; - break; - case Pointer: - out << "pointer"; - break; - case Custom: - out << "custom"; - break; - } - out << ", type: " << type_id << "}"; -} - -auto TypeInfo::Print(llvm::raw_ostream& out) const -> void { - out << "{constant: " << constant_id << ", value_rep: " << value_repr << "}"; -} - -File::File(CheckIRId check_ir_id, SharedValueStores& value_stores, +File::File(CheckIRId check_ir_id, IdentifierId package_id, + StringLiteralValueId library_id, SharedValueStores& value_stores, std::string filename) : check_ir_id_(check_ir_id), + package_id_(package_id), + library_id_(library_id), value_stores_(&value_stores), filename_(std::move(filename)), type_blocks_(allocator_), @@ -72,6 +32,12 @@ File::File(CheckIRId check_ir_id, SharedValueStores& value_stores, constant_values_(ConstantId::NotConstant), inst_blocks_(allocator_), constants_(*this, allocator_) { + // `type` and the error type are both complete types. + types_.SetValueRepr(TypeId::TypeType, + {.kind = ValueRepr::Copy, .type_id = TypeId::TypeType}); + types_.SetValueRepr(TypeId::Error, + {.kind = ValueRepr::Copy, .type_id = TypeId::Error}); + insts_.Reserve(BuiltinInstKind::ValidCount); // Error uses a self-referential type so that it's not accidentally treated as // a normal type. Every other builtin is a type, including the @@ -139,11 +105,11 @@ auto File::OutputYaml(bool include_builtins) const -> Yaml::OutputMapping { map.Add("import_irs", import_irs_.OutputYaml()); map.Add("import_ir_insts", import_ir_insts_.OutputYaml()); map.Add("name_scopes", name_scopes_.OutputYaml()); - map.Add("bind_names", bind_names_.OutputYaml()); + map.Add("entity_names", entity_names_.OutputYaml()); map.Add("functions", functions_.OutputYaml()); map.Add("classes", classes_.OutputYaml()); map.Add("generics", generics_.OutputYaml()); - map.Add("generic_instances", generic_instances_.OutputYaml()); + map.Add("specifics", specifics_.OutputYaml()); map.Add("types", types_.OutputYaml()); map.Add("type_blocks", type_blocks_.OutputYaml()); map.Add( @@ -167,11 +133,45 @@ auto File::OutputYaml(bool include_builtins) const -> Yaml::OutputMapping { } } })); + map.Add( + "symbolic_constants", + Yaml::OutputMapping([&](Yaml::OutputMapping::Map map) { + for (const auto& [i, symbolic] : + llvm::enumerate(constant_values().symbolic_constants())) { + map.Add( + PrintToString(ConstantId::ForSymbolicConstantIndex(i)), + Yaml::OutputScalar(symbolic)); + } + })); map.Add("inst_blocks", inst_blocks_.OutputYaml()); })); }); } +auto File::CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "allocator_"), allocator_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "entity_names_"), + entity_names_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "functions_"), functions_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "classes_"), classes_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "interfaces_"), interfaces_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "impls_"), impls_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "generics_"), generics_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "specifics_"), specifics_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "import_irs_"), import_irs_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "import_ir_insts_"), + import_ir_insts_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "type_blocks_"), type_blocks_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "insts_"), insts_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "name_scopes_"), name_scopes_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "constant_values_"), + constant_values_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "inst_blocks_"), inst_blocks_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "constants_"), constants_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "types_"), types_); +} + // Map an instruction kind representing a type into an integer describing the // precedence of that type's syntax. Higher numbers correspond to higher // precedence. @@ -256,9 +256,10 @@ static auto StringifyTypeExprImpl(const SemIR::File& outer_sem_ir, case BindAlias::Kind: case BindSymbolicName::Kind: case ExportDecl::Kind: { - auto name_id = untyped_inst.As().bind_name_id; + auto name_id = + untyped_inst.As().entity_name_id; out << sem_ir.names().GetFormatted( - sem_ir.bind_names().Get(name_id).name_id); + sem_ir.entity_names().Get(name_id).name_id); break; } case CARBON_KIND(ClassType inst): { @@ -663,25 +664,4 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { } } -auto GetInitRepr(const File& file, TypeId type_id) -> InitRepr { - auto value_rep = GetValueRepr(file, type_id); - switch (value_rep.kind) { - case ValueRepr::None: - return {.kind = InitRepr::None}; - - case ValueRepr::Copy: - // TODO: Use in-place initialization for types that have non-trivial - // destructive move. - return {.kind = InitRepr::ByCopy}; - - case ValueRepr::Pointer: - case ValueRepr::Custom: - return {.kind = InitRepr::InPlace}; - - case ValueRepr::Unknown: - CARBON_FATAL() - << "Attempting to perform initialization of incomplete type"; - } -} - } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index c742211663726..e2ea1d3a6ef2f 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -12,9 +12,9 @@ #include "llvm/Support/FormatVariadic.h" #include "toolchain/base/value_store.h" #include "toolchain/base/yaml.h" -#include "toolchain/sem_ir/bind_name.h" #include "toolchain/sem_ir/class.h" #include "toolchain/sem_ir/constant.h" +#include "toolchain/sem_ir/entity_name.h" #include "toolchain/sem_ir/function.h" #include "toolchain/sem_ir/generic.h" #include "toolchain/sem_ir/ids.h" @@ -33,8 +33,9 @@ namespace Carbon::SemIR { class File : public Printable { public: // Starts a new file for Check::CheckParseTree. - explicit File(CheckIRId check_ir_id, SharedValueStores& value_stores, - std::string filename); + explicit File(CheckIRId check_ir_id, IdentifierId package_id, + StringLiteralValueId library_id, + SharedValueStores& value_stores, std::string filename); File(const File&) = delete; auto operator=(const File&) -> File& = delete; @@ -53,6 +54,10 @@ class File : public Printable { } auto OutputYaml(bool include_builtins) const -> Yaml::OutputMapping; + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void; + // Returns array bound value from the bound instruction. auto GetArrayBoundValue(InstId bound_id) const -> uint64_t { return ints() @@ -60,19 +65,6 @@ class File : public Printable { .getZExtValue(); } - // Marks a type as complete, and sets its value representation. - auto CompleteType(TypeId object_type_id, ValueRepr value_repr) -> void { - if (object_type_id.index < 0) { - // We already know our builtin types are complete. - return; - } - CARBON_CHECK(types().Get(object_type_id).value_repr.kind == - ValueRepr::Unknown) - << "Type " << object_type_id << " completed more than once"; - types().Get(object_type_id).value_repr = value_repr; - complete_types_.push_back(object_type_id); - } - // Gets the pointee type of the given type, which must be a pointer type. auto GetPointeeType(TypeId pointer_id) const -> TypeId { return types().GetAs(pointer_id).pointee_id; @@ -89,6 +81,8 @@ class File : public Printable { auto StringifyTypeExpr(InstId outer_inst_id) const -> std::string; auto check_ir_id() const -> CheckIRId { return check_ir_id_; } + auto package_id() const -> IdentifierId { return package_id_; } + auto library_id() const -> StringLiteralValueId { return library_id_; } // Directly expose SharedValueStores members. auto identifiers() -> CanonicalValueStore& { @@ -117,8 +111,8 @@ class File : public Printable { return value_stores_->string_literal_values(); } - auto bind_names() -> BindNameStore& { return bind_names_; } - auto bind_names() const -> const BindNameStore& { return bind_names_; } + auto entity_names() -> EntityNameStore& { return entity_names_; } + auto entity_names() const -> const EntityNameStore& { return entity_names_; } auto functions() -> ValueStore& { return functions_; } auto functions() const -> const ValueStore& { return functions_; } auto classes() -> ValueStore& { return classes_; } @@ -131,12 +125,8 @@ class File : public Printable { auto impls() const -> const ImplStore& { return impls_; } auto generics() -> GenericStore& { return generics_; } auto generics() const -> const GenericStore& { return generics_; } - auto generic_instances() -> GenericInstanceStore& { - return generic_instances_; - } - auto generic_instances() const -> const GenericInstanceStore& { - return generic_instances_; - } + auto specifics() -> SpecificStore& { return specifics_; } + auto specifics() const -> const SpecificStore& { return specifics_; } auto import_irs() -> ValueStore& { return import_irs_; } auto import_irs() const -> const ValueStore& { return import_irs_; @@ -169,13 +159,6 @@ class File : public Printable { auto constants() -> ConstantStore& { return constants_; } auto constants() const -> const ConstantStore& { return constants_; } - // A list of types that were completed in this file, in the order in which - // they were completed. Earlier types in this list cannot contain instances of - // later types. - auto complete_types() const -> llvm::ArrayRef { - return complete_types_; - } - auto top_inst_block_id() const -> InstBlockId { return top_inst_block_id_; } auto set_top_inst_block_id(InstBlockId block_id) -> void { top_inst_block_id_ = block_id; @@ -188,10 +171,18 @@ class File : public Printable { auto filename() const -> llvm::StringRef { return filename_; } private: + // True if parts of the IR may be invalid. bool has_errors_ = false; + // The file's ID. CheckIRId check_ir_id_; + // The file's package. + IdentifierId package_id_ = IdentifierId::Invalid; + + // The file's library. + StringLiteralValueId library_id_ = StringLiteralValueId::Invalid; + // Shared, compile-scoped values. SharedValueStores* value_stores_; @@ -202,8 +193,8 @@ class File : public Printable { // TODO: If SemIR starts linking back to tokens, reuse its filename. std::string filename_; - // Storage for bind names. - BindNameStore bind_names_; + // Storage for EntityNames. + EntityNameStore entity_names_; // Storage for callable objects. ValueStore functions_; @@ -220,8 +211,8 @@ class File : public Printable { // Storage for generics. GenericStore generics_; - // Storage for instances of generics. - GenericInstanceStore generic_instances_; + // Storage for specifics. + SpecificStore specifics_; // Related IRs. There are some fixed entries at the start; see ImportIRId. ValueStore import_irs_; @@ -257,9 +248,6 @@ class File : public Printable { // Descriptions of types used in this file. TypeStore types_ = TypeStore(&insts_, &constant_values_); - - // Types that were completed in this file. - llvm::SmallVector complete_types_; }; // The expression category of a sem_ir instruction. See /docs/design/values.md @@ -294,37 +282,6 @@ enum class ExprCategory : int8_t { // Returns the expression category for an instruction. auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory; -// Returns information about the value representation to use for a type. -inline auto GetValueRepr(const File& file, TypeId type_id) -> ValueRepr { - return file.types().GetValueRepr(type_id); -} - -// The initializing representation to use when returning by value. -struct InitRepr { - enum Kind : int8_t { - // The type has no initializing representation. This is used for empty - // types, where no initialization is necessary. - None, - // An initializing expression produces an object representation by value, - // which is copied into the initialized object. - ByCopy, - // An initializing expression takes a location as input, which is - // initialized as a side effect of evaluating the expression. - InPlace, - // TODO: Consider adding a kind where the expression takes an advisory - // location and returns a value plus an indicator of whether the location - // was actually initialized. - }; - // The kind of initializing representation used by this type. - Kind kind; - - // Returns whether a return slot is used when returning this type. - auto has_return_slot() const -> bool { return kind == InPlace; } -}; - -// Returns information about the initializing representation to use for a type. -auto GetInitRepr(const File& file, TypeId type_id) -> InitRepr; - } // namespace Carbon::SemIR #endif // CARBON_TOOLCHAIN_SEM_IR_FILE_H_ diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index cbef76da237c6..dd6019ee5b88c 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -22,16 +22,11 @@ namespace Carbon::SemIR { // Formatter for printing textual Semantics IR. -class Formatter { +class FormatterImpl { public: - enum class AddSpace : bool { Before, After }; - - explicit Formatter(const Lex::TokenizedBuffer& tokenized_buffer, - const Parse::Tree& parse_tree, const File& sem_ir, - llvm::raw_ostream& out) - : sem_ir_(sem_ir), - out_(out), - inst_namer_(tokenized_buffer, parse_tree, sem_ir) {} + explicit FormatterImpl(const File& sem_ir, InstNamer* inst_namer, + llvm::raw_ostream& out, int indent) + : sem_ir_(sem_ir), inst_namer_(inst_namer), out_(out), indent_(indent) {} // Prints the SemIR. // @@ -41,10 +36,11 @@ class Formatter { auto Format() -> void { out_ << "--- " << sem_ir_.filename() << "\n\n"; - FormatConstants(); - FormatImportRefs(); + FormatScope(InstNamer::ScopeId::Constants, sem_ir_.constants().array_ref()); + FormatScope(InstNamer::ScopeId::ImportRefs, + sem_ir_.inst_blocks().Get(InstBlockId::ImportRefs)); - out_ << inst_namer_.GetScopeName(InstNamer::ScopeId::File) << " "; + out_ << inst_namer_->GetScopeName(InstNamer::ScopeId::File) << " "; OpenBrace(); // TODO: Handle the case where there are multiple top-level instruction @@ -74,10 +70,45 @@ class Formatter { FormatFunction(FunctionId(i)); } + for (int i : llvm::seq(sem_ir_.specifics().size())) { + FormatSpecific(SpecificId(i)); + } + // End-of-file newline. out_ << "\n"; } + // Prints a code block. + auto FormatPartialTrailingCodeBlock(llvm::ArrayRef block) + -> void { + out_ << ' '; + OpenBrace(); + constexpr int NumPrintedOnSkip = 9; + // Avoid only skipping one item. + if (block.size() > NumPrintedOnSkip + 1) { + Indent(); + out_ << "... skipping " << (block.size() - NumPrintedOnSkip) + << " insts ...\n"; + block = block.take_back(NumPrintedOnSkip); + } + FormatCodeBlock(block); + CloseBrace(); + } + + // Prints a single instruction. + auto FormatInst(InstId inst_id) -> void { + if (!inst_id.is_valid()) { + Indent(); + out_ << "invalid\n"; + return; + } + + FormatInst(inst_id, sem_ir_.insts().Get(inst_id)); + } + + private: + enum class AddSpace : bool { Before, After }; + // Begins a braced block. Writes an open brace, and prepares to insert a // newline after it if the braced block is non-empty. auto OpenBrace() -> void { @@ -121,52 +152,27 @@ class Formatter { Indent(-2); } - // Wraps the current line, prior to some text that we expect to be quite long - // and more readable on a separate line. This is indented two levels more than - // the ambient text. - auto WrapLine() -> void { - out_ << '\n'; - Indent(4); - } - - auto FormatConstants() -> void { - if (!sem_ir_.constants().size()) { - return; - } - - llvm::SaveAndRestore constants_scope(scope_, InstNamer::ScopeId::Constants); - out_ << inst_namer_.GetScopeName(InstNamer::ScopeId::Constants) << " "; - OpenBrace(); - FormatCodeBlock(sem_ir_.constants().array_ref()); - CloseBrace(); - out_ << "\n\n"; - } - - auto FormatImportRefs() -> void { - auto import_refs = sem_ir_.inst_blocks().Get(InstBlockId::ImportRefs); - if (import_refs.empty()) { + // Formats a top-level scope, particularly Constants and ImportRefs. + auto FormatScope(InstNamer::ScopeId scope_id, llvm::ArrayRef block) + -> void { + if (block.empty()) { return; } - llvm::SaveAndRestore scope(scope_, InstNamer::ScopeId::ImportRefs); - out_ << inst_namer_.GetScopeName(InstNamer::ScopeId::ImportRefs) << " "; + llvm::SaveAndRestore scope(scope_, scope_id); + out_ << inst_namer_->GetScopeName(scope_id) << " "; OpenBrace(); - FormatCodeBlock(import_refs); + FormatCodeBlock(block); CloseBrace(); out_ << "\n\n"; } + // Formats a full class. auto FormatClass(ClassId id) -> void { const Class& class_info = sem_ir_.classes().Get(id); + FormatEntityStart("class", class_info.generic_id, id); - out_ << "\nclass "; - FormatClassName(id); - - if (class_info.generic_id.is_valid()) { - FormatGeneric(class_info.generic_id); - } - - llvm::SaveAndRestore class_scope(scope_, inst_namer_.GetScopeFor(id)); + llvm::SaveAndRestore class_scope(scope_, inst_namer_->GetScopeFor(id)); if (class_info.scope_id.is_valid()) { out_ << ' '; @@ -178,19 +184,16 @@ class Formatter { } else { out_ << ";\n"; } + + FormatEntityEnd(class_info.generic_id); } + // Formats a full interface. auto FormatInterface(InterfaceId id) -> void { const Interface& interface_info = sem_ir_.interfaces().Get(id); + FormatEntityStart("interface", interface_info.generic_id, id); - out_ << "\ninterface "; - FormatInterfaceName(id); - - if (interface_info.generic_id.is_valid()) { - FormatGeneric(interface_info.generic_id); - } - - llvm::SaveAndRestore interface_scope(scope_, inst_namer_.GetScopeFor(id)); + llvm::SaveAndRestore interface_scope(scope_, inst_namer_->GetScopeFor(id)); if (interface_info.scope_id.is_valid()) { out_ << ' '; @@ -213,20 +216,22 @@ class Formatter { } else { out_ << ";\n"; } + + FormatEntityEnd(interface_info.generic_id); } + // Formats a full impl. auto FormatImpl(ImplId id) -> void { const Impl& impl_info = sem_ir_.impls().Get(id); + FormatEntityStart("impl", SemIR::GenericId::Invalid, id); - out_ << "\nimpl "; - FormatImplName(id); out_ << ": "; // TODO: Include the deduced parameter list if present. FormatType(impl_info.self_id); out_ << " as "; FormatType(impl_info.constraint_id); - llvm::SaveAndRestore impl_scope(scope_, inst_namer_.GetScopeFor(id)); + llvm::SaveAndRestore impl_scope(scope_, inst_namer_->GetScopeFor(id)); if (impl_info.scope_id.is_valid()) { out_ << ' '; @@ -251,36 +256,22 @@ class Formatter { } } + // Formats a full function. auto FormatFunction(FunctionId id) -> void { const Function& fn = sem_ir_.functions().Get(id); + FormatEntityStart(fn.is_extern ? "extern fn" : "fn", fn.generic_id, id); - out_ << "\n"; - - if (fn.is_extern) { - out_ << "extern "; - } - - out_ << "fn "; - FormatFunctionName(id); + llvm::SaveAndRestore function_scope(scope_, inst_namer_->GetScopeFor(id)); - llvm::SaveAndRestore function_scope(scope_, inst_namer_.GetScopeFor(id)); - - if (fn.implicit_param_refs_id.is_valid()) { - out_ << "["; - FormatParamList(fn.implicit_param_refs_id); - out_ << "]"; - } - - if (fn.param_refs_id.is_valid()) { - out_ << "("; - FormatParamList(fn.param_refs_id); - out_ << ")"; - } + FormatParamList(fn.implicit_param_refs_id, /*is_implicit=*/true); + FormatParamList(fn.param_refs_id, /*is_implicit=*/false); if (fn.return_storage_id.is_valid()) { out_ << " -> "; - if (!fn.body_block_ids.empty() && fn.has_return_slot()) { - FormatInstName(fn.return_storage_id); + auto return_info = ReturnTypeInfo::ForFunction(sem_ir_, fn); + if (!fn.body_block_ids.empty() && return_info.is_valid() && + return_info.has_return_slot()) { + FormatName(fn.return_storage_id); out_ << ": "; } FormatType(sem_ir_.insts().Get(fn.return_storage_id).type_id()); @@ -293,10 +284,6 @@ class Formatter { out_ << "\""; } - if (fn.generic_id.is_valid()) { - FormatGeneric(fn.generic_id); - } - if (!fn.body_block_ids.empty()) { out_ << ' '; OpenBrace(); @@ -314,20 +301,142 @@ class Formatter { } else { out_ << ";\n"; } + + FormatEntityEnd(fn.generic_id); + } + + // Helper for FormatSpecific to print regions. + auto FormatSpecificRegion(const Generic& generic, const Specific& specific, + GenericInstIndex::Region region, + llvm::StringRef region_name) -> void { + if (!specific.GetValueBlock(region).is_valid()) { + return; + } + + if (!region_name.empty()) { + IndentLabel(); + out_ << "!" << region_name << ":\n"; + } + for (auto [generic_inst_id, specific_inst_id] : llvm::zip_longest( + sem_ir_.inst_blocks().Get(generic.GetEvalBlock(region)), + sem_ir_.inst_blocks().Get(specific.GetValueBlock(region)))) { + if (generic_inst_id && specific_inst_id && + sem_ir_.insts().Is(*generic_inst_id) && + sem_ir_.insts().Is(*specific_inst_id)) { + // Skip printing struct type fields to match the way we print the + // generic. + continue; + } + + Indent(); + if (generic_inst_id) { + FormatName(*generic_inst_id); + } else { + out_ << ""; + } + out_ << " => "; + if (specific_inst_id) { + FormatName(*specific_inst_id); + } else { + out_ << ""; + } + out_ << "\n"; + } + } + + // Formats a full specific. + auto FormatSpecific(SpecificId id) -> void { + const auto& specific = sem_ir_.specifics().Get(id); + + out_ << "\n"; + + out_ << "specific "; + FormatName(id); + + // TODO: Remove once we stop forming generic specifics with no generic + // during import. + if (!specific.generic_id.is_valid()) { + out_ << ";\n"; + return; + } + out_ << " "; + + const auto& generic = sem_ir_.generics().Get(specific.generic_id); + llvm::SaveAndRestore generic_scope( + scope_, inst_namer_->GetScopeFor(specific.generic_id)); + + OpenBrace(); + FormatSpecificRegion(generic, specific, + GenericInstIndex::Region::Declaration, ""); + FormatSpecificRegion(generic, specific, + GenericInstIndex::Region::Definition, "definition"); + CloseBrace(); + + out_ << "\n"; } - auto FormatGeneric(GenericId generic_id) -> void { + // Handles generic-specific setup for FormatEntityStart. + auto FormatGenericStart(llvm::StringRef entity_kind, GenericId generic_id) + -> void { const auto& generic = sem_ir_.generics().Get(generic_id); + out_ << "\n"; + Indent(); + out_ << "generic " << entity_kind << " "; + FormatName(generic_id); - WrapLine(); - out_ << "generic ["; - FormatParamList(generic.bindings_id); - out_ << "]"; - // TODO: Format at least the portions of the declaration and definition - // blocks that don't duplicate portions of the generic body. + llvm::SaveAndRestore generic_scope(scope_, + inst_namer_->GetScopeFor(generic_id)); + + FormatParamList(generic.bindings_id, /*is_implicit=*/false); + + out_ << " "; + OpenBrace(); + FormatCodeBlock(generic.decl_block_id); + if (generic.definition_block_id.is_valid()) { + IndentLabel(); + out_ << "!definition:\n"; + FormatCodeBlock(generic.definition_block_id); + } + } + + // Provides common formatting for entities, paired with FormatEntityEnd. + template + auto FormatEntityStart(llvm::StringRef entity_kind, GenericId generic_id, + IdT entity_id) -> void { + if (generic_id.is_valid()) { + FormatGenericStart(entity_kind, generic_id); + } + + out_ << "\n"; + Indent(); + out_ << entity_kind; + + // If there's a generic, it will have attached the name. Otherwise, add the + // name here. + if (!generic_id.is_valid()) { + out_ << " "; + FormatName(entity_id); + } } - auto FormatParamList(InstBlockId param_refs_id) -> void { + // Provides common formatting for entities, paired with FormatEntityStart. + auto FormatEntityEnd(GenericId generic_id) -> void { + if (generic_id.is_valid()) { + CloseBrace(); + out_ << '\n'; + } + } + + // Formats parameters, eliding them completely if they're empty. Wraps in + // parentheses or square brackets based on whether these are implicit + // parameters. + auto FormatParamList(InstBlockId param_refs_id, bool is_implicit) -> void { + if (!param_refs_id.is_valid()) { + return; + } + + out_ << (is_implicit ? "[" : "("); + llvm::ListSeparator sep; for (InstId param_id : sem_ir_.inst_blocks().Get(param_refs_id)) { out_ << sep; @@ -339,24 +448,30 @@ class Formatter { out_ << "addr "; param_id = addr->inner_id; } - FormatInstName(param_id); + FormatName(param_id); out_ << ": "; FormatType(sem_ir_.insts().Get(param_id).type_id()); } + + out_ << (is_implicit ? "]" : ")"); } + // Prints instructions for a code block. auto FormatCodeBlock(InstBlockId block_id) -> void { if (block_id.is_valid()) { FormatCodeBlock(sem_ir_.inst_blocks().Get(block_id)); } } + // Prints instructions for a code block. auto FormatCodeBlock(llvm::ArrayRef block) -> void { for (const InstId inst_id : block) { - FormatInstruction(inst_id); + FormatInst(inst_id); } } + // Prints a code block with braces, intended to be used trailing after other + // content on the same line. If non-empty, instructions are on separate lines. auto FormatTrailingBlock(InstBlockId block_id) -> void { out_ << ' '; OpenBrace(); @@ -364,11 +479,12 @@ class Formatter { CloseBrace(); } + // Prints the contents of a name scope, with an optional label. auto FormatNameScope(NameScopeId id, llvm::StringRef label = "") -> void { const auto& scope = sem_ir_.name_scopes().Get(id); if (scope.names.empty() && scope.extended_scopes.empty() && - !scope.has_error) { + scope.import_ir_scopes.empty() && !scope.has_error) { // Name scope is empty. return; } @@ -393,7 +509,7 @@ class Formatter { break; } out_ << " = "; - FormatInstName(inst_id); + FormatName(inst_id); out_ << "\n"; } @@ -403,52 +519,49 @@ class Formatter { out_ << "extend " << extended_scope_id << "\n"; } - if (scope.has_error) { + for (auto [import_ir_id, unused] : scope.import_ir_scopes) { Indent(); - out_ << "has_error\n"; + out_ << "import "; + FormatArg(import_ir_id); + out_ << "\n"; } - } - auto FormatInstruction(InstId inst_id) -> void { - if (!inst_id.is_valid()) { + if (scope.has_error) { Indent(); - out_ << "invalid\n"; - return; + out_ << "has_error\n"; } - - FormatInstruction(inst_id, sem_ir_.insts().Get(inst_id)); } - auto FormatInstruction(InstId inst_id, Inst inst) -> void { + auto FormatInst(InstId inst_id, Inst inst) -> void { CARBON_KIND_SWITCH(inst) { -#define CARBON_SEM_IR_INST_KIND(InstT) \ - case CARBON_KIND(InstT typed_inst): { \ - FormatInstruction(inst_id, typed_inst); \ - break; \ +#define CARBON_SEM_IR_INST_KIND(InstT) \ + case CARBON_KIND(InstT typed_inst): { \ + FormatInst(inst_id, typed_inst); \ + break; \ } #include "toolchain/sem_ir/inst_kind.def" } } template - auto FormatInstruction(InstId inst_id, InstT inst) -> void { + auto FormatInst(InstId inst_id, InstT inst) -> void { Indent(); - FormatInstructionLHS(inst_id, inst); + FormatInstLHS(inst_id, inst); out_ << InstT::Kind.ir_name(); pending_constant_value_ = sem_ir_.constant_values().Get(inst_id); pending_constant_value_is_self_ = sem_ir_.constant_values().GetInstId(pending_constant_value_) == inst_id; - FormatInstructionRHS(inst); + FormatInstRHS(inst); FormatPendingConstantValue(AddSpace::Before); out_ << "\n"; } // Don't print a constant for ImportRefUnloaded. - auto FormatInstruction(InstId inst_id, ImportRefUnloaded inst) -> void { + auto FormatInst(InstId inst_id, ImportRefUnloaded inst) -> void { Indent(); - FormatInstructionLHS(inst_id, inst); + FormatInstLHS(inst_id, inst); out_ << ImportRefUnloaded::Kind.ir_name(); - FormatInstructionRHS(inst); + FormatInstRHS(inst); out_ << "\n"; } @@ -481,10 +594,10 @@ class Formatter { pending_constant_value_ = ConstantId::NotConstant; } - auto FormatInstructionLHS(InstId inst_id, Inst inst) -> void { + auto FormatInstLHS(InstId inst_id, Inst inst) -> void { switch (inst.kind().value_kind()) { case InstValueKind::Typed: - FormatInstName(inst_id); + FormatName(inst_id); out_ << ": "; switch (GetExprCategory(sem_ir_, inst_id)) { case ExprCategory::NotExpr: @@ -509,21 +622,20 @@ class Formatter { } // Format ImportDecl with its name. - auto FormatInstructionLHS(InstId inst_id, ImportDecl /*inst*/) -> void { - FormatInstName(inst_id); + auto FormatInstLHS(InstId inst_id, ImportDecl /*inst*/) -> void { + FormatName(inst_id); out_ << " = "; } // Print ImportRefUnloaded with type-like semantics even though it lacks a // type_id. - auto FormatInstructionLHS(InstId inst_id, ImportRefUnloaded /*inst*/) - -> void { - FormatInstName(inst_id); + auto FormatInstLHS(InstId inst_id, ImportRefUnloaded /*inst*/) -> void { + FormatName(inst_id); out_ << " = "; } template - auto FormatInstructionRHS(InstT inst) -> void { + auto FormatInstRHS(InstT inst) -> void { // By default, an instruction has a comma-separated argument list. using Info = Internal::InstLikeTypeInfo; if constexpr (Info::NumArgs == 2) { @@ -535,22 +647,22 @@ class Formatter { } } - auto FormatInstructionRHS(BindSymbolicName inst) -> void { + auto FormatInstRHS(BindSymbolicName inst) -> void { // A BindSymbolicName with no value is a purely symbolic binding, such as // the `Self` in an interface. Don't print out `invalid` for the value. if (inst.value_id.is_valid()) { - FormatArgs(inst.bind_name_id, inst.value_id); + FormatArgs(inst.entity_name_id, inst.value_id); } else { - FormatArgs(inst.bind_name_id); + FormatArgs(inst.entity_name_id); } } - auto FormatInstructionRHS(BlockArg inst) -> void { + auto FormatInstRHS(BlockArg inst) -> void { out_ << " "; FormatLabel(inst.block_id); } - auto FormatInstructionRHS(Namespace inst) -> void { + auto FormatInstRHS(Namespace inst) -> void { if (inst.import_id.is_valid()) { FormatArgs(inst.import_id, inst.name_scope_id); } else { @@ -558,31 +670,31 @@ class Formatter { } } - auto FormatInstruction(InstId /*inst_id*/, BranchIf inst) -> void { + auto FormatInst(InstId /*inst_id*/, BranchIf inst) -> void { if (!in_terminator_sequence_) { Indent(); } out_ << "if "; - FormatInstName(inst.cond_id); + FormatName(inst.cond_id); out_ << " " << Branch::Kind.ir_name() << " "; FormatLabel(inst.target_id); out_ << " else "; in_terminator_sequence_ = true; } - auto FormatInstruction(InstId /*inst_id*/, BranchWithArg inst) -> void { + auto FormatInst(InstId /*inst_id*/, BranchWithArg inst) -> void { if (!in_terminator_sequence_) { Indent(); } out_ << BranchWithArg::Kind.ir_name() << " "; FormatLabel(inst.target_id); out_ << "("; - FormatInstName(inst.arg_id); + FormatName(inst.arg_id); out_ << ")\n"; in_terminator_sequence_ = false; } - auto FormatInstruction(InstId /*inst_id*/, Branch inst) -> void { + auto FormatInst(InstId /*inst_id*/, Branch inst) -> void { if (!in_terminator_sequence_) { Indent(); } @@ -592,7 +704,7 @@ class Formatter { in_terminator_sequence_ = false; } - auto FormatInstructionRHS(Call inst) -> void { + auto FormatInstRHS(Call inst) -> void { out_ << " "; FormatArg(inst.callee_id); @@ -603,7 +715,8 @@ class Formatter { llvm::ArrayRef args = sem_ir_.inst_blocks().Get(inst.args_id); - bool has_return_slot = GetInitRepr(sem_ir_, inst.type_id).has_return_slot(); + auto return_info = ReturnTypeInfo::ForType(sem_ir_, inst.type_id); + bool has_return_slot = return_info.has_return_slot(); InstId return_slot_id = InstId::Invalid; if (has_return_slot) { return_slot_id = args.back(); @@ -623,102 +736,109 @@ class Formatter { } } - auto FormatInstructionRHS(ArrayInit inst) -> void { + auto FormatInstRHS(ArrayInit inst) -> void { FormatArgs(inst.inits_id); FormatReturnSlot(inst.dest_id); } - auto FormatInstructionRHS(InitializeFrom inst) -> void { + auto FormatInstRHS(InitializeFrom inst) -> void { FormatArgs(inst.src_id); FormatReturnSlot(inst.dest_id); } - auto FormatInstructionRHS(ReturnExpr ret) -> void { + auto FormatInstRHS(ReturnExpr ret) -> void { FormatArgs(ret.expr_id); if (ret.dest_id.is_valid()) { FormatReturnSlot(ret.dest_id); } } - auto FormatInstructionRHS(StructInit init) -> void { + auto FormatInstRHS(StructInit init) -> void { FormatArgs(init.elements_id); FormatReturnSlot(init.dest_id); } - auto FormatInstructionRHS(TupleInit init) -> void { + auto FormatInstRHS(TupleInit init) -> void { FormatArgs(init.elements_id); FormatReturnSlot(init.dest_id); } - auto FormatInstructionRHS(FunctionDecl inst) -> void { + auto FormatInstRHS(FunctionDecl inst) -> void { FormatArgs(inst.function_id); FormatTrailingBlock(inst.decl_block_id); } - auto FormatInstructionRHS(ClassDecl inst) -> void { + auto FormatInstRHS(FunctionType inst) -> void { + if (inst.specific_id.is_valid()) { + FormatArgs(inst.function_id, inst.specific_id); + } else { + FormatArgs(inst.function_id); + } + } + + auto FormatInstRHS(ClassDecl inst) -> void { FormatArgs(inst.class_id); FormatTrailingBlock(inst.decl_block_id); } - auto FormatInstructionRHS(ClassType inst) -> void { - if (inst.instance_id.is_valid()) { - FormatArgs(inst.class_id, inst.instance_id); + auto FormatInstRHS(ClassType inst) -> void { + if (inst.specific_id.is_valid()) { + FormatArgs(inst.class_id, inst.specific_id); } else { FormatArgs(inst.class_id); } } - auto FormatInstructionRHS(ImplDecl inst) -> void { + auto FormatInstRHS(ImplDecl inst) -> void { FormatArgs(inst.impl_id); FormatTrailingBlock(inst.decl_block_id); } - auto FormatInstructionRHS(InterfaceDecl inst) -> void { + auto FormatInstRHS(InterfaceDecl inst) -> void { FormatArgs(inst.interface_id); FormatTrailingBlock(inst.decl_block_id); } - auto FormatInstructionRHS(InterfaceType inst) -> void { - if (inst.instance_id.is_valid()) { - FormatArgs(inst.interface_id, inst.instance_id); + auto FormatInstRHS(InterfaceType inst) -> void { + if (inst.specific_id.is_valid()) { + FormatArgs(inst.interface_id, inst.specific_id); } else { FormatArgs(inst.interface_id); } } - auto FormatInstructionRHS(IntLiteral inst) -> void { + auto FormatInstRHS(IntLiteral inst) -> void { out_ << " "; sem_ir_.ints() .Get(inst.int_id) .print(out_, sem_ir_.types().IsSignedInt(inst.type_id)); } - auto FormatInstructionRHS(FloatLiteral inst) -> void { + auto FormatInstRHS(FloatLiteral inst) -> void { llvm::SmallVector buffer; sem_ir_.floats().Get(inst.float_id).toString(buffer); out_ << " " << buffer; } - auto FormatInstructionRHS(ImportRefUnloaded inst) -> void { + auto FormatInstRHS(ImportRefUnloaded inst) -> void { FormatArgs(inst.import_ir_inst_id); out_ << ", unloaded"; } - auto FormatInstructionRHS(ImportRefLoaded inst) -> void { + auto FormatInstRHS(ImportRefLoaded inst) -> void { FormatArgs(inst.import_ir_inst_id); out_ << ", loaded"; } - auto FormatInstructionRHS(SpliceBlock inst) -> void { + auto FormatInstRHS(SpliceBlock inst) -> void { FormatArgs(inst.result_id); FormatTrailingBlock(inst.block_id); } // StructTypeFields are formatted as part of their StructType. - auto FormatInstruction(InstId /*inst_id*/, StructTypeField /*inst*/) -> void { - } + auto FormatInst(InstId /*inst_id*/, StructTypeField /*inst*/) -> void {} - auto FormatInstructionRHS(StructType inst) -> void { + auto FormatInstRHS(StructType inst) -> void { out_ << " {"; llvm::ListSeparator sep; for (auto field_id : sem_ir_.inst_blocks().Get(inst.fields_id)) { @@ -740,37 +860,55 @@ class Formatter { ((out_ << sep, FormatArg(args)), ...); } + // FormatArg variants handling printing instruction arguments. Several things + // provide equivalent behavior with `FormatName`, so we provide that as the + // default. + template + auto FormatArg(IdT id) -> void { + FormatName(id); + } + auto FormatArg(BoolValue v) -> void { out_ << v; } auto FormatArg(BuiltinInstKind kind) -> void { out_ << kind.label(); } - auto FormatArg(BindNameId id) -> void { - const auto& info = sem_ir_.bind_names().Get(id); + auto FormatArg(EntityNameId id) -> void { + const auto& info = sem_ir_.entity_names().Get(id); FormatName(info.name_id); if (info.bind_index.is_valid()) { out_ << " " << info.bind_index.index; } } - auto FormatArg(FunctionId id) -> void { FormatFunctionName(id); } - - auto FormatArg(ClassId id) -> void { FormatClassName(id); } - - auto FormatArg(InterfaceId id) -> void { FormatInterfaceName(id); } - auto FormatArg(IntKind k) -> void { k.Print(out_); } auto FormatArg(FloatKind k) -> void { k.Print(out_); } - auto FormatArg(ImplId id) -> void { FormatImplName(id); } - - auto FormatArg(ImportIRId id) -> void { out_ << id; } + auto FormatArg(ImportIRId id) -> void { + if (!id.is_valid()) { + out_ << id; + return; + } + const auto& import_ir = *sem_ir_.import_irs().Get(id).sem_ir; + if (import_ir.package_id().is_valid()) { + out_ << import_ir.identifiers().Get(import_ir.package_id()); + } else { + out_ << "Main"; + } + out_ << "//"; + if (import_ir.library_id().is_valid()) { + out_ << import_ir.string_literal_values().Get(import_ir.library_id()); + } else { + out_ << "default"; + } + } auto FormatArg(ImportIRInstId id) -> void { // Don't format the inst_id because it refers to a different IR. // TODO: Consider a better way to format the InstID from other IRs. auto import_ir_inst = sem_ir_.import_ir_insts().Get(id); - out_ << import_ir_inst.ir_id << ", " << import_ir_inst.inst_id; + FormatArg(import_ir_inst.ir_id); + out_ << ", " << import_ir_inst.inst_id; } auto FormatArg(IntId id) -> void { @@ -799,8 +937,6 @@ class Formatter { CloseBrace(); } - auto FormatArg(InstId id) -> void { FormatInstName(id); } - auto FormatArg(InstBlockId id) -> void { if (!id.is_valid()) { out_ << "invalid"; @@ -816,11 +952,6 @@ class Formatter { out_ << ')'; } - auto FormatArg(GenericInstanceId id) -> void { - const auto& instance = sem_ir_.generic_instances().Get(id); - FormatArg(instance.args_id); - } - auto FormatArg(RealId id) -> void { // TODO: Format with a `.` when the exponent is near zero. const auto& real = sem_ir_.reals().Get(id); @@ -835,8 +966,6 @@ class Formatter { out_ << '"'; } - auto FormatArg(NameId id) -> void { FormatName(id); } - auto FormatArg(TypeId id) -> void { FormatType(id); } auto FormatArg(TypeBlockId id) -> void { @@ -854,32 +983,32 @@ class Formatter { FormatArg(dest_id); } - auto FormatName(NameId id) -> void { - out_ << sem_ir_.names().GetFormatted(id); - } - - auto FormatInstName(InstId id) -> void { - out_ << inst_namer_.GetNameFor(scope_, id); + // `FormatName` is used when we need the name from an id. Most id types use + // equivalent name formatting from InstNamer, although there are a few special + // formats below. + template + auto FormatName(IdT id) -> void { + out_ << inst_namer_->GetNameFor(id); } - auto FormatLabel(InstBlockId id) -> void { - out_ << inst_namer_.GetLabelFor(scope_, id); + auto FormatName(NameId id) -> void { + out_ << sem_ir_.names().GetFormatted(id); } - auto FormatFunctionName(FunctionId id) -> void { - out_ << inst_namer_.GetNameFor(id); + auto FormatName(InstId id) -> void { + out_ << inst_namer_->GetNameFor(scope_, id); } - auto FormatClassName(ClassId id) -> void { - out_ << inst_namer_.GetNameFor(id); + auto FormatName(SpecificId id) -> void { + const auto& specific = sem_ir_.specifics().Get(id); + FormatName(specific.generic_id); + FormatArg(specific.args_id); } - auto FormatInterfaceName(InterfaceId id) -> void { - out_ << inst_namer_.GetNameFor(id); + auto FormatLabel(InstBlockId id) -> void { + out_ << inst_namer_->GetLabelFor(scope_, id); } - auto FormatImplName(ImplId id) -> void { out_ << inst_namer_.GetNameFor(id); } - auto FormatConstant(ConstantId id) -> void { if (!id.is_valid()) { out_ << ""; @@ -892,21 +1021,19 @@ class Formatter { const auto& symbolic_constant = sem_ir_.constant_values().GetSymbolicConstant(id); if (symbolic_constant.generic_id.is_valid()) { - CARBON_CHECK(symbolic_constant.index.region() == - GenericInstIndex::Region::Declaration) - << "TODO: implement formatting of definition constants"; const auto& generic = sem_ir_.generics().Get(symbolic_constant.generic_id); - FormatInstName(sem_ir_.inst_blocks().Get( - generic.decl_block_id)[symbolic_constant.index.index()]); + FormatName(sem_ir_.inst_blocks().Get(generic.GetEvalBlock( + symbolic_constant.index + .region()))[symbolic_constant.index.index()]); out_ << " ("; - FormatInstName(sem_ir_.constant_values().GetInstId(id)); + FormatName(sem_ir_.constant_values().GetInstId(id)); out_ << ")"; return; } } - FormatInstName(sem_ir_.constant_values().GetInstId(id)); + FormatName(sem_ir_.constant_values().GetInstId(id)); } auto FormatType(TypeId id) -> void { @@ -920,10 +1047,11 @@ class Formatter { } } - private: const File& sem_ir_; + InstNamer* const inst_namer_; + + // The output stream. Set while formatting instructions. llvm::raw_ostream& out_; - InstNamer inst_namer_; // The current scope that we are formatting within. References to names in // this scope will not have a `@scope.` prefix added. @@ -935,7 +1063,7 @@ class Formatter { bool in_terminator_sequence_ = false; // The indent depth to use for new instructions. - int indent_ = 0; + int indent_; // Whether we are currently formatting immediately after an open brace. If so, // a newline will be inserted before the next line indent. @@ -952,10 +1080,28 @@ class Formatter { bool pending_constant_value_is_self_ = false; }; -auto FormatFile(const Lex::TokenizedBuffer& tokenized_buffer, - const Parse::Tree& parse_tree, const File& sem_ir, - llvm::raw_ostream& out) -> void { - Formatter(tokenized_buffer, parse_tree, sem_ir, out).Format(); +Formatter::Formatter(const Lex::TokenizedBuffer& tokenized_buffer, + const Parse::Tree& parse_tree, const File& sem_ir) + : sem_ir_(sem_ir), inst_namer_(tokenized_buffer, parse_tree, sem_ir) {} + +Formatter::~Formatter() = default; + +auto Formatter::Print(llvm::raw_ostream& out) -> void { + FormatterImpl formatter(sem_ir_, &inst_namer_, out, /*indent=*/0); + formatter.Format(); +} + +auto Formatter::PrintPartialTrailingCodeBlock( + llvm::ArrayRef block, int indent, llvm::raw_ostream& out) + -> void { + FormatterImpl formatter(sem_ir_, &inst_namer_, out, indent); + formatter.FormatPartialTrailingCodeBlock(block); +} + +auto Formatter::PrintInst(SemIR::InstId inst_id, int indent, + llvm::raw_ostream& out) -> void { + FormatterImpl formatter(sem_ir_, &inst_namer_, out, indent); + formatter.FormatInst(inst_id); } } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/formatter.h b/toolchain/sem_ir/formatter.h index c7d744afd0e97..7a2ff326159b9 100644 --- a/toolchain/sem_ir/formatter.h +++ b/toolchain/sem_ir/formatter.h @@ -9,12 +9,33 @@ #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/tree.h" #include "toolchain/sem_ir/file.h" +#include "toolchain/sem_ir/inst_namer.h" namespace Carbon::SemIR { -auto FormatFile(const Lex::TokenizedBuffer& tokenized_buffer, - const Parse::Tree& parse_tree, const File& sem_ir, - llvm::raw_ostream& out) -> void; +// Formatter for printing textual Semantics IR. +class Formatter { + public: + explicit Formatter(const Lex::TokenizedBuffer& tokenized_buffer, + const Parse::Tree& parse_tree, const File& sem_ir); + ~Formatter(); + + // Prints the full IR. + auto Print(llvm::raw_ostream& out) -> void; + // Prints a single code block. Only prints the last several instructions of + // large blocks. + auto PrintPartialTrailingCodeBlock(llvm::ArrayRef block, + int indent, llvm::raw_ostream& out) + -> void; + // Prints a single instruction. + auto PrintInst(SemIR::InstId inst_id, int indent, llvm::raw_ostream& out) + -> void; + + private: + const File& sem_ir_; + // Caches naming between Print calls. + InstNamer inst_namer_; +}; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/function.cpp b/toolchain/sem_ir/function.cpp index 3d921b9ba8eff..2b667b9ba35de 100644 --- a/toolchain/sem_ir/function.cpp +++ b/toolchain/sem_ir/function.cpp @@ -5,11 +5,14 @@ #include "toolchain/sem_ir/function.h" #include "toolchain/sem_ir/file.h" +#include "toolchain/sem_ir/generic.h" +#include "toolchain/sem_ir/ids.h" namespace Carbon::SemIR { auto GetCalleeFunction(const File& sem_ir, InstId callee_id) -> CalleeFunction { CalleeFunction result = {.function_id = FunctionId::Invalid, + .specific_id = SpecificId::Invalid, .self_id = InstId::Invalid, .is_error = false}; @@ -35,14 +38,34 @@ auto GetCalleeFunction(const File& sem_ir, InstId callee_id) -> CalleeFunction { } result.function_id = fn_type->function_id; + result.specific_id = fn_type->specific_id; return result; } -auto Function::declared_return_type(const File& file) const -> TypeId { +auto Function::GetParamFromParamRefId(const File& sem_ir, InstId param_ref_id) + -> std::pair { + auto ref = sem_ir.insts().Get(param_ref_id); + + if (auto addr_pattern = ref.TryAs()) { + param_ref_id = addr_pattern->inner_id; + ref = sem_ir.insts().Get(param_ref_id); + } + + if (auto bind_name = ref.TryAs()) { + param_ref_id = bind_name->value_id; + ref = sem_ir.insts().Get(param_ref_id); + } + + return {param_ref_id, ref.As()}; +} + +auto Function::GetDeclaredReturnType(const File& file, + SpecificId specific_id) const -> TypeId { if (!return_storage_id.is_valid()) { return TypeId::Invalid; } - return file.insts().Get(return_storage_id).type_id(); + return GetTypeInSpecific(file, specific_id, + file.insts().Get(return_storage_id).type_id()); } } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/function.h b/toolchain/sem_ir/function.h index 5e45ee710cd4e..cb8dfc6216727 100644 --- a/toolchain/sem_ir/function.h +++ b/toolchain/sem_ir/function.h @@ -6,90 +6,17 @@ #define CARBON_TOOLCHAIN_SEM_IR_FUNCTION_H_ #include "toolchain/sem_ir/builtin_function_kind.h" +#include "toolchain/sem_ir/entity_with_params_base.h" #include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/typed_insts.h" namespace Carbon::SemIR { -// A function. -struct Function : public Printable { - // A value that describes whether the function uses a return slot. - enum class ReturnSlot : int8_t { - // Not yet known: the function has not been called or defined. - NotComputed, - // The function is known to not use a return slot. - Absent, - // The function has a return slot, and a call to the function is expected to - // have an additional final argument corresponding to the return slot. - Present, - // Computing whether the function should have a return slot failed, for - // example because the return type was incomplete. - Error - }; - - auto Print(llvm::raw_ostream& out) const -> void { - out << "{name: " << name_id << ", parent_scope: " << parent_scope_id - << ", param_refs: " << param_refs_id; - if (return_storage_id.is_valid()) { - out << ", return_storage: " << return_storage_id; - out << ", return_slot: "; - switch (return_slot) { - case ReturnSlot::NotComputed: - out << "unknown"; - break; - case ReturnSlot::Absent: - out << "absent"; - break; - case ReturnSlot::Present: - out << "present"; - break; - case ReturnSlot::Error: - out << "error"; - break; - } - } - if (!body_block_ids.empty()) { - out << llvm::formatv( - ", body: [{0}]", - llvm::make_range(body_block_ids.begin(), body_block_ids.end())); - } - out << "}"; - } - - // Given a parameter reference instruction from `param_refs_id` or - // `implicit_param_refs_id`, returns the corresponding `Param` instruction - // and its ID. - static auto GetParamFromParamRefId(const File& sem_ir, InstId param_ref_id) - -> std::pair; - - // Gets the declared return type of the function. Returns `Invalid` if no - // return type was specified, - auto declared_return_type(const File& file) const -> TypeId; - - // Returns whether the function has a return slot. Can only be called for a - // function that has either been called or defined, otherwise this is not - // known. - auto has_return_slot() const -> bool { - CARBON_CHECK(return_slot != ReturnSlot::NotComputed); - // On error, we assume no return slot is used. - return return_slot == ReturnSlot::Present; - } - +// Function-specific fields. +struct FunctionFields { // The following members always have values, and do not change throughout the // lifetime of the function. - // The function name. - NameId name_id; - // The parent scope. - NameScopeId parent_scope_id; - // The first declaration of the function. This is a FunctionDecl. - InstId decl_id; - // If this is a generic function, information about the generic. - GenericId generic_id; - // A block containing a single reference instruction per implicit parameter. - InstBlockId implicit_param_refs_id; - // A block containing a single reference instruction per parameter. - InstBlockId param_refs_id; // The storage for the return value, which is a reference expression whose // type is the return type of the function. This may or may not be used by the // function, depending on whether the return type needs a return slot, but is @@ -101,20 +28,11 @@ struct Function : public Printable { // The following member is set on the first call to the function, or at the // point where the function is defined. - // Whether the function uses a return slot. - ReturnSlot return_slot; - // The following members are set at the end of a builtin function definition. // If this is a builtin function, the corresponding builtin kind. BuiltinFunctionKind builtin_function_kind = BuiltinFunctionKind::None; - // The following members are set at the `{` of the function definition. - - // The definition, if the function has been defined or is currently being - // defined. This is a FunctionDecl. - InstId definition_id = InstId::Invalid; - // The following members are accumulated throughout the function definition. // A list of the statically reachable code blocks in the body of the @@ -123,11 +41,46 @@ struct Function : public Printable { llvm::SmallVector body_block_ids = {}; }; +// A function. See EntityWithParamsBase regarding the inheritance here. +struct Function : public EntityWithParamsBase, + public FunctionFields, + public Printable { + auto Print(llvm::raw_ostream& out) const -> void { + out << "{"; + PrintBaseFields(out); + if (return_storage_id.is_valid()) { + out << ", return_storage: " << return_storage_id; + } + if (!body_block_ids.empty()) { + out << llvm::formatv( + ", body: [{0}]", + llvm::make_range(body_block_ids.begin(), body_block_ids.end())); + } + out << "}"; + } + + // Given a parameter reference instruction from `param_refs_id` or + // `implicit_param_refs_id`, returns the corresponding `Param` instruction + // and its ID. + static auto GetParamFromParamRefId(const File& sem_ir, InstId param_ref_id) + -> std::pair; + + // Gets the declared return type for a specific version of this function, or + // the canonical return type for the original declaration no specific is + // specified. Returns `Invalid` if no return type was specified, in which + // case the effective return type is an empty tuple. + auto GetDeclaredReturnType(const File& file, + SpecificId specific_id = SpecificId::Invalid) const + -> TypeId; +}; + class File; struct CalleeFunction { // The function. Invalid if not a function. SemIR::FunctionId function_id; + // The specific that contains the function. + SemIR::SpecificId specific_id; // The bound `self` parameter. Invalid if not a method. SemIR::InstId self_id; // True if an error instruction was found. diff --git a/toolchain/sem_ir/generic.cpp b/toolchain/sem_ir/generic.cpp index 9518617611100..5cc71765a7939 100644 --- a/toolchain/sem_ir/generic.cpp +++ b/toolchain/sem_ir/generic.cpp @@ -8,10 +8,9 @@ namespace Carbon::SemIR { -class GenericInstanceStore::KeyContext - : public TranslatingKeyContext { +class SpecificStore::KeyContext : public TranslatingKeyContext { public: - // A lookup key for a generic instance. + // A lookup key for a specific. struct Key { GenericId generic_id; InstBlockId args_id; @@ -19,33 +18,40 @@ class GenericInstanceStore::KeyContext friend auto operator==(const Key&, const Key&) -> bool = default; }; - explicit KeyContext(llvm::ArrayRef instances) - : instances_(instances) {} + explicit KeyContext(llvm::ArrayRef specifics) + : specifics_(specifics) {} - auto TranslateKey(GenericInstanceId id) const -> Key { - const auto& instance = instances_[id.index]; - return {.generic_id = instance.generic_id, .args_id = instance.args_id}; + auto TranslateKey(SpecificId id) const -> Key { + const auto& specific = specifics_[id.index]; + return {.generic_id = specific.generic_id, .args_id = specific.args_id}; } private: - llvm::ArrayRef instances_; + llvm::ArrayRef specifics_; }; -auto GenericInstanceStore::GetOrAdd(GenericId generic_id, InstBlockId args_id) - -> GenericInstanceId { +auto SpecificStore::GetOrAdd(GenericId generic_id, InstBlockId args_id) + -> SpecificId { + CARBON_CHECK(generic_id.is_valid()); return lookup_table_ .Insert( KeyContext::Key{.generic_id = generic_id, .args_id = args_id}, [&] { - return generic_instances_.Add( + return specifics_.Add( {.generic_id = generic_id, .args_id = args_id}); }, - KeyContext(generic_instances_.array_ref())) + KeyContext(specifics_.array_ref())) .key(); } -auto GetConstantInInstance(const File& sem_ir, - GenericInstanceId /*instance_id*/, +auto SpecificStore::CollectMemUsage(MemUsage& mem_usage, + llvm::StringRef label) const -> void { + mem_usage.Collect(MemUsage::ConcatLabel(label, "specifics_"), specifics_); + mem_usage.Add(MemUsage::ConcatLabel(label, "lookup_table_"), lookup_table_, + KeyContext(specifics_.array_ref())); +} + +auto GetConstantInSpecific(const File& sem_ir, SpecificId specific_id, ConstantId const_id) -> ConstantId { if (!const_id.is_symbolic()) { // Type does not depend on a generic parameter. @@ -54,20 +60,43 @@ auto GetConstantInInstance(const File& sem_ir, const auto& symbolic = sem_ir.constant_values().GetSymbolicConstant(const_id); if (!symbolic.generic_id.is_valid()) { - // Constant is an abstract symbolic constant, not an instance-specific one. + // Constant is an abstract symbolic constant, not associated with some + // particular generic. return const_id; } - // TODO: Look up the value in the generic instance. For now, return the - // canonical constant value. - return sem_ir.constant_values().Get(symbolic.inst_id); + if (!specific_id.is_valid()) { + // TODO: We have a generic constant but no specific. Investigate whether we + // can CHECK-fail here. For now, produce the canonical value of the + // constant. + return sem_ir.constant_values().Get(symbolic.inst_id); + } + + const auto& specific = sem_ir.specifics().Get(specific_id); + if (specific.generic_id != symbolic.generic_id) { + // TODO: Given an specific for the wrong generic. If the symbolic constant + // is from an enclosing generic, take the value from the corresponding + // specific. Otherwise, CHECK-fail. + return sem_ir.constant_values().Get(symbolic.inst_id); + } + + auto value_block_id = specific.GetValueBlock(symbolic.index.region()); + CARBON_CHECK(value_block_id.is_valid()) + << "Queried region of " << specific_id << " before it was resolved."; + return sem_ir.constant_values().Get( + sem_ir.inst_blocks().Get(value_block_id)[symbolic.index.index()]); } -auto GetConstantValueInInstance(const File& sem_ir, - GenericInstanceId instance_id, InstId inst_id) - -> ConstantId { - return GetConstantInInstance(sem_ir, instance_id, +auto GetConstantValueInSpecific(const File& sem_ir, SpecificId specific_id, + InstId inst_id) -> ConstantId { + return GetConstantInSpecific(sem_ir, specific_id, sem_ir.constant_values().Get(inst_id)); } +auto GetTypeInSpecific(const File& sem_ir, SpecificId specific_id, + TypeId type_id) -> TypeId { + return TypeId::ForTypeConstant(GetConstantInSpecific( + sem_ir, specific_id, sem_ir.types().GetConstantId(type_id))); +} + } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/generic.h b/toolchain/sem_ir/generic.h index 437a84eb61b3c..6f37d7935b228 100644 --- a/toolchain/sem_ir/generic.h +++ b/toolchain/sem_ir/generic.h @@ -19,6 +19,15 @@ struct Generic : public Printable { out << "{decl: " << decl_id << ", bindings: " << bindings_id << "}"; } + // Returns the eval block for the specified region of the generic. This is a + // block of instructions that should be evaluated to compute the values and + // instructions needed by that region of the generic. + auto GetEvalBlock(GenericInstIndex::Region region) const -> InstBlockId { + return region == GenericInstIndex::Region::Declaration + ? decl_block_id + : definition_block_id; + } + // The following members always have values, and do not change throughout the // lifetime of the generic. @@ -26,99 +35,125 @@ struct Generic : public Printable { InstId decl_id; // A block containing the IDs of compile time bindings in this generic scope. // The index in this block will match the `bind_index` in the name binding - // instruction's `BindNameInfo`. + // instruction's `EntityName`. InstBlockId bindings_id; - // The self instance of this generic, which is an instance where every generic - // parameter's argument is that same parameter. For example, the self instance + // The self specific of this generic, which is a specific where every generic + // parameter's argument is that same parameter. For example, the self specific // of `Vector(T:! type)` is `Vector(T)`. - GenericInstanceId self_instance_id; + SpecificId self_specific_id; // The following members are set at the end of the corresponding region of the // generic. - // A block of instructions that should be evaluated to compute the values and - // instructions needed by the declaration of the generic. + // The eval block for the declaration region of the generic. InstBlockId decl_block_id = InstBlockId::Invalid; + // The eval block for the definition region of the generic. + InstBlockId definition_block_id = InstBlockId::Invalid; }; // Provides storage for generics. class GenericStore : public ValueStore { public: - // Get the self-instance for a generic, or an invalid instance for an invalid + // Get the self specific for a generic, or an invalid specific for an invalid // generic ID. - auto GetSelfInstance(GenericId id) -> GenericInstanceId { - return id.is_valid() ? Get(id).self_instance_id - : GenericInstanceId::Invalid; + auto GetSelfSpecific(GenericId id) -> SpecificId { + return id.is_valid() ? Get(id).self_specific_id : SpecificId::Invalid; } }; -// An instance of a generic entity, such as an instance of a generic function. -// For each construct that depends on a compile-time parameter in the generic -// entity, this contains the corresponding non-generic value. This includes +// A specific, which is the combination of a generic and specified generic +// arguments. For each construct that depends on a compile-time parameter in the +// generic entity, this contains the corresponding specific value. This includes // values for the compile-time parameters themselves. -struct GenericInstance : Printable { +struct Specific : Printable { auto Print(llvm::raw_ostream& out) const -> void { out << "{generic: " << generic_id << ", args: " << args_id << "}"; } - // The generic that this is an instance of. + // Returns the value block for this region of the specific. This is a block + // containing values and instructions produced by evaluating the corresponding + // eval block of the generic within the context of this specific. These are + // the constant values and types and the instantiated template-dependent + // instructions that are used in this region of the specific. + auto GetValueBlock(GenericInstIndex::Region region) const -> InstBlockId { + return region == GenericInstIndex::Region::Declaration + ? decl_block_id + : definition_block_id; + } + + // The generic that this is a specific version of. GenericId generic_id; // Argument values, corresponding to the bindings in `Generic::bindings_id`. InstBlockId args_id; - // The following members are set when the corresponding region of the generic - // instance is resolved. + // The following members are set when the corresponding region of the specific + // is resolved. - // The values and instructions produced by evaluating the decl block of the - // generic. These are the constant values and types and the instantiated - // template-dependent instructions needed by the declaration of this instance. + // The value block for the declaration region of the specific. InstBlockId decl_block_id = InstBlockId::Invalid; + // The value block for the definition region of the specific. + InstBlockId definition_block_id = InstBlockId::Invalid; }; -// Provides storage for deduplicated instances of generics. -class GenericInstanceStore : public Yaml::Printable { +// Provides storage for deduplicated specifics, which represent generics plus +// their associated generic argument list. +class SpecificStore : public Yaml::Printable { public: - // Adds a new generic instance, or gets the existing generic instance for a - // specified generic and argument list. Returns the ID of the generic - // instance. The argument IDs must be for instructions in the constant block, - // and must be a canonical instruction block ID. - auto GetOrAdd(GenericId generic_id, InstBlockId args_id) -> GenericInstanceId; - - // Gets the specified generic instance. - auto Get(GenericInstanceId instance_id) const -> const GenericInstance& { - return generic_instances_.Get(instance_id); + // Adds a new specific, or gets the existing specific for a specified generic + // and argument list. Returns the ID of the specific. The argument IDs must be + // for instructions in the constant block, and must be a canonical instruction + // block ID. + auto GetOrAdd(GenericId generic_id, InstBlockId args_id) -> SpecificId; + + // Gets the specific with the given ID. + auto Get(SpecificId specific_id) const -> const Specific& { + return specifics_.Get(specific_id); } - // Gets the specified generic instance. - auto Get(GenericInstanceId instance_id) -> GenericInstance& { - return generic_instances_.Get(instance_id); + // Gets the specific with the given ID. + auto Get(SpecificId specific_id) -> Specific& { + return specifics_.Get(specific_id); } // These are to support printable structures, and are not guaranteed. auto OutputYaml() const -> Yaml::OutputMapping { - return generic_instances_.OutputYaml(); + return specifics_.OutputYaml(); + } + + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void; + + auto array_ref() const -> llvm::ArrayRef { + return specifics_.array_ref(); } + auto size() const -> size_t { return specifics_.size(); } private: // Context for hashing keys. class KeyContext; - ValueStore generic_instances_; - Carbon::Set lookup_table_; + ValueStore specifics_; + Carbon::Set lookup_table_; }; -// Gets the substituted value of a constant within a specified instance of a -// generic. Note that this does not perform substitution, and will return +// Gets the substituted value of a potentially generic constant within a +// specific. Note that this does not perform substitution, and will return // `Invalid` if the substituted constant value is not yet known. -auto GetConstantInInstance(const File& sem_ir, GenericInstanceId instance_id, +auto GetConstantInSpecific(const File& sem_ir, SpecificId specific_id, ConstantId const_id) -> ConstantId; -// Gets the substituted constant value of an instruction within a specified -// instance of a generic. Note that this does not perform substitution, and will +// Gets the substituted constant value of a potentially generic instruction +// within a specific. Note that this does not perform substitution, and will // return `Invalid` if the substituted constant value is not yet known. -auto GetConstantValueInInstance(const File& sem_ir, - GenericInstanceId instance_id, InstId inst_id) - -> ConstantId; +auto GetConstantValueInSpecific(const File& sem_ir, SpecificId specific_id, + InstId inst_id) -> ConstantId; + +// Gets the substituted value of a potentially generic type within a specific. +// Note that this does not perform substitution, and will return `Invalid` if +// the substituted type is not yet known. +auto GetTypeInSpecific(const File& sem_ir, SpecificId specific_id, + TypeId type_id) -> TypeId; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/id_kind.h b/toolchain/sem_ir/id_kind.h index f1aac1bf473b2..ba411440563b1 100644 --- a/toolchain/sem_ir/id_kind.h +++ b/toolchain/sem_ir/id_kind.h @@ -120,10 +120,10 @@ using IdKind = TypeEnum< // From base/value_store.h. IntId, RealId, FloatId, StringLiteralValueId, // From sem_ir/id.h. - InstId, ConstantId, BindNameId, CompileTimeBindIndex, FunctionId, ClassId, - InterfaceId, ImplId, GenericId, GenericInstanceId, ImportIRId, - ImportIRInstId, LocId, BoolValue, IntKind, NameId, NameScopeId, InstBlockId, - TypeId, TypeBlockId, ElementIndex, FloatKind>; + InstId, ConstantId, EntityNameId, CompileTimeBindIndex, FunctionId, ClassId, + InterfaceId, ImplId, GenericId, SpecificId, ImportIRId, ImportIRInstId, + LocId, BoolValue, IntKind, NameId, NameScopeId, InstBlockId, TypeId, + TypeBlockId, ElementIndex, FloatKind>; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index e69458d6504ff..4c40cf49218e1 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -18,11 +18,11 @@ namespace Carbon::SemIR { // Forward declare indexed types, for integration with ValueStore. class File; class Inst; -struct BindNameInfo; +struct EntityName; struct Class; struct Function; struct Generic; -struct GenericInstance; +struct Specific; struct ImportIR; struct ImportIRInst; struct Interface; @@ -141,13 +141,23 @@ struct ConstantId : public IdBase, public Printable { return index >= 0; } - auto Print(llvm::raw_ostream& out) const -> void { + // Prints this ID to the given output stream. `disambiguate` indicates whether + // template constants should be wrapped with "templateConstant(...)" so that + // they aren't printed the same as an InstId. This can be set to false if + // there is no risk of ambiguity. + auto Print(llvm::raw_ostream& out, bool disambiguate = true) const -> void { if (!is_valid()) { IdBase::Print(out); } else if (is_template()) { - out << "template " << template_inst_id(); + if (disambiguate) { + out << "templateConstant("; + } + out << template_inst_id(); + if (disambiguate) { + out << ")"; + } } else if (is_symbolic()) { - out << "symbolic " << symbolic_index(); + out << "symbolicConstant" << symbolic_index(); } else { out << "runtime"; } @@ -184,21 +194,21 @@ constexpr ConstantId ConstantId::Error = ConstantId::ForTemplateConstant(InstId::BuiltinError); constexpr ConstantId ConstantId::Invalid = ConstantId(InvalidIndex); -// The ID of a bind name. -struct BindNameId : public IdBase, public Printable { - using ValueType = BindNameInfo; +// The ID of a EntityName. +struct EntityNameId : public IdBase, public Printable { + using ValueType = EntityName; // An explicitly invalid ID. - static const BindNameId Invalid; + static const EntityNameId Invalid; using IdBase::IdBase; auto Print(llvm::raw_ostream& out) const -> void { - out << "bind_name"; + out << "entity_name"; IdBase::Print(out); } }; -constexpr BindNameId BindNameId::Invalid = BindNameId(InvalidIndex); +constexpr EntityNameId EntityNameId::Invalid = EntityNameId(InvalidIndex); // The index of a compile-time binding. This is the de Bruijn level for the // binding -- that is, this is the number of other compile time bindings whose @@ -309,27 +319,28 @@ struct GenericId : public IdBase, public Printable { constexpr GenericId GenericId::Invalid = GenericId(InvalidIndex); -// The ID of an instance of a generic. -struct GenericInstanceId : public IdBase, public Printable { - using ValueType = GenericInstance; +// The ID of a specific, which is the result of specifying the generic arguments +// for a generic. +struct SpecificId : public IdBase, public Printable { + using ValueType = Specific; // An explicitly invalid ID. This is typically used to represent a non-generic - // instance. - static const GenericInstanceId Invalid; + // entity. + static const SpecificId Invalid; using IdBase::IdBase; auto Print(llvm::raw_ostream& out) const -> void { - out << "genericInstance"; + out << "specific"; IdBase::Print(out); } }; -constexpr GenericInstanceId GenericInstanceId::Invalid = - GenericInstanceId(InvalidIndex); +constexpr SpecificId SpecificId::Invalid = SpecificId(InvalidIndex); // The index of an instruction that depends on generic parameters within a -// generic, and the value of that instruction within the instances of that -// generic. This is a pair of a region and an index, stored in 32 bits. +// region of a generic. A corresponding specific version of the instruction can +// be found in each specific corresponding to that generic. This is a pair of a +// region and an index, stored in 32 bits. struct GenericInstIndex : public IndexBase, public Printable { // Where the value is first used within the generic. enum Region : uint8_t { @@ -615,7 +626,6 @@ constexpr InstBlockId InstBlockId::Unreachable = InstBlockId(InvalidIndex - 1); // The ID of a type. struct TypeId : public IdBase, public Printable { - using ValueType = TypeInfo; // StringifyType() is used for diagnostics. using DiagnosticType = DiagnosticTypeInfo; @@ -629,6 +639,17 @@ struct TypeId : public IdBase, public Printable { static const TypeId Invalid; using IdBase::IdBase; + + // Returns the ID of the type corresponding to the constant `const_id`, which + // must be of type `type`. As an exception, the type `Error` is of type + // `Error`. + static constexpr auto ForTypeConstant(ConstantId const_id) -> TypeId { + return TypeId(const_id.index); + } + + // Returns the constant ID that defines the type. + auto AsConstantId() const -> ConstantId { return ConstantId(index); } + auto Print(llvm::raw_ostream& out) const -> void { out << "type"; if (*this == TypeType) { @@ -636,13 +657,16 @@ struct TypeId : public IdBase, public Printable { } else if (*this == Error) { out << "Error"; } else { - IdBase::Print(out); + out << "("; + AsConstantId().Print(out, /*disambiguate=*/false); + out << ")"; } } }; -constexpr TypeId TypeId::TypeType = TypeId(InvalidIndex - 2); -constexpr TypeId TypeId::Error = TypeId(InvalidIndex - 1); +constexpr TypeId TypeId::TypeType = TypeId::ForTypeConstant( + ConstantId::ForTemplateConstant(InstId::BuiltinTypeType)); +constexpr TypeId TypeId::Error = TypeId::ForTypeConstant(ConstantId::Error); constexpr TypeId TypeId::Invalid = TypeId(InvalidIndex); // The ID of a type block. diff --git a/toolchain/sem_ir/impl.h b/toolchain/sem_ir/impl.h index 89ff4e183f503..de9dc2bb6849a 100644 --- a/toolchain/sem_ir/impl.h +++ b/toolchain/sem_ir/impl.h @@ -74,6 +74,13 @@ class ImplStore { return values_.OutputYaml(); } + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Collect(MemUsage::ConcatLabel(label, "values_"), values_); + mem_usage.Add(MemUsage::ConcatLabel(label, "lookup_"), lookup_); + } + auto array_ref() const -> llvm::ArrayRef { return values_.array_ref(); } auto size() const -> size_t { return values_.size(); } diff --git a/toolchain/sem_ir/inst.h b/toolchain/sem_ir/inst.h index 1d3aed8891f0b..63a214f656ad3 100644 --- a/toolchain/sem_ir/inst.h +++ b/toolchain/sem_ir/inst.h @@ -423,6 +423,13 @@ class InstStore { values_.Reserve(size); } + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "loc_ids_"), loc_ids_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "values_"), values_); + } + auto array_ref() const -> llvm::ArrayRef { return values_.array_ref(); } auto size() const -> int { return values_.size(); } diff --git a/toolchain/sem_ir/inst_namer.cpp b/toolchain/sem_ir/inst_namer.cpp index 4e6620fee6534..3dffeb96814d0 100644 --- a/toolchain/sem_ir/inst_namer.cpp +++ b/toolchain/sem_ir/inst_namer.cpp @@ -22,9 +22,10 @@ InstNamer::InstNamer(const Lex::TokenizedBuffer& tokenized_buffer, : tokenized_buffer_(tokenized_buffer), parse_tree_(parse_tree), sem_ir_(sem_ir) { - insts.resize(sem_ir.insts().size()); - labels.resize(sem_ir.inst_blocks().size()); - scopes.resize(static_cast(GetScopeFor(NumberOfScopesTag()))); + insts_.resize(sem_ir.insts().size()); + labels_.resize(sem_ir.inst_blocks().size()); + scopes_.resize(static_cast(GetScopeFor(NumberOfScopesTag()))); + generic_scopes_.resize(sem_ir.generics().size(), ScopeId::None); // Build the constants scope. CollectNamesInBlock(ScopeId::Constants, sem_ir.constants().array_ref()); @@ -43,12 +44,12 @@ InstNamer::InstNamer(const Lex::TokenizedBuffer& tokenized_buffer, // TODO: Provide a location for the function for use as a // disambiguator. auto fn_loc = Parse::NodeId::Invalid; - GetScopeInfo(fn_scope).name = globals.AllocateName( + GetScopeInfo(fn_scope).name = globals_.AllocateName( *this, fn_loc, sem_ir.names().GetIRBaseName(fn.name_id).str()); CollectNamesInBlock(fn_scope, fn.implicit_param_refs_id); CollectNamesInBlock(fn_scope, fn.param_refs_id); if (fn.return_storage_id.is_valid()) { - insts[fn.return_storage_id.index] = { + insts_[fn.return_storage_id.index] = { fn_scope, GetScopeInfo(fn_scope).insts.AllocateName( *this, sem_ir.insts().GetLocId(fn.return_storage_id), "return")}; @@ -62,6 +63,7 @@ InstNamer::InstNamer(const Lex::TokenizedBuffer& tokenized_buffer, for (auto block_id : fn.body_block_ids) { AddBlockLabel(fn_scope, block_id); } + CollectNamesInGeneric(fn_scope, fn.generic_id); } // Build each class scope. @@ -70,11 +72,12 @@ InstNamer::InstNamer(const Lex::TokenizedBuffer& tokenized_buffer, auto class_scope = GetScopeFor(class_id); // TODO: Provide a location for the class for use as a disambiguator. auto class_loc = Parse::NodeId::Invalid; - GetScopeInfo(class_scope).name = globals.AllocateName( + GetScopeInfo(class_scope).name = globals_.AllocateName( *this, class_loc, sem_ir.names().GetIRBaseName(class_info.name_id).str()); AddBlockLabel(class_scope, class_info.body_block_id, "class", class_loc); CollectNamesInBlock(class_scope, class_info.body_block_id); + CollectNamesInGeneric(class_scope, class_info.generic_id); } // Build each interface scope. @@ -84,12 +87,13 @@ InstNamer::InstNamer(const Lex::TokenizedBuffer& tokenized_buffer, auto interface_scope = GetScopeFor(interface_id); // TODO: Provide a location for the interface for use as a disambiguator. auto interface_loc = Parse::NodeId::Invalid; - GetScopeInfo(interface_scope).name = globals.AllocateName( + GetScopeInfo(interface_scope).name = globals_.AllocateName( *this, interface_loc, sem_ir.names().GetIRBaseName(interface_info.name_id).str()); AddBlockLabel(interface_scope, interface_info.body_block_id, "interface", interface_loc); CollectNamesInBlock(interface_scope, interface_info.body_block_id); + CollectNamesInGeneric(interface_scope, interface_info.generic_id); } // Build each impl scope. @@ -100,9 +104,10 @@ InstNamer::InstNamer(const Lex::TokenizedBuffer& tokenized_buffer, auto impl_loc = Parse::NodeId::Invalid; // TODO: Invent a name based on the self and constraint types. GetScopeInfo(impl_scope).name = - globals.AllocateName(*this, impl_loc, "impl"); + globals_.AllocateName(*this, impl_loc, "impl"); AddBlockLabel(impl_scope, impl_info.body_block_id, "impl", impl_loc); CollectNamesInBlock(impl_scope, impl_info.body_block_id); + // TODO: Collect names from the generic once we support generic impls. } } @@ -129,7 +134,7 @@ auto InstNamer::GetUnscopedNameFor(InstId inst_id) const -> llvm::StringRef { if (!inst_id.is_valid()) { return ""; } - const auto& inst_name = insts[inst_id.index].second; + const auto& inst_name = insts_[inst_id.index].second; return inst_name ? inst_name.str() : ""; } @@ -148,11 +153,19 @@ auto InstNamer::GetNameFor(ScopeId scope_id, InstId inst_id) const return "package"; } - const auto& [inst_scope, inst_name] = insts[inst_id.index]; + const auto& [inst_scope, inst_name] = insts_[inst_id.index]; if (!inst_name) { // This should not happen in valid IR. std::string str; - llvm::raw_string_ostream(str) << ""; + llvm::raw_string_ostream str_stream(str); + str_stream << "." << inst_id; + auto loc_id = sem_ir_.insts().GetLocId(inst_id); + // TODO: Consider handling inst_id cases. + if (loc_id.is_node_id()) { + auto token = parse_tree_.node_token(loc_id.node_id()); + str_stream << ".loc" << tokenized_buffer_.GetLineNumber(token) << "_" + << tokenized_buffer_.GetColumnNumber(token); + } return str; } if (inst_scope == scope_id) { @@ -166,7 +179,7 @@ auto InstNamer::GetUnscopedLabelFor(InstBlockId block_id) const if (!block_id.is_valid()) { return ""; } - const auto& label_name = labels[block_id.index].second; + const auto& label_name = labels_[block_id.index].second; return label_name ? label_name.str() : ""; } @@ -177,7 +190,7 @@ auto InstNamer::GetLabelFor(ScopeId scope_id, InstBlockId block_id) const return "!invalid"; } - const auto& [label_scope, label_name] = labels[block_id.index]; + const auto& [label_scope, label_name] = labels_[block_id.index]; if (!label_name) { // This should not happen in valid IR. std::string str; @@ -263,7 +276,7 @@ auto InstNamer::Namespace::AllocateName(const InstNamer& inst_namer, auto InstNamer::AddBlockLabel(ScopeId scope_id, InstBlockId block_id, std::string name, SemIR::LocId loc_id) -> void { - if (!block_id.is_valid() || labels[block_id.index].second) { + if (!block_id.is_valid() || labels_[block_id.index].second) { return; } @@ -274,7 +287,7 @@ auto InstNamer::AddBlockLabel(ScopeId scope_id, InstBlockId block_id, } } - labels[block_id.index] = { + labels_[block_id.index] = { scope_id, GetScopeInfo(scope_id).labels.AllocateName(*this, loc_id, std::move(name))}; } @@ -368,7 +381,7 @@ auto InstNamer::CollectNamesInBlock(ScopeId scope_id, auto untyped_inst = sem_ir_.insts().Get(inst_id); auto add_inst_name = [&](std::string name) { - insts[inst_id.index] = { + insts_[inst_id.index] = { scope_id, scope.insts.AllocateName( *this, sem_ir_.insts().GetLocId(inst_id), name)}; }; @@ -399,7 +412,8 @@ auto InstNamer::CollectNamesInBlock(ScopeId scope_id, case BindSymbolicName::Kind: case ExportDecl::Kind: { auto inst = untyped_inst.As(); - add_inst_name_id(sem_ir_.bind_names().Get(inst.bind_name_id).name_id); + add_inst_name_id( + sem_ir_.entity_names().Get(inst.entity_name_id).name_id); continue; } case CARBON_KIND(Call inst): { @@ -472,7 +486,7 @@ auto InstNamer::CollectNamesInBlock(ScopeId scope_id, auto const_id = sem_ir_.constant_values().Get(inst_id); if (const_id.is_valid() && const_id.is_template()) { auto const_inst_id = sem_ir_.constant_values().GetInstId(const_id); - if (!insts[const_inst_id.index].second) { + if (!insts_[const_inst_id.index].second) { CollectNamesInBlock(ScopeId::ImportRefs, const_inst_id); } } @@ -544,4 +558,15 @@ auto InstNamer::CollectNamesInBlock(ScopeId scope_id, } } +auto InstNamer::CollectNamesInGeneric(ScopeId scope_id, GenericId generic_id) + -> void { + if (!generic_id.is_valid()) { + return; + } + generic_scopes_[generic_id.index] = scope_id; + const auto& generic = sem_ir_.generics().Get(generic_id); + CollectNamesInBlock(scope_id, generic.decl_block_id); + CollectNamesInBlock(scope_id, generic.definition_block_id); +} + } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/inst_namer.h b/toolchain/sem_ir/inst_namer.h index 428812ade3155..1a4ee50bec428 100644 --- a/toolchain/sem_ir/inst_namer.h +++ b/toolchain/sem_ir/inst_namer.h @@ -9,6 +9,7 @@ #include "toolchain/lex/tokenized_buffer.h" #include "toolchain/parse/tree.h" #include "toolchain/sem_ir/file.h" +#include "toolchain/sem_ir/ids.h" namespace Carbon::SemIR { @@ -59,6 +60,12 @@ class InstNamer { return static_cast(index); } + // Returns the scope ID corresponding to a generic. A generic object shares + // its scope with its generic entity. + auto GetScopeFor(GenericId id) const -> ScopeId { + return generic_scopes_[id.index]; + } + // Returns the IR name for the specified scope. auto GetScopeName(ScopeId scope) const -> std::string; @@ -135,11 +142,11 @@ class InstNamer { }; auto GetScopeInfo(ScopeId scope_id) -> Scope& { - return scopes[static_cast(scope_id)]; + return scopes_[static_cast(scope_id)]; } auto GetScopeInfo(ScopeId scope_id) const -> const Scope& { - return scopes[static_cast(scope_id)]; + return scopes_[static_cast(scope_id)]; } auto AddBlockLabel(ScopeId scope_id, InstBlockId block_id, @@ -156,14 +163,26 @@ class InstNamer { auto CollectNamesInBlock(ScopeId scope_id, llvm::ArrayRef block) -> void; + auto CollectNamesInGeneric(ScopeId scope_id, GenericId generic_id) -> void; + const Lex::TokenizedBuffer& tokenized_buffer_; const Parse::Tree& parse_tree_; const File& sem_ir_; - Namespace globals; - std::vector> insts; - std::vector> labels; - std::vector scopes; + // The namespace for entity names. Names within this namespace are prefixed + // with `@` in formatted SemIR. + Namespace globals_; + // The enclosing scope and name for each instruction, indexed by the InstId's + // index. + std::vector> insts_; + // The enclosing scope and name for each block that might be a branch target, + // indexed by the InstBlockId's index. + std::vector> labels_; + // The scopes corresponding to ScopeId values. + std::vector scopes_; + // The scope IDs corresponding to generics. The vector indexes are the + // GenericId index. + std::vector generic_scopes_; }; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/interface.h b/toolchain/sem_ir/interface.h index 89fbe93a03605..5d967b0b40d96 100644 --- a/toolchain/sem_ir/interface.h +++ b/toolchain/sem_ir/interface.h @@ -5,51 +5,15 @@ #ifndef CARBON_TOOLCHAIN_SEM_IR_INTERFACE_H_ #define CARBON_TOOLCHAIN_SEM_IR_INTERFACE_H_ +#include "toolchain/sem_ir/entity_with_params_base.h" #include "toolchain/sem_ir/ids.h" namespace Carbon::SemIR { -// An interface. -struct Interface : public Printable { - auto Print(llvm::raw_ostream& out) const -> void { - out << "{name: " << name_id << ", parent_scope: " << parent_scope_id << "}"; - } - - // Determines whether this interface has been fully defined. This is false - // until we reach the `}` of the interface definition. - auto is_defined() const -> bool { return associated_entities_id.is_valid(); } - - // Determines whether we're currently defining the interface. This is true - // between the braces of the interface. - auto is_being_defined() const -> bool { - return definition_id.is_valid() && !is_defined(); - } - - // Determines whether this is a generic interface. - auto is_generic() const -> bool { - return implicit_param_refs_id.is_valid() || param_refs_id.is_valid(); - } - - // The following members always have values, and do not change throughout the - // lifetime of the interface. - - // The interface name. - NameId name_id; - // The parent scope. - NameScopeId parent_scope_id; - // If this is a generic function, information about the generic. - GenericId generic_id; - // A block containing a single reference instruction per implicit parameter. - InstBlockId implicit_param_refs_id; - // A block containing a single reference instruction per parameter. - InstBlockId param_refs_id; - // The first declaration of the interface. This is a InterfaceDecl. - InstId decl_id; - +// Interface-specific fields. +struct InterfaceFields { // The following members are set at the `{` of the interface definition. - // The definition of the interface. This is a InterfaceDecl. - InstId definition_id = InstId::Invalid; // The interface scope. NameScopeId scope_id = NameScopeId::Invalid; // The first block of the interface body. @@ -62,6 +26,27 @@ struct Interface : public Printable { InstBlockId associated_entities_id = InstBlockId::Invalid; }; +// An interface. See EntityWithParamsBase regarding the inheritance here. +struct Interface : public EntityWithParamsBase, + public InterfaceFields, + public Printable { + auto Print(llvm::raw_ostream& out) const -> void { + out << "{"; + PrintBaseFields(out); + out << "}"; + } + + // Determines whether this interface has been fully defined. This is false + // until we reach the `}` of the interface definition. + auto is_defined() const -> bool { return associated_entities_id.is_valid(); } + + // Determines whether we're currently defining the interface. This is true + // between the braces of the interface. + auto is_being_defined() const -> bool { + return definition_id.is_valid() && !is_defined(); + } +}; + } // namespace Carbon::SemIR #endif // CARBON_TOOLCHAIN_SEM_IR_INTERFACE_H_ diff --git a/toolchain/sem_ir/name_scope.h b/toolchain/sem_ir/name_scope.h index 6e4ceb581d2f5..4401cd9a01448 100644 --- a/toolchain/sem_ir/name_scope.h +++ b/toolchain/sem_ir/name_scope.h @@ -161,6 +161,12 @@ class NameScopeStore { return values_.OutputYaml(); } + // Collects memory usage of members. + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Collect(label, values_); + } + private: InstStore* insts_; ValueStore values_; diff --git a/toolchain/sem_ir/type.h b/toolchain/sem_ir/type.h index 5d90cbd5fa0c2..183ef6b360978 100644 --- a/toolchain/sem_ir/type.h +++ b/toolchain/sem_ir/type.h @@ -14,23 +14,18 @@ namespace Carbon::SemIR { // Provides a ValueStore wrapper with an API specific to types. -class TypeStore : public ValueStore { +class TypeStore : public Yaml::Printable { public: explicit TypeStore(InstStore* insts, ConstantValueStore* constants) : insts_(insts), constants_(constants) {} // Returns the ID of the constant used to define the specified type. auto GetConstantId(TypeId type_id) const -> ConstantId { - if (type_id == TypeId::TypeType) { - return ConstantId::ForTemplateConstant(InstId::BuiltinTypeType); - } else if (type_id == TypeId::Error) { - return ConstantId::Error; - } else if (!type_id.is_valid()) { - // TODO: Can we CHECK-fail on this? + if (!type_id.is_valid()) { + // TODO: Investigate replacing this with a CHECK or returning Invalid. return ConstantId::NotConstant; - } else { - return Get(type_id).constant_id; } + return type_id.AsConstantId(); } // Returns the ID of the instruction used to define the specified type. @@ -58,7 +53,7 @@ class TypeStore : public ValueStore { return GetAsInst(type_id).As(); } else { // The type is not a builtin, so no need to check for special values. - auto inst_id = constants_->GetInstId(Get(type_id).constant_id); + auto inst_id = constants_->GetInstId(GetConstantId(type_id)); return insts_->GetAs(inst_id); } } @@ -80,17 +75,27 @@ class TypeStore : public ValueStore { // Gets the value representation to use for a type. This returns an // invalid type if the given type is not complete. auto GetValueRepr(TypeId type_id) const -> ValueRepr { - if (type_id.index < 0) { - // TypeType and InvalidType are their own value representation. - return {.kind = ValueRepr::Copy, .type_id = type_id}; + if (auto type_info = complete_type_info_.Lookup(type_id)) { + return type_info.value().value_repr; } - return Get(type_id).value_repr; + return {.kind = ValueRepr::Unknown}; + } + + // Sets the value representation associated with a type. + auto SetValueRepr(TypeId type_id, ValueRepr value_repr) -> void { + CARBON_CHECK(value_repr.kind != ValueRepr::Unknown); + auto insert_info = + complete_type_info_.Insert(type_id, {.value_repr = value_repr}); + CARBON_CHECK(insert_info.is_inserted()) + << "Type " << type_id << " completed more than once"; + complete_types_.push_back(type_id); + CARBON_CHECK(IsComplete(type_id)); } // Determines whether the given type is known to be complete. This does not // determine whether the type could be completed, only whether it has been. auto IsComplete(TypeId type_id) const -> bool { - return GetValueRepr(type_id).kind != ValueRepr::Unknown; + return complete_type_info_.Contains(type_id); } // Determines whether the given type is a signed integer type. @@ -103,9 +108,35 @@ class TypeStore : public ValueStore { return int_type && int_type->int_kind.is_signed(); } + // Returns a list of types that were completed in this file, in the order in + // which they were completed. Earlier types in this list cannot contain + // instances of later types. + auto complete_types() const -> llvm::ArrayRef { + return complete_types_; + } + + auto OutputYaml() const -> Yaml::OutputMapping { + return Yaml::OutputMapping([&](Yaml::OutputMapping::Map map) { + for (auto type_id : complete_types_) { + map.Add(PrintToString(type_id), + Yaml::OutputScalar(GetValueRepr(type_id))); + } + }); + } + + auto CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const + -> void { + mem_usage.Add(MemUsage::ConcatLabel(label, "complete_type_info_"), + complete_type_info_); + mem_usage.Add(MemUsage::ConcatLabel(label, "complete_types_"), + complete_types_); + } + private: InstStore* insts_; ConstantValueStore* constants_; + Map complete_type_info_; + llvm::SmallVector complete_types_; }; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/type_info.cpp b/toolchain/sem_ir/type_info.cpp new file mode 100644 index 0000000000000..bc42360ef279a --- /dev/null +++ b/toolchain/sem_ir/type_info.cpp @@ -0,0 +1,61 @@ +// 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 + +#include "toolchain/sem_ir/type_info.h" + +#include "toolchain/sem_ir/file.h" + +namespace Carbon::SemIR { + +auto ValueRepr::Print(llvm::raw_ostream& out) const -> void { + out << "{kind: "; + switch (kind) { + case Unknown: + out << "unknown"; + break; + case None: + out << "none"; + break; + case Copy: + out << "copy"; + break; + case Pointer: + out << "pointer"; + break; + case Custom: + out << "custom"; + break; + } + out << ", type: " << type_id << "}"; +} + +auto CompleteTypeInfo::Print(llvm::raw_ostream& out) const -> void { + out << "{value_rep: " << value_repr << "}"; +} + +auto ValueRepr::ForType(const File& file, TypeId type_id) -> ValueRepr { + return file.types().GetValueRepr(type_id); +} + +auto InitRepr::ForType(const File& file, TypeId type_id) -> InitRepr { + auto value_rep = ValueRepr::ForType(file, type_id); + switch (value_rep.kind) { + case ValueRepr::None: + return {.kind = InitRepr::None}; + + case ValueRepr::Copy: + // TODO: Use in-place initialization for types that have non-trivial + // destructive move. + return {.kind = InitRepr::ByCopy}; + + case ValueRepr::Pointer: + case ValueRepr::Custom: + return {.kind = InitRepr::InPlace}; + + case ValueRepr::Unknown: + return {.kind = InitRepr::Incomplete}; + } +} + +} // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/type_info.h b/toolchain/sem_ir/type_info.h index 46dfeb006c5d9..aa5b00999d5e7 100644 --- a/toolchain/sem_ir/type_info.h +++ b/toolchain/sem_ir/type_info.h @@ -6,12 +6,16 @@ #define CARBON_TOOLCHAIN_SEM_IR_TYPE_INFO_H_ #include "common/ostream.h" +#include "toolchain/sem_ir/function.h" #include "toolchain/sem_ir/ids.h" namespace Carbon::SemIR { // The value representation to use when passing by value. struct ValueRepr : public Printable { + // Returns information about the value representation to use for a type. + static auto ForType(const File& file, TypeId type_id) -> ValueRepr; + auto Print(llvm::raw_ostream& out) const -> void; enum Kind : int8_t { @@ -62,17 +66,78 @@ struct ValueRepr : public Printable { TypeId type_id = TypeId::Invalid; }; -// Information stored about a TypeId. -struct TypeInfo : public Printable { +// Information stored about a TypeId corresponding to a complete type. +struct CompleteTypeInfo : public Printable { auto Print(llvm::raw_ostream& out) const -> void; - // The constant type value that defines this type. - ConstantId constant_id; // The value representation for this type. Will be `Unknown` if the type is // not complete. ValueRepr value_repr = ValueRepr(); }; +// The initializing representation to use when returning by value. +struct InitRepr { + // Returns information about the initializing representation to use for a + // type. + static auto ForType(const File& file, TypeId type_id) -> InitRepr; + + enum Kind : int8_t { + // The type has no initializing representation. This is used for empty + // types, where no initialization is necessary. + None, + // An initializing expression produces an object representation by value, + // which is copied into the initialized object. + ByCopy, + // An initializing expression takes a location as input, which is + // initialized as a side effect of evaluating the expression. + InPlace, + // No initializing expressions should exist because the type is not + // complete. + Incomplete, + // TODO: Consider adding a kind where the expression takes an advisory + // location and returns a value plus an indicator of whether the location + // was actually initialized. + }; + // The kind of initializing representation used by this type. + Kind kind; + + // Returns whether the initializing representation information could be fully + // computed. + auto is_valid() const -> bool { return kind != Incomplete; } +}; + +// Information about a function's return type. +struct ReturnTypeInfo { + // Builds return type information for a given declared return type. + static auto ForType(const File& file, TypeId type_id) -> ReturnTypeInfo { + return {.type_id = type_id, + .init_repr = type_id.is_valid() ? InitRepr::ForType(file, type_id) + : InitRepr{.kind = InitRepr::None}}; + } + + // Builds return type information for a given function. + static auto ForFunction(const File& file, const Function& function, + SpecificId specific_id = SpecificId::Invalid) + -> ReturnTypeInfo { + return ForType(file, function.GetDeclaredReturnType(file, specific_id)); + } + + // Returns whether the return information could be fully computed. + auto is_valid() const -> bool { return init_repr.is_valid(); } + + // Returns whether a function with this return type has a return slot. Can + // only be called for valid return info. + auto has_return_slot() const -> bool { + CARBON_CHECK(is_valid()); + return init_repr.kind == InitRepr::InPlace; + } + + // The declared return type. Invalid if no return type was specified. + TypeId type_id; + // The initializing representation for the return type. + InitRepr init_repr; +}; + } // namespace Carbon::SemIR #endif // CARBON_TOOLCHAIN_SEM_IR_TYPE_INFO_H_ diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index f9a10f74049a8..95bc8ee447599 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -6,6 +6,7 @@ #define CARBON_TOOLCHAIN_SEM_IR_TYPED_INSTS_H_ #include "toolchain/parse/node_ids.h" +#include "toolchain/parse/node_kind.h" #include "toolchain/sem_ir/builtin_inst_kind.h" #include "toolchain/sem_ir/ids.h" #include "toolchain/sem_ir/inst_kind.h" @@ -237,7 +238,7 @@ struct AnyBindName { InstKind kind; TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -250,7 +251,7 @@ struct AnyBindNameOrExportDecl { InstKind kind; TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -260,7 +261,7 @@ struct BindAlias { InstKind::BindAlias.Define({.ir_name = "bind_alias"}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -271,7 +272,7 @@ struct BindName { InstKind::BindName.Define({.ir_name = "bind_name"}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; // The value is inline in the inst so that value access doesn't require an // indirection. InstId value_id; @@ -285,7 +286,7 @@ struct BindSymbolicName { .constant_kind = InstConstantKind::SymbolicOnly}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -450,7 +451,7 @@ struct ClassInit { InstId dest_id; }; -// The type for a class, either non-generic or parameterized generic instance. +// The type for a class, either non-generic or specific. struct ClassType { static constexpr auto Kind = InstKind::ClassType.Define( {.ir_name = "class_type", @@ -459,7 +460,7 @@ struct ClassType { TypeId type_id; ClassId class_id; - GenericInstanceId instance_id; + SpecificId specific_id; }; // Indicates `const` on a type, such as `var x: const i32`. @@ -501,7 +502,7 @@ struct ExportDecl { InstKind::ExportDecl.Define({.ir_name = "export"}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; // The exported entity. InstId value_id; }; @@ -575,6 +576,7 @@ struct FunctionType { TypeId type_id; FunctionId function_id; + SpecificId specific_id; }; // The type of the name of a generic class. The corresponding value is an empty @@ -635,7 +637,7 @@ struct AnyImportRef { ImportIRInstId import_ir_inst_id; // A BindName is currently only set on directly imported names. It is not // generically available. - BindNameId bind_name_id; + EntityNameId entity_name_id; }; // An imported entity that is not yet been loaded. @@ -646,7 +648,7 @@ struct ImportRefUnloaded { {.ir_name = "import_ref", .is_lowered = false}); ImportIRInstId import_ir_inst_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; }; // A imported entity that is loaded, and may be used. @@ -658,7 +660,7 @@ struct ImportRefLoaded { TypeId type_id; ImportIRInstId import_ir_inst_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; }; // Finalizes the initialization of `dest_id` from the initializer expression @@ -689,8 +691,7 @@ struct InterfaceDecl { InstBlockId decl_block_id; }; -// The type for an interface, either non-generic or parameterized generic -// instance. +// The type for an interface, either non-generic or specific. struct InterfaceType { static constexpr auto Kind = InstKind::InterfaceType.Define( {.ir_name = "interface_type", @@ -699,7 +700,7 @@ struct InterfaceType { TypeId type_id; InterfaceId interface_id; - GenericInstanceId instance_id; + SpecificId specific_id; }; // A witness that a type implements an interface. @@ -822,7 +823,7 @@ struct ReturnExpr { }; // Given an instruction with a constant value that depends on a generic -// parameter, selects an instance of that instruction with the constant value +// parameter, selects a version of that instruction with the constant value // corresponding to a particular specific. // // TODO: We only form these as the instruction referenced by a `NameRef`. @@ -834,7 +835,7 @@ struct SpecificConstant { TypeId type_id; InstId inst_id; - GenericInstanceId instance_id; + SpecificId specific_id; }; // Splices a block into the location where this appears. This may be an @@ -967,10 +968,11 @@ struct TupleAccess { ElementIndex index; }; -// Access to a tuple member by index, such as `tuple[index]`. +// Access to a tuple member by index, such as `tuple.0`. struct TupleIndex { - static constexpr auto Kind = InstKind::TupleIndex.Define( - {.ir_name = "tuple_index"}); + // TODO: Make Parse::NodeId more specific. + static constexpr auto Kind = + InstKind::TupleIndex.Define({.ir_name = "tuple_index"}); TypeId type_id; InstId tuple_id; diff --git a/toolchain/sem_ir/yaml_test.cpp b/toolchain/sem_ir/yaml_test.cpp index e2e52df532119..1846d6775c9ea 100644 --- a/toolchain/sem_ir/yaml_test.cpp +++ b/toolchain/sem_ir/yaml_test.cpp @@ -49,22 +49,20 @@ TEST(SemIRTest, YAML) { auto type_block_id = Yaml::Scalar(MatchesRegex(R"(type_block\d+)")); auto inst_id = Yaml::Scalar(MatchesRegex(R"(inst\+\d+)")); auto constant_id = - Yaml::Scalar(MatchesRegex(R"((template|symbolic) inst(\w+|\+\d+))")); + Yaml::Scalar(MatchesRegex(R"(templateConstant\(inst(\w+|\+\d+)\))")); auto inst_builtin = Yaml::Scalar(MatchesRegex(R"(inst\w+)")); - auto type_id = Yaml::Scalar(MatchesRegex(R"(type\d+)")); - auto type_builtin = Pair( - type_id, Yaml::Mapping(ElementsAre(Pair("constant", constant_id), - Pair("value_rep", Yaml::Mapping(_))))); + auto type_id = Yaml::Scalar(MatchesRegex(R"(type(\w+|\(inst(\w+|\+\d+)\)))")); + auto type_builtin = Pair(type_id, Yaml::Mapping(_)); auto file = Yaml::Mapping(ElementsAre( Pair("import_irs", Yaml::Mapping(SizeIs(1))), Pair("import_ir_insts", Yaml::Mapping(SizeIs(0))), Pair("name_scopes", Yaml::Mapping(SizeIs(1))), - Pair("bind_names", Yaml::Mapping(SizeIs(1))), + Pair("entity_names", Yaml::Mapping(SizeIs(1))), Pair("functions", Yaml::Mapping(SizeIs(1))), Pair("classes", Yaml::Mapping(SizeIs(0))), Pair("generics", Yaml::Mapping(SizeIs(0))), - Pair("generic_instances", Yaml::Mapping(SizeIs(0))), + Pair("specifics", Yaml::Mapping(SizeIs(0))), Pair("types", Yaml::Mapping(Each(type_builtin))), Pair("type_blocks", Yaml::Mapping(SizeIs(Ge(1)))), Pair("insts", @@ -87,6 +85,7 @@ TEST(SemIRTest, YAML) { Pair("arg1", inst_id)))))))), Pair("constant_values", Yaml::Mapping(AllOf(Each(Pair(inst_id, constant_id))))), + Pair("symbolic_constants", Yaml::Mapping(SizeIs(0))), // This production has only two instruction blocks. Pair("inst_blocks", Yaml::Mapping(ElementsAre(