mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Replace :! binding syntax with phase keywords and contextual defaults (#7479)
Implement the toolchain side of proposal #7254, removing the `:!` binding syntax for generic and template parameters in favor of the keywords `generic`, `template`, and `runtime` plus contextual defaults for phase. For valid programs this is semantics-preserving: each binding resolves to the same phase, and produces the same SemIR, as it did under `:!`/`:`. The parser derives a binding's phase from its syntactic context plus any explicit phase keyword; new diagnostics and error recovery for misused keywords are described below. Implementation details for each component: - Lexer: remove the `:!` (`ColonExclaim`) token, move its virtual parse-node budget onto `:`, and add the `generic` and `runtime` keywords. - Parser: thread a `BindingContext` (`ExplicitParam`, `DeducedParam`, or `CompileTimeEntityParam`) from declaration introducers down through parameter lists to each binding pattern, using a one-token lookahead to distinguish a name-qualifier parameter list from a declaration's own final list. Parameters of a compile-time entity (`class`, `interface`, `constraint`, `choice`, `alias`, `export`, `namespace`) and deduced `[]` parameters default to checked generic; explicit function parameters and local bindings default to runtime. `HandleBindingPattern` resolves the phase from that context plus the keyword: a `generic` keyword needs no node of its own (the phase is carried by the binding's node kind), while a `runtime` keyword is preserved as a `RuntimeBindingName` node so `check` can name it in a diagnostic. A phase keyword that is merely redundant with the contextual default is diagnosed here, without invalidating the parse tree. - Check: a phase keyword that is invalid for its context (for example `runtime` on a checked-generic parameter) is diagnosed here, and recovers by building an error binding that still introduces the name so that later uses of it do not produce cascading errors. The removed `:!` syntax is now rejected as an ordinary parse error. The `form`/`:?`/`->?` ("extended types") portion of proposal #7254 is left for a separate change. Assisted-by: Claude Code
This commit is contained in:
@@ -13,10 +13,10 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/fail_runtime_implicit_param.carbon
|
||||
|
||||
// CHECK:STDERR: fail_runtime_implicit_param.carbon:[[@LINE+4]]:6: error: implicit parameters of functions must be constant [ImplictParamMustBeConstant]
|
||||
// CHECK:STDERR: fn F[s: ()]();
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR: fn F[runtime s: ()]();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn F[s: ()]();
|
||||
fn F[runtime s: ()]();
|
||||
|
||||
fn Run() {
|
||||
F();
|
||||
|
||||
+101
-101
@@ -78,14 +78,14 @@ library "[[@TEST_NAME]]";
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
fn F(x:? i32);
|
||||
// CHECK:STDERR: fail_form_param_not_form.carbon:[[@LINE+8]]:6: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn G(ref x:? i32);
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_form_param_not_form.carbon:[[@LINE+4]]:6: error: expected `:` binding after `ref` [ExpectedRuntimeBindingPatternAfterRef]
|
||||
// CHECK:STDERR: fail_form_param_not_form.carbon:[[@LINE+8]]:6: error: `ref` is only allowed on a runtime binding [ExpectedRuntimeBindingPatternAfterRef]
|
||||
// CHECK:STDERR: fn G(ref x:? i32);
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_form_param_not_form.carbon:[[@LINE+4]]:10: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn G(ref x:? i32);
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn G(ref x:? i32);
|
||||
|
||||
// --- fail_missing_ref_tag.carbon
|
||||
@@ -108,7 +108,7 @@ fn G() {
|
||||
// --- form_generic_param.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
|
||||
fn G() {
|
||||
var x: i32;
|
||||
@@ -118,7 +118,7 @@ fn G() {
|
||||
// --- fail_todo_composite_generic_form.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
|
||||
fn G() {
|
||||
var x: i32;
|
||||
@@ -128,9 +128,9 @@ fn G() {
|
||||
// CHECK:STDERR: fail_todo_composite_generic_form.carbon:[[@LINE+7]]:3: note: type `(Core.Form, Core.Form)` does not implement interface `Core.ImplicitAs(Core.Form)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: F((form(var i32), form(ref i32)), (x, ref x));
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_composite_generic_form.carbon:[[@LINE-10]]:6: note: initializing generic parameter `Fm` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_composite_generic_form.carbon:[[@LINE-10]]:14: note: initializing generic parameter `Fm` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F((form(var i32), form(ref i32)), (x, ref x));
|
||||
}
|
||||
@@ -138,7 +138,7 @@ fn G() {
|
||||
// --- fail_todo_deduce_generic_form.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F[Fm:! Core.Form](v:? Fm);
|
||||
fn F[Fm: Core.Form](v:? Fm);
|
||||
|
||||
fn G() {
|
||||
var v: i32 = 0;
|
||||
@@ -146,8 +146,8 @@ fn G() {
|
||||
// CHECK:STDERR: F(ref v);
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_deduce_generic_form.carbon:[[@LINE-7]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
|
||||
// CHECK:STDERR: fn F[Fm:! Core.Form](v:? Fm);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fn F[Fm: Core.Form](v:? Fm);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(ref v);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ fn G() {
|
||||
// --- fail_form_generic_arg_not_form.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
|
||||
fn G() {
|
||||
var x: i32;
|
||||
@@ -165,9 +165,9 @@ fn G() {
|
||||
// CHECK:STDERR: fail_form_generic_arg_not_form.carbon:[[@LINE+7]]:3: note: type `type` does not implement interface `Core.ImplicitAs(Core.Form)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: F(i32, x);
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_form_generic_arg_not_form.carbon:[[@LINE-10]]:6: note: initializing generic parameter `Fm` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_form_generic_arg_not_form.carbon:[[@LINE-10]]:14: note: initializing generic parameter `Fm` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(i32, x);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ fn G() {
|
||||
// --- fail_form_generic_missing_ref_tag.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
|
||||
fn G() {
|
||||
var x: i32;
|
||||
@@ -183,9 +183,9 @@ fn G() {
|
||||
// CHECK:STDERR: F(form(ref i32), x);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_form_generic_missing_ref_tag.carbon: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: fail_form_generic_missing_ref_tag.carbon:[[@LINE-8]]:29: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: fn F(Fm:! Core.Form, unused x:? Fm) {}
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: fail_form_generic_missing_ref_tag.carbon:[[@LINE-8]]:36: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: fn F(generic Fm: Core.Form, unused x:? Fm) {}
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
F(form(ref i32), x);
|
||||
}
|
||||
@@ -206,7 +206,7 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
// TODO: this code should fail for a different reason, but right now we don't
|
||||
// have a way to write correct code that reaches the TODO we're exercising here.
|
||||
fn F(Form:! Core.Form) {
|
||||
fn F(generic Form: Core.Form) {
|
||||
// CHECK:STDERR: fail_todo_local_symbolic_form_binding.carbon:[[@LINE+4]]:7: error: semantics TODO: `support local form bindings` [SemanticsTodo]
|
||||
// CHECK:STDERR: let y:? Form = 0;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
@@ -274,7 +274,7 @@ fn F() ->? ref i32;
|
||||
library "[[@TEST_NAME]]";
|
||||
//@include-in-dumps
|
||||
|
||||
fn F(Fm:! Core.Form, v:? Fm) ->? Fm {
|
||||
fn F(generic Fm: Core.Form, v:? Fm) ->? Fm {
|
||||
// TODO: This should fail because `Fm` might be `form(var T)` for a
|
||||
// non-copyable `T`.
|
||||
return v;
|
||||
@@ -673,9 +673,9 @@ fn G() {
|
||||
// CHECK:STDOUT: %Fm: Core.Form = symbolic_binding Fm, 0 [symbolic]
|
||||
// CHECK:STDOUT: %.42f: type = type_component_of %Fm [symbolic]
|
||||
// CHECK:STDOUT: %pattern_type.177: type = pattern_type %.42f [symbolic]
|
||||
// CHECK:STDOUT: %.f15: %pattern_type.177 = splice_inst @F.%.loc4_23.3 [template]
|
||||
// CHECK:STDOUT: %.f15: %pattern_type.177 = splice_inst @F.%.loc4_30.3 [template]
|
||||
// CHECK:STDOUT: %v.patt.0b3: %pattern_type.177 = at_binding_pattern v, %.f15 [template]
|
||||
// CHECK:STDOUT: %.677: %pattern_type.177 = splice_inst @F.%.loc4_30.3 [template]
|
||||
// CHECK:STDOUT: %.677: %pattern_type.177 = splice_inst @F.%.loc4_37.3 [template]
|
||||
// CHECK:STDOUT: %return.patt.113: %pattern_type.177 = return_slot_pattern %.677, %.42f [template]
|
||||
// CHECK:STDOUT: %.cfa: <instruction> = form_param_pattern_action %Fm, v [template]
|
||||
// CHECK:STDOUT: %.26b: %pattern_type.177 = splice_inst %.cfa [template]
|
||||
@@ -816,52 +816,52 @@ fn G() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_8.1: %pattern_type.13f = symbolic_binding_pattern Fm, 0 [symbolic = %Fm.patt.loc4_8.2 (constants.%Fm.patt)]
|
||||
// CHECK:STDOUT: %.loc4_23.2: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_23.3 [template = %.loc4_23.4 (constants.%.f15)]
|
||||
// CHECK:STDOUT: %v.patt.loc4_23.1: @F.%pattern_type (%pattern_type.177) = at_binding_pattern v, %.loc4_23.2 [template = %v.patt.loc4_23.2 (constants.%v.patt.0b3)]
|
||||
// CHECK:STDOUT: %.loc4_30.2: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_30.3 [template = %.loc4_30.4 (constants.%.677)]
|
||||
// CHECK:STDOUT: %return.patt.loc4_30.1: @F.%pattern_type (%pattern_type.177) = return_slot_pattern %.loc4_30.2, %.loc4_34 [template = %return.patt.loc4_30.2 (constants.%return.patt.113)]
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_16.1: %pattern_type.13f = symbolic_binding_pattern Fm, 0 [symbolic = %Fm.patt.loc4_16.2 (constants.%Fm.patt)]
|
||||
// CHECK:STDOUT: %.loc4_30.2: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_30.3 [template = %.loc4_30.4 (constants.%.f15)]
|
||||
// CHECK:STDOUT: %v.patt.loc4_30.1: @F.%pattern_type (%pattern_type.177) = at_binding_pattern v, %.loc4_30.2 [template = %v.patt.loc4_30.2 (constants.%v.patt.0b3)]
|
||||
// CHECK:STDOUT: %.loc4_37.2: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_37.3 [template = %.loc4_37.4 (constants.%.677)]
|
||||
// CHECK:STDOUT: %return.patt.loc4_37.1: @F.%pattern_type (%pattern_type.177) = return_slot_pattern %.loc4_37.2, %.loc4_41 [template = %return.patt.loc4_37.2 (constants.%return.patt.113)]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %Fm.ref.loc4_34: Core.Form = name_ref Fm, %Fm.loc4_8.2 [symbolic = %Fm.loc4_8.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_34: type = type_component_of %Fm.ref.loc4_34 [symbolic = %.loc4_26.1 (constants.%.42f)]
|
||||
// CHECK:STDOUT: %.loc4_15: type = splice_block %Form.ref [concrete = Core.Form] {
|
||||
// CHECK:STDOUT: %Fm.ref.loc4_41: Core.Form = name_ref Fm, %Fm.loc4_16.2 [symbolic = %Fm.loc4_16.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_41: type = type_component_of %Fm.ref.loc4_41 [symbolic = %.loc4_33.1 (constants.%.42f)]
|
||||
// CHECK:STDOUT: %.loc4_22: type = splice_block %Form.ref [concrete = Core.Form] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
|
||||
// CHECK:STDOUT: %Form.ref: type = name_ref Form, imports.%Core.Form [concrete = Core.Form]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Fm.loc4_8.2: Core.Form = symbolic_binding Fm, 0 [symbolic = %Fm.loc4_8.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_23.1: @F.%.loc4_26.1 (%.42f) = splice_inst %.loc4_23.5
|
||||
// CHECK:STDOUT: %.loc4_26.2: Core.Form = splice_block %Fm.ref.loc4_26 [symbolic = %Fm.loc4_8.1 (constants.%Fm)] {
|
||||
// CHECK:STDOUT: %Fm.ref.loc4_26: Core.Form = name_ref Fm, %Fm.loc4_8.2 [symbolic = %Fm.loc4_8.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_26.3: type = type_component_of %Fm.ref.loc4_26 [symbolic = %.loc4_26.1 (constants.%.42f)]
|
||||
// CHECK:STDOUT: %Fm.loc4_16.2: Core.Form = symbolic_binding Fm, 0 [symbolic = %Fm.loc4_16.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_30.1: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_30.5
|
||||
// CHECK:STDOUT: %.loc4_33.2: Core.Form = splice_block %Fm.ref.loc4_33 [symbolic = %Fm.loc4_16.1 (constants.%Fm)] {
|
||||
// CHECK:STDOUT: %Fm.ref.loc4_33: Core.Form = name_ref Fm, %Fm.loc4_16.2 [symbolic = %Fm.loc4_16.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_33.3: type = type_component_of %Fm.ref.loc4_33 [symbolic = %.loc4_33.1 (constants.%.42f)]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %v: @F.%.loc4_26.1 (%.42f) = wrapper_binding v, %.loc4_23.1
|
||||
// CHECK:STDOUT: %.loc4_30.1: @F.%.loc4_26.1 (%.42f) = splice_inst %.loc4_30.5
|
||||
// CHECK:STDOUT: %return: @F.%.loc4_26.1 (%.42f) = return_slot %.loc4_30.1
|
||||
// CHECK:STDOUT: %v: @F.%.loc4_33.1 (%.42f) = wrapper_binding v, %.loc4_30.1
|
||||
// CHECK:STDOUT: %.loc4_37.1: @F.%.loc4_33.1 (%.42f) = splice_inst %.loc4_37.5
|
||||
// CHECK:STDOUT: %return: @F.%.loc4_33.1 (%.42f) = return_slot %.loc4_37.1
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic fn @F(%Fm.loc4_8.2: Core.Form) {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_8.2: %pattern_type.13f = symbolic_binding_pattern Fm, 0 [symbolic = %Fm.patt.loc4_8.2 (constants.%Fm.patt)]
|
||||
// CHECK:STDOUT: %Fm.loc4_8.1: Core.Form = symbolic_binding Fm, 0 [symbolic = %Fm.loc4_8.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_26.1: type = type_component_of %Fm.loc4_8.1 [symbolic = %.loc4_26.1 (constants.%.42f)]
|
||||
// CHECK:STDOUT: %.loc4_23.3: <instruction> = form_param_pattern_action %Fm.ref.loc4_26, v [template]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %.loc4_26.1 [symbolic = %pattern_type (constants.%pattern_type.177)]
|
||||
// CHECK:STDOUT: %.loc4_23.4: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_23.3 [template = %.loc4_23.4 (constants.%.f15)]
|
||||
// CHECK:STDOUT: %v.patt.loc4_23.2: @F.%pattern_type (%pattern_type.177) = at_binding_pattern v, %.loc4_23.4 [template = %v.patt.loc4_23.2 (constants.%v.patt.0b3)]
|
||||
// CHECK:STDOUT: %.loc4_30.3: <instruction> = out_form_param_pattern_action %Fm.ref.loc4_34 [template]
|
||||
// CHECK:STDOUT: %.loc4_30.4: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_30.3 [template = %.loc4_30.4 (constants.%.677)]
|
||||
// CHECK:STDOUT: %return.patt.loc4_30.2: @F.%pattern_type (%pattern_type.177) = return_slot_pattern %.loc4_30.4, %.loc4_26.1 [template = %return.patt.loc4_30.2 (constants.%return.patt.113)]
|
||||
// CHECK:STDOUT: %.loc4_23.5: <instruction> = callee_pattern_match_action constants.%.f15, call_param0 [template]
|
||||
// CHECK:STDOUT: %.loc4_30.5: <instruction> = callee_pattern_match_action constants.%.677, call_param1 [template]
|
||||
// CHECK:STDOUT: generic fn @F(%Fm.loc4_16.2: Core.Form) {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_16.2: %pattern_type.13f = symbolic_binding_pattern Fm, 0 [symbolic = %Fm.patt.loc4_16.2 (constants.%Fm.patt)]
|
||||
// CHECK:STDOUT: %Fm.loc4_16.1: Core.Form = symbolic_binding Fm, 0 [symbolic = %Fm.loc4_16.1 (constants.%Fm)]
|
||||
// CHECK:STDOUT: %.loc4_33.1: type = type_component_of %Fm.loc4_16.1 [symbolic = %.loc4_33.1 (constants.%.42f)]
|
||||
// CHECK:STDOUT: %.loc4_30.3: <instruction> = form_param_pattern_action %Fm.ref.loc4_33, v [template]
|
||||
// CHECK:STDOUT: %pattern_type: type = pattern_type %.loc4_33.1 [symbolic = %pattern_type (constants.%pattern_type.177)]
|
||||
// CHECK:STDOUT: %.loc4_30.4: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_30.3 [template = %.loc4_30.4 (constants.%.f15)]
|
||||
// CHECK:STDOUT: %v.patt.loc4_30.2: @F.%pattern_type (%pattern_type.177) = at_binding_pattern v, %.loc4_30.4 [template = %v.patt.loc4_30.2 (constants.%v.patt.0b3)]
|
||||
// CHECK:STDOUT: %.loc4_37.3: <instruction> = out_form_param_pattern_action %Fm.ref.loc4_41 [template]
|
||||
// CHECK:STDOUT: %.loc4_37.4: @F.%pattern_type (%pattern_type.177) = splice_inst %.loc4_37.3 [template = %.loc4_37.4 (constants.%.677)]
|
||||
// CHECK:STDOUT: %return.patt.loc4_37.2: @F.%pattern_type (%pattern_type.177) = return_slot_pattern %.loc4_37.4, %.loc4_33.1 [template = %return.patt.loc4_37.2 (constants.%return.patt.113)]
|
||||
// CHECK:STDOUT: %.loc4_30.5: <instruction> = callee_pattern_match_action constants.%.f15, call_param0 [template]
|
||||
// CHECK:STDOUT: %.loc4_37.5: <instruction> = callee_pattern_match_action constants.%.677, call_param1 [template]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.loc4_26.1 [symbolic = %require_complete (constants.%require_complete.c9b)]
|
||||
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.loc4_33.1 [symbolic = %require_complete (constants.%require_complete.c9b)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn(%.loc4_23.1: @F.%.loc4_26.1 (%.42f)) -> out %.loc4_30.1:? %Fm {
|
||||
// CHECK:STDOUT: fn(%.loc4_30.1: @F.%.loc4_33.1 (%.42f)) -> out %.loc4_37.1:? %Fm {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %v.ref: @F.%.loc4_26.1 (%.42f) = name_ref v, %v
|
||||
// CHECK:STDOUT: %v.ref: @F.%.loc4_33.1 (%.42f) = name_ref v, %v
|
||||
// CHECK:STDOUT: return %v.ref
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
@@ -954,69 +954,69 @@ fn G() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @F(constants.%Fm) {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_8.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_8.1 => constants.%Fm
|
||||
// CHECK:STDOUT: %.loc4_26.1 => constants.%.42f
|
||||
// CHECK:STDOUT: %.loc4_23.3 => constants.%.cfa
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_16.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_16.1 => constants.%Fm
|
||||
// CHECK:STDOUT: %.loc4_33.1 => constants.%.42f
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%.cfa
|
||||
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.177
|
||||
// CHECK:STDOUT: %.loc4_23.4 => constants.%.26b
|
||||
// CHECK:STDOUT: %v.patt.loc4_23.2 => constants.%v.patt.cda
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%.94f
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%.1ac
|
||||
// CHECK:STDOUT: %return.patt.loc4_30.2 => constants.%return.patt.333
|
||||
// CHECK:STDOUT: %.loc4_23.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.efc
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%.26b
|
||||
// CHECK:STDOUT: %v.patt.loc4_30.2 => constants.%v.patt.cda
|
||||
// CHECK:STDOUT: %.loc4_37.3 => constants.%.94f
|
||||
// CHECK:STDOUT: %.loc4_37.4 => constants.%.1ac
|
||||
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.333
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @F(constants.%.795) {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_8.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_8.1 => constants.%.795
|
||||
// CHECK:STDOUT: %.loc4_26.1 => constants.%i32
|
||||
// CHECK:STDOUT: %.loc4_23.3 => constants.%inst.splice_block
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_16.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_16.1 => constants.%.795
|
||||
// CHECK:STDOUT: %.loc4_33.1 => constants.%i32
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%inst.splice_block
|
||||
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.6b6
|
||||
// CHECK:STDOUT: %.loc4_23.4 => constants.%v.var_patt.13561f.1
|
||||
// CHECK:STDOUT: %v.patt.loc4_23.2 => constants.%v.patt.b2b
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%inst.out_param_pattern
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%return.param_patt.a9a4c7.1
|
||||
// CHECK:STDOUT: %return.patt.loc4_30.2 => constants.%return.patt.e1b
|
||||
// CHECK:STDOUT: %.loc4_23.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.efc
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%v.var_patt.13561f.1
|
||||
// CHECK:STDOUT: %v.patt.loc4_30.2 => constants.%v.patt.b2b
|
||||
// CHECK:STDOUT: %.loc4_37.3 => constants.%inst.out_param_pattern
|
||||
// CHECK:STDOUT: %.loc4_37.4 => constants.%return.param_patt.a9a4c7.1
|
||||
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.e1b
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @F(constants.%.512) {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_8.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_8.1 => constants.%.512
|
||||
// CHECK:STDOUT: %.loc4_26.1 => constants.%i32
|
||||
// CHECK:STDOUT: %.loc4_23.3 => constants.%inst.ref_param_pattern
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_16.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_16.1 => constants.%.512
|
||||
// CHECK:STDOUT: %.loc4_33.1 => constants.%i32
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%inst.ref_param_pattern
|
||||
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.6b6
|
||||
// CHECK:STDOUT: %.loc4_23.4 => constants.%v.param_patt.e9ad17.1
|
||||
// CHECK:STDOUT: %v.patt.loc4_23.2 => constants.%v.patt.5c0
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%inst.ref_return_pattern
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%.ae0167.1
|
||||
// CHECK:STDOUT: %return.patt.loc4_30.2 => constants.%return.patt.c62
|
||||
// CHECK:STDOUT: %.loc4_23.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.efc
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%v.param_patt.e9ad17.1
|
||||
// CHECK:STDOUT: %v.patt.loc4_30.2 => constants.%v.patt.5c0
|
||||
// CHECK:STDOUT: %.loc4_37.3 => constants.%inst.ref_return_pattern
|
||||
// CHECK:STDOUT: %.loc4_37.4 => constants.%.ae0167.1
|
||||
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.c62
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @F(constants.%.c2a) {
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_8.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_8.1 => constants.%.c2a
|
||||
// CHECK:STDOUT: %.loc4_26.1 => constants.%i32
|
||||
// CHECK:STDOUT: %.loc4_23.3 => constants.%inst.value_param_pattern
|
||||
// CHECK:STDOUT: %Fm.patt.loc4_16.2 => constants.%Fm.patt
|
||||
// CHECK:STDOUT: %Fm.loc4_16.1 => constants.%.c2a
|
||||
// CHECK:STDOUT: %.loc4_33.1 => constants.%i32
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%inst.value_param_pattern
|
||||
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.6b6
|
||||
// CHECK:STDOUT: %.loc4_23.4 => constants.%v.param_patt.733534.1
|
||||
// CHECK:STDOUT: %v.patt.loc4_23.2 => constants.%v.patt.971
|
||||
// CHECK:STDOUT: %.loc4_30.3 => constants.%inst.value_return_pattern
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%.1a588f.1
|
||||
// CHECK:STDOUT: %return.patt.loc4_30.2 => constants.%return.patt.45a
|
||||
// CHECK:STDOUT: %.loc4_23.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.efc
|
||||
// CHECK:STDOUT: %.loc4_30.4 => constants.%v.param_patt.733534.1
|
||||
// CHECK:STDOUT: %v.patt.loc4_30.2 => constants.%v.patt.971
|
||||
// CHECK:STDOUT: %.loc4_37.3 => constants.%inst.value_return_pattern
|
||||
// CHECK:STDOUT: %.loc4_37.4 => constants.%.1a588f.1
|
||||
// CHECK:STDOUT: %return.patt.loc4_37.2 => constants.%return.patt.45a
|
||||
// CHECK:STDOUT: %.loc4_30.5 => constants.%.095
|
||||
// CHECK:STDOUT: %.loc4_37.5 => constants.%.efc
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// F in the lexical scope.
|
||||
class Class(F:! type) {
|
||||
class Class(F: type) {
|
||||
class Inner {
|
||||
// F in a non-lexical scope.
|
||||
fn F() -> i32 { return 0; }
|
||||
@@ -25,7 +25,7 @@ class Class(F:! type) {
|
||||
}
|
||||
}
|
||||
|
||||
fn Class(F:! type).Inner.G() -> i32 { return F(); }
|
||||
fn Class(F: type).Inner.G() -> i32 { return F(); }
|
||||
|
||||
// CHECK:STDOUT: --- prefer_unqualified_lookup.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -95,9 +95,9 @@ fn Class(F:! type).Inner.G() -> i32 { return F(); }
|
||||
// CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [concrete = constants.%Class.generic] {
|
||||
// CHECK:STDOUT: %F.patt.loc5_14.1: %pattern_type.98f = symbolic_binding_pattern F, 0 [symbolic = %F.patt.loc5_14.2 (constants.%F.patt)]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %.loc5_17.1: type = splice_block %.loc5_17.2 [concrete = type] {
|
||||
// CHECK:STDOUT: %.loc5_16.1: type = splice_block %.loc5_16.2 [concrete = type] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.loc5_17.2: type = type_literal type [concrete = type]
|
||||
// CHECK:STDOUT: %.loc5_16.2: type = type_literal type [concrete = type]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.loc5_14.2: type = symbolic_binding F, 0 [symbolic = %F.loc5_14.1 (constants.%F)]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -105,13 +105,13 @@ fn Class(F:! type).Inner.G() -> i32 { return F(); }
|
||||
// CHECK:STDOUT: %return.param_patt: %pattern_type.6b6 = out_param_pattern [concrete = constants.%return.param_patt.a9a]
|
||||
// CHECK:STDOUT: %return.patt: %pattern_type.6b6 = return_slot_pattern %return.param_patt, %i32.loc13 [concrete = constants.%return.patt.e1b]
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %.loc13_14.1: type = splice_block %.loc13_14.2 [concrete = type] {
|
||||
// CHECK:STDOUT: %.loc13_13.1: type = splice_block %.loc13_13.2 [concrete = type] {
|
||||
// CHECK:STDOUT: %.Self.frozen: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen]
|
||||
// CHECK:STDOUT: %.loc13_14.2: type = type_literal type [concrete = type]
|
||||
// CHECK:STDOUT: %.loc13_13.2: type = type_literal type [concrete = type]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %F.loc13_11: type = symbolic_binding F, 0 [symbolic = @Class.%F.loc5_14.1 (constants.%F)]
|
||||
// CHECK:STDOUT: %i32.loc13: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc13_33: Core.Form = init_form %i32.loc13 [concrete = constants.%.795]
|
||||
// CHECK:STDOUT: %.loc13_32: Core.Form = init_form %i32.loc13 [concrete = constants.%.795]
|
||||
// CHECK:STDOUT: %return.param.loc13: ref %i32 = out_param call_param0
|
||||
// CHECK:STDOUT: %return.loc13: ref %i32 = return_slot %return.param.loc13
|
||||
// CHECK:STDOUT: }
|
||||
@@ -192,17 +192,17 @@ fn Class(F:! type).Inner.G() -> i32 { return F(); }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic fn @Inner.G(@Class.%F.loc5_14.2: type) {
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %F.loc13_46: type = symbolic_binding F, 0 [symbolic = %F.loc13_46 (constants.%F)]
|
||||
// CHECK:STDOUT: %Inner.F.type: type = fn_type @Inner.F, @Inner(%F.loc13_46) [symbolic = %Inner.F.type (constants.%Inner.F.type)]
|
||||
// CHECK:STDOUT: %F.loc13_45: type = symbolic_binding F, 0 [symbolic = %F.loc13_45 (constants.%F)]
|
||||
// CHECK:STDOUT: %Inner.F.type: type = fn_type @Inner.F, @Inner(%F.loc13_45) [symbolic = %Inner.F.type (constants.%Inner.F.type)]
|
||||
// CHECK:STDOUT: %Inner.F: @Inner.G.%Inner.F.type (%Inner.F.type) = struct_value () [symbolic = %Inner.F (constants.%Inner.F)]
|
||||
// CHECK:STDOUT: %Inner.F.specific_fn.loc13_46.2: <specific function> = specific_function %Inner.F, @Inner.F(%F.loc13_46) [symbolic = %Inner.F.specific_fn.loc13_46.2 (constants.%Inner.F.specific_fn)]
|
||||
// CHECK:STDOUT: %Inner.F.specific_fn.loc13_45.2: <specific function> = specific_function %Inner.F, @Inner.F(%F.loc13_45) [symbolic = %Inner.F.specific_fn.loc13_45.2 (constants.%Inner.F.specific_fn)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn() -> out %return.param.loc13: %i32 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %.loc13_46: @Inner.G.%Inner.F.type (%Inner.F.type) = specific_constant @Inner.%Inner.F.decl, @Inner(constants.%F) [symbolic = %Inner.F (constants.%Inner.F)]
|
||||
// CHECK:STDOUT: %F.ref: @Inner.G.%Inner.F.type (%Inner.F.type) = name_ref F, %.loc13_46 [symbolic = %Inner.F (constants.%Inner.F)]
|
||||
// CHECK:STDOUT: %Inner.F.specific_fn.loc13_46.1: <specific function> = specific_function %F.ref, @Inner.F(constants.%F) [symbolic = %Inner.F.specific_fn.loc13_46.2 (constants.%Inner.F.specific_fn)]
|
||||
// CHECK:STDOUT: %Inner.F.call: init %i32 = call %Inner.F.specific_fn.loc13_46.1()
|
||||
// CHECK:STDOUT: %.loc13_45: @Inner.G.%Inner.F.type (%Inner.F.type) = specific_constant @Inner.%Inner.F.decl, @Inner(constants.%F) [symbolic = %Inner.F (constants.%Inner.F)]
|
||||
// CHECK:STDOUT: %F.ref: @Inner.G.%Inner.F.type (%Inner.F.type) = name_ref F, %.loc13_45 [symbolic = %Inner.F (constants.%Inner.F)]
|
||||
// CHECK:STDOUT: %Inner.F.specific_fn.loc13_45.1: <specific function> = specific_function %F.ref, @Inner.F(constants.%F) [symbolic = %Inner.F.specific_fn.loc13_45.2 (constants.%Inner.F.specific_fn)]
|
||||
// CHECK:STDOUT: %Inner.F.call: init %i32 = call %Inner.F.specific_fn.loc13_45.1()
|
||||
// CHECK:STDOUT: return %Inner.F.call
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !observes:
|
||||
|
||||
Reference in New Issue
Block a user