diff options
Diffstat (limited to 'src/parser/lexer.cpp')
-rw-r--r-- | src/parser/lexer.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/parser/lexer.cpp b/src/parser/lexer.cpp index bb6428e87..44aecdc2b 100644 --- a/src/parser/lexer.cpp +++ b/src/parser/lexer.cpp @@ -280,6 +280,13 @@ struct LexStrResult : LexResult { // Allocate a string only if there are escape sequences, otherwise just use // the original string_view. std::optional<std::string> str; + + std::string_view getStr() { + if (str) { + return *str; + } + return span; + } }; struct LexStrCtx : LexCtx { @@ -860,6 +867,9 @@ std::optional<LexIdResult> ident(std::string_view in) { return {}; } if (auto s = str(ctx.next())) { + if (!String::isUTF8(s->getStr())) { + return {}; + } ctx.isStr = true; ctx.str = s->str; ctx.take(*s); |