Fix crash with bad escape sequence in string array

Invalid escape sequences aren't a fatal parser error, so the AST can be
built even when one is present, in which case the string token is None.
This commit is contained in:
James Westman 2024-07-26 21:08:50 -05:00
parent d0659a43c2
commit 3a712af4dd

View file

@ -424,7 +424,8 @@ class ArrayValue(AstNode):
):
quoted_literal = value.child.value
literal_value = quoted_literal.value
if "\n" in literal_value:
# literal_value can be None if there's an invalid escape sequence
if literal_value is not None and "\n" in literal_value:
errors.append(
CompileError(
"String literals inside arrays can't contain newlines",