From 3a712af4ddf1d42def1f1d1d9560c7b860a461eb Mon Sep 17 00:00:00 2001 From: James Westman Date: Fri, 26 Jul 2024 21:08:50 -0500 Subject: [PATCH] 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. --- blueprintcompiler/language/values.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blueprintcompiler/language/values.py b/blueprintcompiler/language/values.py index 73a1084..9b29d94 100644 --- a/blueprintcompiler/language/values.py +++ b/blueprintcompiler/language/values.py @@ -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",