diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1334936..305d6da26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Commands are now better at checking to see if the first word is a keyword (e.g. `return`) or a word that just _begins_ with a keyword (`returnToMenu`). +- Fixed an error where the compiler would crash if an error expression resulted in the implicit declaration of a variable (for example, `<>`). ### Removed diff --git a/Tests/TestCases/ParseFailures/SetStatements-MustHaveValues.yarn b/Tests/TestCases/ParseFailures/SetStatements-MustHaveValues.yarn new file mode 100644 index 000000000..dcfd4e032 --- /dev/null +++ b/Tests/TestCases/ParseFailures/SetStatements-MustHaveValues.yarn @@ -0,0 +1,4 @@ +title: Start +--- +<> +=== diff --git a/YarnSpinner.Compiler/Compiler.cs b/YarnSpinner.Compiler/Compiler.cs index 1f73ea52f..162999479 100644 --- a/YarnSpinner.Compiler/Compiler.cs +++ b/YarnSpinner.Compiler/Compiler.cs @@ -312,6 +312,13 @@ public static CompilationResult Compile(CompilationJob compilationJob) { decl.Type = TypeChecker.ITypeExtensions.Substitute(decl.Type, typeSolution); + // If this value is of an error type, don't attempt to create a + // value for it. + if (decl.Type == Types.Error) + { + continue; + } + // If this was an implicit declaration, then we didn't have an // initial value to use. Instead, set its default value to one // provided by the type.