Model var as a pattern operator (#4720)

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2025-01-17 17:51:34 +00:00
committed by GitHub
co-authored by Richard Smith
parent 6572da7314
commit 13434f0e8a
510 changed files with 11819 additions and 3352 deletions
@@ -24,9 +24,9 @@ interface I {
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
// CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template]
// CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template]
// CHECK:STDOUT: %assoc0.790: %assoc_type = assoc_entity element0, @I.%T [template]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -48,10 +48,10 @@ interface I {
// CHECK:STDOUT:
// CHECK:STDOUT: interface @I {
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42]
// CHECK:STDOUT: %.loc19: type = converted %int_42, <error> [template = <error>]
// CHECK:STDOUT: %T: type = assoc_const_decl T [template]
// CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0.790]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42]
// CHECK:STDOUT: %.loc19: type = converted %int_42, <error> [template = <error>]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
@@ -26,12 +26,14 @@ interface I {
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
// CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic]
// CHECK:STDOUT: %assoc_type.579: type = assoc_entity_type %I.type, type [template]
// CHECK:STDOUT: %assoc0.790: %assoc_type.579 = assoc_entity element0, @I.%T [template]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
// CHECK:STDOUT: %assoc_type.579: type = assoc_entity_type %I.type, type [template]
// CHECK:STDOUT: %assoc0.790: %assoc_type.579 = assoc_entity element0, @I.%T [template]
// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template]
// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, @I.%N [template]
// CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [template]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
// CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template]
@@ -40,8 +42,6 @@ interface I {
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_42.20e, %Convert.956 [template]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
// CHECK:STDOUT: %int_42.c68: %i32 = int_value 42 [template]
// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template]
// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, @I.%N [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -64,14 +64,16 @@ interface I {
// CHECK:STDOUT:
// CHECK:STDOUT: interface @I {
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826]
// CHECK:STDOUT: %T: type = assoc_const_decl T [template]
// CHECK:STDOUT: %assoc0: %assoc_type.579 = assoc_entity element0, %T [template = constants.%assoc0.790]
// CHECK:STDOUT: %int_32.loc16_27: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc16_27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc16_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc16_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc16_35: %tuple.type.24b = tuple_literal (%i32.loc16_27, %i32.loc16_32)
// CHECK:STDOUT: %.loc16_36: type = converted %.loc16_35, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
// CHECK:STDOUT: %T: type = assoc_const_decl T [template]
// CHECK:STDOUT: %assoc0: %assoc_type.579 = assoc_entity element0, %T [template = constants.%assoc0.790]
// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template]
// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, %N [template = constants.%assoc1]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42.20e]
// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_42, %impl.elem0 [template = constants.%Convert.bound]
@@ -79,8 +81,6 @@ interface I {
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_42) [template = constants.%int_42.c68]
// CHECK:STDOUT: %.loc21_27.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_42.c68]
// CHECK:STDOUT: %.loc21_27.2: %i32 = converted %int_42, %.loc21_27.1 [template = constants.%int_42.c68]
// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template]
// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, %N [template = constants.%assoc1]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
+12 -12
View File
@@ -156,16 +156,16 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: %Self.2: %Interface.type.d32 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Interface.%T.loc4_21.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
// CHECK:STDOUT: %assoc_type: type = assoc_entity_type @Interface.%Interface.type (%Interface.type.d32), @Interface.%T.loc4_21.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.376)]
// CHECK:STDOUT: %assoc0.loc5_12.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %assoc0.loc5_8.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: %Self.1: @Interface.%Interface.type (%Interface.type.d32) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
// CHECK:STDOUT: %X: @Interface.%T.loc4_21.2 (%T) = assoc_const_decl X [template]
// CHECK:STDOUT: %assoc0.loc5_12.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %assoc0.loc5_8.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.1
// CHECK:STDOUT: .X = %assoc0.loc5_12.1
// CHECK:STDOUT: .X = %assoc0.loc5_8.1
// CHECK:STDOUT: witness = (%X)
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -188,7 +188,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: fn[%T.param_patt: type](%I.param_patt: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.d32)) -> @AccessGeneric.%T.loc8_18.2 (%T) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %I.ref: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.d32) = name_ref I, %I.loc8_28.1 [symbolic = %I.loc8_28.2 (constants.%I.a5f)]
// CHECK:STDOUT: %.loc9: @AccessGeneric.%assoc_type (%assoc_type.376) = specific_constant @Interface.%assoc0.loc5_12.1, @Interface(constants.%T) [symbolic = %assoc0 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %.loc9: @AccessGeneric.%assoc_type (%assoc_type.376) = specific_constant @Interface.%assoc0.loc5_8.1, @Interface(constants.%T) [symbolic = %assoc0 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %X.ref: @AccessGeneric.%assoc_type (%assoc_type.376) = name_ref X, %.loc9 [symbolic = %assoc0 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %I.as_wit.loc9_11.1: <witness> = facet_access_witness %I.ref [symbolic = %I.as_wit.loc9_11.2 (constants.%I.as_wit.9f4)]
// CHECK:STDOUT: %impl.elem0.loc9_11.1: @AccessGeneric.%T.loc8_18.2 (%T) = impl_witness_access %I.as_wit.loc9_11.1, element0 [symbolic = %impl.elem0.loc9_11.2 (constants.%impl.elem0.68a)]
@@ -207,7 +207,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: fn(%I.param_patt: %Interface.type.981) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %I.ref: %Interface.type.981 = name_ref I, %I.loc12_19.1 [symbolic = %I.loc12_19.2 (constants.%I.d08)]
// CHECK:STDOUT: %.loc13: %assoc_type.5f0 = specific_constant @Interface.%assoc0.loc5_12.1, @Interface(constants.%i32) [template = constants.%assoc0.ed2]
// CHECK:STDOUT: %.loc13: %assoc_type.5f0 = specific_constant @Interface.%assoc0.loc5_8.1, @Interface(constants.%i32) [template = constants.%assoc0.ed2]
// CHECK:STDOUT: %X.ref: %assoc_type.5f0 = name_ref X, %.loc13 [template = constants.%assoc0.ed2]
// CHECK:STDOUT: %I.as_wit.loc13_11.1: <witness> = facet_access_witness %I.ref [symbolic = %I.as_wit.loc13_11.2 (constants.%I.as_wit.156)]
// CHECK:STDOUT: %impl.elem0.loc13_11.1: %i32 = impl_witness_access %I.as_wit.loc13_11.1, element0 [symbolic = %impl.elem0.loc13_11.2 (constants.%impl.elem0.b00)]
@@ -224,7 +224,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: %Self.2 => constants.%Self
// CHECK:STDOUT: %require_complete => constants.%require_complete.4ae
// CHECK:STDOUT: %assoc_type => constants.%assoc_type.376
// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.fa3
// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.fa3
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Interface(%T.loc4_21.2) {}
@@ -248,7 +248,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: %Self.2 => constants.%Self
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
// CHECK:STDOUT: %assoc_type => constants.%assoc_type.5f0
// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.ed2
// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.ed2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @AccessConcrete(constants.%I.d08) {
@@ -360,16 +360,16 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: %Self.2: %Interface.type.d32 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Interface.%T.loc4_21.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
// CHECK:STDOUT: %assoc_type: type = assoc_entity_type @Interface.%Interface.type (%Interface.type.d32), @Interface.%T.loc4_21.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.376)]
// CHECK:STDOUT: %assoc0.loc5_12.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %assoc0.loc5_8.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT:
// CHECK:STDOUT: interface {
// CHECK:STDOUT: %Self.1: @Interface.%Interface.type (%Interface.type.d32) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
// CHECK:STDOUT: %X: @Interface.%T.loc4_21.2 (%T) = assoc_const_decl X [template]
// CHECK:STDOUT: %assoc0.loc5_12.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT: %assoc0.loc5_8.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.1
// CHECK:STDOUT: .X = %assoc0.loc5_12.1
// CHECK:STDOUT: .X = %assoc0.loc5_8.1
// CHECK:STDOUT: witness = (%X)
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -415,7 +415,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: %Self.2 => constants.%Self
// CHECK:STDOUT: %require_complete => constants.%require_complete.4ae
// CHECK:STDOUT: %assoc_type => constants.%assoc_type.376
// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.fa3
// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.fa3
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Interface(%T.loc4_21.2) {}
@@ -439,7 +439,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
// CHECK:STDOUT: %Self.2 => constants.%Self
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
// CHECK:STDOUT: %assoc_type => constants.%assoc_type.5f0
// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.ed2
// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.ed2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @AccessMissingConcrete(constants.%I.d08) {
@@ -56,13 +56,22 @@ fn F(T:! Empty) {
// CHECK:STDOUT: %T.patt.loc13_6.2: %Empty.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_6.2 (constants.%T.patt)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %T.as_type: type = facet_access_type %T.loc13_6.2 [symbolic = %T.as_type (constants.%T.as_type)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%T.as_type (%T.as_type) [symbolic = %require_complete (constants.%require_complete)]
// CHECK:STDOUT: %T.as_type.loc14_10.2: type = facet_access_type %T.loc13_6.2 [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%T.as_type.loc14_10.2 (%T.as_type) [symbolic = %require_complete (constants.%require_complete)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%T.param_patt: %Empty.type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %x.var: ref @F.%T.as_type (%T.as_type) = var x
// CHECK:STDOUT: %x: ref @F.%T.as_type (%T.as_type) = bind_name x, %x.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %x.patt: @F.%T.as_type.loc14_10.2 (%T.as_type) = binding_pattern x
// CHECK:STDOUT: %.loc14_3: @F.%T.as_type.loc14_10.2 (%T.as_type) = var_pattern %x.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %x.var: ref @F.%T.as_type.loc14_10.2 (%T.as_type) = var x
// CHECK:STDOUT: %.loc14_10.1: type = splice_block %.loc14_10.2 [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)] {
// CHECK:STDOUT: %T.ref: %Empty.type = name_ref T, %T.loc13_6.1 [symbolic = %T.loc13_6.2 (constants.%T)]
// CHECK:STDOUT: %T.as_type.loc14_10.1: type = facet_access_type %T.ref [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc14_10.2: type = converted %T.ref, %T.as_type.loc14_10.1 [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %x: ref @F.%T.as_type.loc14_10.2 (%T.as_type) = bind_name x, %x.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -85,12 +85,17 @@ class C {
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %c.patt: %C = binding_pattern c
// CHECK:STDOUT: %.loc16_7.1: %C = var_pattern %c.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %c.var: ref %C = var c
// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
// CHECK:STDOUT: %.loc16_19.1: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: %.loc16_19.2: init %C = class_init (), %c.var [template = constants.%C.val]
// CHECK:STDOUT: %.loc16_20: init %C = converted %.loc16_19.1, %.loc16_19.2 [template = constants.%C.val]
// CHECK:STDOUT: assign %c.var, %.loc16_20
// CHECK:STDOUT: %.loc16_7.2: init %C = converted %.loc16_19.1, %.loc16_19.2 [template = constants.%C.val]
// CHECK:STDOUT: assign %c.var, %.loc16_7.2
// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
// CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c
// CHECK:STDOUT: %I.ref: type = name_ref I, @C.%I.decl [template = constants.%I.type]
// CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, @I.%assoc0 [template = constants.%assoc0]
@@ -26,6 +26,8 @@ interface I {
// CHECK:STDOUT: interface @I {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = <unexpected>.inst15
// CHECK:STDOUT: .T = <unexpected>.inst19.loc16_9
// CHECK:STDOUT: .U = <unexpected>.inst22.loc16_19
// CHECK:STDOUT: witness = invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -41,8 +41,8 @@ alias UseOther = I.other;
// CHECK:STDOUT: }
// CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
// CHECK:STDOUT: %I.ref.loc24: type = name_ref I, %I.decl [template = constants.%I.type]
// CHECK:STDOUT: %a.ref: <error> = name_ref a, <error> [template = <error>]
// CHECK:STDOUT: %UseA: <error> = bind_alias UseA, <error> [template = <error>]
// CHECK:STDOUT: %a.ref: <error> = name_ref a, <unexpected>.inst19.loc20_7
// CHECK:STDOUT: %UseA: <error> = bind_alias UseA, <unexpected>.inst19.loc20_7
// CHECK:STDOUT: %I.ref.loc27: type = name_ref I, %I.decl [template = constants.%I.type]
// CHECK:STDOUT: %other.ref: <error> = name_ref other, <error> [template = <error>]
// CHECK:STDOUT: %UseOther: <error> = bind_alias UseOther, <error> [template = <error>]
@@ -53,6 +53,7 @@ alias UseOther = I.other;
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
// CHECK:STDOUT: .a = <unexpected>.inst19.loc20_7
// CHECK:STDOUT: has_error
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT: }
@@ -26,6 +26,7 @@ interface I {
// CHECK:STDOUT: interface @I {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = <unexpected>.inst15
// CHECK:STDOUT: .T = <unexpected>.inst19.loc16_17
// CHECK:STDOUT: witness = invalid
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -0,0 +1,53 @@
// 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_incomplete_type.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon
class C;
interface I {
// CHECK:STDERR: fail_incomplete_type.carbon:[[@LINE+7]]:11: error: associated constant has incomplete type `C` [IncompleteTypeInAssociatedDecl]
// CHECK:STDERR: let T:! C;
// CHECK:STDERR: ^
// CHECK:STDERR: fail_incomplete_type.carbon:[[@LINE-6]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class C;
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
let T:! C;
}
// CHECK:STDOUT: --- fail_incomplete_type.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [template]
// CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .C = %C.decl
// CHECK:STDOUT: .I = %I.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
// CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: interface @I {
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
// CHECK:STDOUT: %T: <error> = assoc_const_decl T [template]
// CHECK:STDOUT: %assoc0: <error> = assoc_entity element0, %T [template = <error>]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
// CHECK:STDOUT: .T = %assoc0
// CHECK:STDOUT: witness = (%T)
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C;
// CHECK:STDOUT:
@@ -36,33 +36,49 @@ let U: (type where .Self impls type).missing = {};
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .T = @__global_init.%T
// CHECK:STDOUT: .T = %T
// CHECK:STDOUT: }
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %T.patt: <error> = binding_pattern T
// CHECK:STDOUT: }
// CHECK:STDOUT: %T: <error> = bind_name T, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc8: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: %T: <error> = bind_name T, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_lookup_type_where.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic]
// CHECK:STDOUT: %type_where: type = facet_type <type where TODO> [template]
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .U = @__global_init.%U
// CHECK:STDOUT: .U = %U
// CHECK:STDOUT: }
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %U.patt: <error> = binding_pattern U
// CHECK:STDOUT: }
// CHECK:STDOUT: %.1: <error> = splice_block <error> [template = <error>] {
// CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic = constants.%.Self]
// CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self]
// CHECK:STDOUT: %.loc8: type = where_expr %.Self [template = constants.%type_where] {
// CHECK:STDOUT: requirement_impls %.Self.ref, type
// CHECK:STDOUT: }
// CHECK:STDOUT: %missing.ref: <error> = name_ref missing, <error> [template = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %U: <error> = bind_name U, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc8: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: %U: <error> = bind_name U, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -113,10 +113,19 @@ fn G(U:! Different) -> U.(Interface.T);
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F.2() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
// CHECK:STDOUT: %Interface.ref.loc22: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
// CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, @Interface.%assoc0 [template = constants.%assoc0]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %v.patt: <error> = binding_pattern v
// CHECK:STDOUT: %.loc28_3: <error> = var_pattern %v.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %v.var: ref <error> = var v
// CHECK:STDOUT: %v: ref <error> = bind_name v, %v.var
// CHECK:STDOUT: %.1: <error> = splice_block <error> [template = <error>] {
// CHECK:STDOUT: %Interface.ref.loc28: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
// CHECK:STDOUT: %T.ref: %assoc_type = name_ref T, @Interface.%assoc1 [template = constants.%assoc1]
// CHECK:STDOUT: %.loc28_19: type = converted %T.ref, <error> [template = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v: <error> = bind_name v, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+18 -2
View File
@@ -82,7 +82,15 @@ var f: ForwardDeclared* = &f_ref.f;
// CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%Empty.type] {} {}
// CHECK:STDOUT: %Basic.decl: type = interface_decl @Basic [template = constants.%Basic.type] {} {}
// CHECK:STDOUT: %ForwardDeclared.decl: type = interface_decl @ForwardDeclared [template = constants.%ForwardDeclared.type] {} {}
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %f_ref.patt: %struct_type.f.2f5 = binding_pattern f_ref
// CHECK:STDOUT: %.loc20_1: %struct_type.f.2f5 = var_pattern %f_ref.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %f_ref.var: ref %struct_type.f.2f5 = var f_ref
// CHECK:STDOUT: %.loc20_32: type = splice_block %struct_type.f [template = constants.%struct_type.f.2f5] {
// CHECK:STDOUT: %ForwardDeclared.ref: type = name_ref ForwardDeclared, %ForwardDeclared.decl [template = constants.%ForwardDeclared.type]
// CHECK:STDOUT: %struct_type.f: type = struct_type {.f: %ForwardDeclared.type} [template = constants.%struct_type.f.2f5]
// CHECK:STDOUT: }
// CHECK:STDOUT: %f_ref: ref %struct_type.f.2f5 = bind_name f_ref, %f_ref.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -171,12 +179,12 @@ var f: ForwardDeclared* = &f_ref.f;
// CHECK:STDOUT: %import_ref.2ac: ref %struct_type.f.2f5 = import_ref Main//a, f_ref, loaded
// CHECK:STDOUT: %import_ref.cc0 = import_ref Main//a, inst15 [no loc], unloaded
// CHECK:STDOUT: %import_ref.37f = import_ref Main//a, inst19 [no loc], unloaded
// CHECK:STDOUT: %import_ref.42e: %assoc_type.6af = import_ref Main//a, loc8_15, loaded [template = constants.%assoc0.1d6]
// CHECK:STDOUT: %import_ref.42e: %assoc_type.6af = import_ref Main//a, loc8_8, loaded [template = constants.%assoc0.1d6]
// CHECK:STDOUT: %import_ref.b06: %F.assoc_type.94b = import_ref Main//a, loc9_9, loaded [template = constants.%assoc1.d7b]
// CHECK:STDOUT: %import_ref.08d600.1 = import_ref Main//a, T, unloaded
// CHECK:STDOUT: %import_ref.eea = import_ref Main//a, F, unloaded
// CHECK:STDOUT: %import_ref.52b = import_ref Main//a, inst34 [no loc], unloaded
// CHECK:STDOUT: %import_ref.95f: %assoc_type.3e8 = import_ref Main//a, loc16_15, loaded [template = constants.%assoc0.910]
// CHECK:STDOUT: %import_ref.95f: %assoc_type.3e8 = import_ref Main//a, loc16_8, loaded [template = constants.%assoc0.910]
// CHECK:STDOUT: %import_ref.7f1: %F.assoc_type.1e3 = import_ref Main//a, loc17_9, loaded [template = constants.%assoc1.68e]
// CHECK:STDOUT: %import_ref.08d600.2 = import_ref Main//a, T, unloaded
// CHECK:STDOUT: %import_ref.5d0 = import_ref Main//a, F, unloaded
@@ -234,7 +242,15 @@ var f: ForwardDeclared* = &f_ref.f;
// CHECK:STDOUT: %ForwardDeclared.ref.loc14: type = name_ref ForwardDeclared, imports.%import_ref.e33 [template = constants.%ForwardDeclared.type]
// CHECK:STDOUT: %F.ref.loc14: %F.assoc_type.1e3 = name_ref F, imports.%import_ref.7f1 [template = constants.%assoc1.68e]
// CHECK:STDOUT: %UseForwardDeclaredF: %F.assoc_type.1e3 = bind_alias UseForwardDeclaredF, imports.%import_ref.7f1 [template = constants.%assoc1.68e]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %f.patt: %ptr = binding_pattern f
// CHECK:STDOUT: %.loc16_1: %ptr = var_pattern %f.patt
// CHECK:STDOUT: }
// CHECK:STDOUT: %f.var: ref %ptr = var f
// CHECK:STDOUT: %.loc16_23: type = splice_block %ptr [template = constants.%ptr] {
// CHECK:STDOUT: %ForwardDeclared.ref.loc16: type = name_ref ForwardDeclared, imports.%import_ref.e33 [template = constants.%ForwardDeclared.type]
// CHECK:STDOUT: %ptr: type = ptr_type %ForwardDeclared.type [template = constants.%ptr]
// CHECK:STDOUT: }
// CHECK:STDOUT: %f: ref %ptr = bind_name f, %f.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -34,10 +34,12 @@ interface I {
// CHECK:STDOUT: %G: %G.type = struct_value () [template]
// CHECK:STDOUT: %G.assoc_type: type = assoc_entity_type %I.type, %G.type [template]
// CHECK:STDOUT: %assoc1: %G.assoc_type = assoc_entity element1, @I.%G.decl [template]
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
// CHECK:STDOUT: %assoc_type.579: type = assoc_entity_type %I.type, type [template]
// CHECK:STDOUT: %assoc2: %assoc_type.579 = assoc_entity element2, @I.%T [template]
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template]
// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, @I.%N [template]
// CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [template]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
// CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template]
@@ -46,8 +48,6 @@ interface I {
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_42.20e, %Convert.956 [template]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
// CHECK:STDOUT: %int_42.c68: %i32 = int_value 42 [template]
// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template]
// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, @I.%N [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -98,14 +98,16 @@ interface I {
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %assoc1: %G.assoc_type = assoc_entity element1, %G.decl [template = constants.%assoc1]
// CHECK:STDOUT: %T: type = assoc_const_decl T [template]
// CHECK:STDOUT: %assoc2: %assoc_type.579 = assoc_entity element2, %T [template = constants.%assoc2]
// CHECK:STDOUT: %int_32.loc18_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc18_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %int_32.loc18_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32.loc18_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc18_27: %tuple.type.24b = tuple_literal (%i32.loc18_19, %i32.loc18_24)
// CHECK:STDOUT: %.loc18_28: type = converted %.loc18_27, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
// CHECK:STDOUT: %T: type = assoc_const_decl T [template]
// CHECK:STDOUT: %assoc2: %assoc_type.579 = assoc_entity element2, %T [template = constants.%assoc2]
// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template]
// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, %N [template = constants.%assoc3]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42.20e]
// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_42, %impl.elem0 [template = constants.%Convert.bound]
@@ -113,8 +115,6 @@ interface I {
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_42) [template = constants.%int_42.c68]
// CHECK:STDOUT: %.loc19_19.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_42.c68]
// CHECK:STDOUT: %.loc19_19.2: %i32 = converted %int_42, %.loc19_19.1 [template = constants.%int_42.c68]
// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template]
// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, %N [template = constants.%assoc3]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self