mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:34:42 +01:00
Fix a crash caused by a bug introduced in C++ overloads support in GetScopeIdOffset() (#6151)
After this change, we correctly increment the offset by the next switch case type. Before this change, we accidentally incremented the offset by `functions()` size instead of `cpp_overload_sets()` size and vice versa. Also sorted the switch cases according to the order of the enum, for consistency. This might help prevent a future similar incident. This fix prevents crashing in the newly introduced test `multiple_too_few_args_calls`. This also has the side effect of showing `null name` for `cpp_overload_set_type` and `cpp_overload_set_value`, instead of having an arbitrary name. Examples that demonstrate the old name is arbitrary can easily be seen in tests like `cpp_namespace.carbon` and `decayed_param.carbon`, but careful review would show that all old names are arbitrary, though often luckily almost make sense. We might want to have a proper name for these, but it's beyond the scope of this crash fixing change. See #6156. Part of #5915.
This commit is contained in:
@@ -38,8 +38,8 @@ fn F() {
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %X: type = class_type @X [concrete]
|
||||
// CHECK:STDOUT: %.034: type = cpp_overload_set_type @X.f [concrete]
|
||||
// CHECK:STDOUT: %.a8d: %.034 = cpp_overload_set_value @X.f [concrete]
|
||||
// CHECK:STDOUT: %.034: type = cpp_overload_set_type @<null name> [concrete]
|
||||
// CHECK:STDOUT: %.a8d: %.034 = cpp_overload_set_value @<null name> [concrete]
|
||||
// CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [concrete]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
||||
@@ -67,7 +67,7 @@ fn F() {
|
||||
// CHECK:STDOUT: import Cpp//...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %X.decl: type = class_decl @X [concrete = constants.%X] {} {}
|
||||
// CHECK:STDOUT: %.a8d: %.034 = cpp_overload_set_value @X.f [concrete = constants.%.a8d]
|
||||
// CHECK:STDOUT: %.a8d: %.034 = cpp_overload_set_value @<null name> [concrete = constants.%.a8d]
|
||||
// CHECK:STDOUT: %X.f.decl: %X.f.type = fn_decl @X.f [concrete = constants.%X.f] {
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: } {
|
||||
|
||||
Reference in New Issue
Block a user