From 274eee4cc60a0ad590271874b9a80f7df94e9ca9 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 24 Aug 2023 19:01:22 +0200 Subject: [PATCH] Raise a warning if non-nilable argument is not provided by caller --- src/lparser.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lparser.h b/src/lparser.h index 78b81c60b8..adfad1c126 100644 --- a/src/lparser.h +++ b/src/lparser.h @@ -233,6 +233,9 @@ struct TypeHint { } [[nodiscard]] bool isCompatibleWith(const TypeHint& b) const noexcept { + if (b.empty()) { + return isNullable(); + } for (const auto& desc : b.descs) { if (!isCompatibleWith(desc)) { return false; @@ -265,6 +268,9 @@ struct TypeHint { } [[nodiscard]] std::string toString() const { + if (empty()) { + return "nil"; + } std::string str{}; if (isNullable()) str.push_back('?');