Commit 23719f6d authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[torque] Don't crash when failing to find a non-constexpr type

Marja pointed out that the following code causes a Torque crash:

Convert<Smi>(MessageTemplate::kFoo)

This change is a small fix to not crash in that case.

Bug: v8:7793, v8:10475
Change-Id: I7856366856a4cd7facdb19686a2d4c92b0d04516
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2182175Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#67580}
parent 6a178193
......@@ -300,8 +300,13 @@ class AbstractType final : public Type {
}
std::string SimpleNameImpl() const override {
if (IsConstexpr())
return "constexpr_" + NonConstexprVersion()->SimpleName();
if (IsConstexpr()) {
const Type* non_constexpr_version = NonConstexprVersion();
if (non_constexpr_version == nullptr) {
ReportError("Cannot find non-constexpr type corresponding to ", *this);
}
return "constexpr_" + non_constexpr_version->SimpleName();
}
return name();
}
......
......@@ -336,6 +336,22 @@ TEST(Torque, ConstexprLetBindingDoesNotCrash) {
HasSubstr("Use 'const' instead of 'let' for variable 'foo'"));
}
TEST(Torque, FailedImplicitCastFromConstexprDoesNotCrash) {
ExpectFailingCompilation(
R"(
extern enum SomeEnum {
kValue,
...
}
macro Foo() {
Bar(SomeEnum::kValue);
}
macro Bar<T: type>(value: T) {}
)",
HasSubstr(
"Cannot find non-constexpr type corresponding to constexpr kValue"));
}
TEST(Torque, DoubleUnderScorePrefixIllegalForIdentifiers) {
ExpectFailingCompilation(R"(
@export macro Foo() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment