mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Separate node kind for bindings inside var (#4822)
This is a step toward making binding pattern handling more robust, by removing its reliance on the node stack for context.
This commit is contained in:
+7
-45
@@ -45,16 +45,16 @@ fn A => 0;
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_invalid_file_generic_regression_test.carbon:[[@LINE+4]]:9: error: `var` declaration cannot declare a compile-time binding [CompileTimeBindingInVarDecl]
|
||||
// CHECK:STDERR: fail_invalid_file_generic_regression_test.carbon:[[@LINE+8]]:5: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
|
||||
// CHECK:STDERR: var x:! () = ();
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_invalid_file_generic_regression_test.carbon:[[@LINE+4]]:12: error: `var` declaration cannot declare a compile-time binding [CompileTimeBindingInVarDecl]
|
||||
// CHECK:STDERR: var x:! () = ();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
var x:! () = ();
|
||||
|
||||
// CHECK:STDERR: fail_invalid_file_generic_regression_test.carbon:[[@LINE+4]]:1: error: semantics TODO: `function with positional parameters` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn A {
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn A {
|
||||
A();
|
||||
}
|
||||
@@ -101,45 +101,7 @@ fn A {
|
||||
// CHECK:STDOUT: --- fail_invalid_file_generic_regression_test.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x [symbolic]
|
||||
// CHECK:STDOUT: %x.patt: %empty_tuple.type = symbolic_binding_pattern x [symbolic]
|
||||
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
|
||||
// CHECK:STDOUT: %A.type: type = fn_type @A [template]
|
||||
// CHECK:STDOUT: %A: %A.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .x = %x
|
||||
// CHECK:STDOUT: .A = %A.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %x.patt: %empty_tuple.type = symbolic_binding_pattern x [symbolic = constants.%x.patt]
|
||||
// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %x.patt
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %.var: ref %empty_tuple.type = var <invalid>
|
||||
// CHECK:STDOUT: %.loc8_10.1: type = splice_block %.loc8_10.3 [template = constants.%empty_tuple.type] {
|
||||
// CHECK:STDOUT: %.loc8_10.2: %empty_tuple.type = tuple_literal ()
|
||||
// CHECK:STDOUT: %.loc8_10.3: type = converted %.loc8_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x, %.var [symbolic = constants.%x]
|
||||
// CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @A() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @__global_init() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %.loc8_15.1: %empty_tuple.type = tuple_literal ()
|
||||
// CHECK:STDOUT: %.loc8_15.2: init %empty_tuple.type = tuple_init () to file.%.var [template = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc8_1: init %empty_tuple.type = converted %.loc8_15.1, %.loc8_15.2 [template = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: assign file.%.var, %.loc8_1
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: file {}
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user