Skip to content

Commit

Permalink
Don't crash when an implicit declaration is of an error type
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Jan 1, 2025
1 parent 89cdf07 commit eb20171
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, `<<set $x = >>`).

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: Start
---
<<set $x = >>
===
7 changes: 7 additions & 0 deletions YarnSpinner.Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit eb20171

Please sign in to comment.