From e305c896a1f605ace792f3ceac74a4f8dd879d9f Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Fri, 12 Jan 2024 14:40:11 -0800 Subject: [PATCH] Add TODOs for implicit params to class and interface. (#3596) Without these, the code crashes. --- toolchain/check/handle_class.cpp | 3 +++ toolchain/check/handle_interface.cpp | 3 +++ .../testdata/class/fail_todo_generic.carbon | 24 +++++++++++++++++++ .../interface/fail_todo_generic.carbon | 23 ++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 toolchain/check/testdata/class/fail_todo_generic.carbon create mode 100644 toolchain/check/testdata/interface/fail_todo_generic.carbon diff --git a/toolchain/check/handle_class.cpp b/toolchain/check/handle_class.cpp index 7c53dea5aff1..75fbc814df73 100644 --- a/toolchain/check/handle_class.cpp +++ b/toolchain/check/handle_class.cpp @@ -26,6 +26,9 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId parse_node) if (context.node_stack().PopIf()) { context.TODO(parse_node, "generic class"); } + if (context.node_stack().PopIf()) { + context.TODO(parse_node, "generic class"); + } auto name_context = context.decl_name_stack().FinishName(); context.node_stack() diff --git a/toolchain/check/handle_interface.cpp b/toolchain/check/handle_interface.cpp index 0ff351dc044f..36698790850f 100644 --- a/toolchain/check/handle_interface.cpp +++ b/toolchain/check/handle_interface.cpp @@ -27,6 +27,9 @@ static auto BuildInterfaceDecl(Context& context, if (context.node_stack().PopIf()) { context.TODO(parse_node, "generic interface"); } + if (context.node_stack().PopIf()) { + context.TODO(parse_node, "generic interface"); + } auto name_context = context.decl_name_stack().FinishName(); context.node_stack() diff --git a/toolchain/check/testdata/class/fail_todo_generic.carbon b/toolchain/check/testdata/class/fail_todo_generic.carbon new file mode 100644 index 000000000000..e859a301a314 --- /dev/null +++ b/toolchain/check/testdata/class/fail_todo_generic.carbon @@ -0,0 +1,24 @@ +// 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 + +// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+6]]:1: ERROR: Semantics TODO: `generic class`. +// CHECK:STDERR: class C[](); +// CHECK:STDERR: ^~~~~~~~~~~~ +// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+3]]:1: ERROR: Semantics TODO: `generic class`. +// CHECK:STDERR: class C[](); +// CHECK:STDERR: ^~~~~~~~~~~~ +class C[](); + +// CHECK:STDOUT: --- fail_todo_generic.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace package, {.C = %C.decl} +// CHECK:STDOUT: %C.decl = class_decl @C, () +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C; +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/fail_todo_generic.carbon b/toolchain/check/testdata/interface/fail_todo_generic.carbon new file mode 100644 index 000000000000..c6364ad4cac8 --- /dev/null +++ b/toolchain/check/testdata/interface/fail_todo_generic.carbon @@ -0,0 +1,23 @@ +// 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 + +// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+6]]:1: ERROR: Semantics TODO: `generic interface`. +// CHECK:STDERR: interface I[](); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+3]]:1: ERROR: Semantics TODO: `generic interface`. +// CHECK:STDERR: interface I[](); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ +interface I[](); + +// CHECK:STDOUT: --- fail_todo_generic.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace package, {.I = %I.decl} +// CHECK:STDOUT: %I.decl = interface_decl @I, () +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I; +// CHECK:STDOUT: