1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Store and return undefined Symbol description

Instead of the current incorrect behaviour of just defaulting to an
empty string.
This commit is contained in:
Idan Horowitz 2021-06-15 02:40:55 +03:00 committed by Linus Groh
parent 4aff4249aa
commit dac971b4ae
5 changed files with 17 additions and 19 deletions

View file

@ -16,21 +16,22 @@ class Symbol final : public Cell {
AK_MAKE_NONMOVABLE(Symbol);
public:
Symbol(String, bool);
Symbol(Optional<String>, bool);
virtual ~Symbol();
const String& description() const { return m_description; }
String description() const { return m_description.value_or(""); }
const Optional<String>& raw_description() const { return m_description; }
bool is_global() const { return m_is_global; }
String to_string() const { return String::formatted("Symbol({})", description()); }
private:
virtual const char* class_name() const override { return "Symbol"; }
String m_description;
Optional<String> m_description;
bool m_is_global;
};
Symbol* js_symbol(Heap&, String description, bool is_global);
Symbol* js_symbol(VM&, String description, bool is_global);
Symbol* js_symbol(Heap&, Optional<String> description, bool is_global);
Symbol* js_symbol(VM&, Optional<String> description, bool is_global);
}