Made function and namespace nodes typed to remove a crash (#3285)

Bug found by fuzzing. Problem was untyped SemIR nodes had an invalid
type id, which was retrieved by `HandlePrefixOperator` and then passed
to `context.GetUnqualifiedType`, ultimately performing an invalid access
in `semantics_ir_->GetNode`.

We prefer to make a placeholder type for functions and namespaces to
remove the need for checking for the untyped case everywhere. Eventually
functions will have their own types, but this approach will be needed
for namespaces (and perhaps other non-first-class entities like unbound
methods and interface members) long term.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
josh11b
2023-10-12 21:14:16 +00:00
committed by GitHub
co-authored by Richard Smith
parent 6ba8712fbd
commit 8d0831f431
133 changed files with 418 additions and 357 deletions
+3 -3
View File
@@ -13,8 +13,8 @@ fn G() -> i32 {
}
// CHECK:STDOUT: file "function_param.carbon" {
// CHECK:STDOUT: %F = fn_decl @F
// CHECK:STDOUT: %G = fn_decl @G
// CHECK:STDOUT: %F: <function> = fn_decl @F
// CHECK:STDOUT: %G: <function> = fn_decl @G
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%arr: [i32; 3], %i: i32) -> i32 {
@@ -29,7 +29,7 @@ fn G() -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() -> i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F
// CHECK:STDOUT: %F.ref: <function> = name_reference "F", package.%F
// CHECK:STDOUT: %.loc12_13: i32 = int_literal 1
// CHECK:STDOUT: %.loc12_16: i32 = int_literal 2
// CHECK:STDOUT: %.loc12_19: i32 = int_literal 3