mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-17 01:10:28 +03:00
AK: Warn when trying to set @foo@
as a SourceGenerator key
I was very confused why I was getting "no key named `foo`" errors, so hopefully this will save someone that confusion in the future. :^) (It'll probably be me again...)
This commit is contained in:
parent
9cf329183f
commit
32c99313a6
Notes:
sideshowbarker
2024-07-17 07:19:28 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/32c99313a6 Pull-request: https://github.com/SerenityOS/serenity/pull/15153 Reviewed-by: https://github.com/linusg
@ -37,7 +37,15 @@ public:
|
||||
|
||||
SourceGenerator fork() { return SourceGenerator { m_builder, m_mapping, m_opening, m_closing }; }
|
||||
|
||||
void set(StringView key, String value) { m_mapping.set(key, move(value)); }
|
||||
void set(StringView key, String value)
|
||||
{
|
||||
if (key.contains(m_opening) || key.contains(m_closing)) {
|
||||
warnln("SourceGenerator keys cannot contain the opening/closing delimiters `{}` and `{}`. (Keys are only wrapped in these when using them, not when setting them.)", m_opening, m_closing);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
m_mapping.set(key, move(value));
|
||||
}
|
||||
|
||||
String get(StringView key) const
|
||||
{
|
||||
auto result = m_mapping.get(key);
|
||||
|
Loading…
Reference in New Issue
Block a user