Skip to content

Commit

Permalink
Fix a crash when reimporting changes in a project that uses 'visited'
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Jun 14, 2022
1 parent a0eae78 commit 5d42767
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Changed

- Fixed an issue where Yarn projects that made use of the `visited` or `visit_count` functions could produce errors when re-importing the project.

## [2.2.0] 2022-04-08

### Added
Expand Down
11 changes: 10 additions & 1 deletion Editor/Importers/YarnProjectImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ public override void OnImportAsset(AssetImportContext ctx)
return;
}

localDeclarations = localDeclarations
.Where(decl => decl.Name.StartsWith("$Yarn.Internal") == false);

// Store these so that we can continue displaying them after
// this import step, in case there are compile errors later.
// We'll replace this with a more complete list later if
Expand Down Expand Up @@ -283,9 +286,15 @@ public override void OnImportAsset(AssetImportContext ctx)
}

// Store _all_ declarations - both the ones in this
// .yarnproject file, and the ones inside the .yarn files
// .yarnproject file, and the ones inside the .yarn files.

// While we're here, filter out any declarations that begin with our
// Yarn internal prefix. These are synthesized variables that are
// generated as a result of the compilation, and are not declared by
// the user.
serializedDeclarations = localDeclarations
.Concat(compilationResult.Declarations)
.Where(decl => !decl.Name.StartsWith("$Yarn.Internal."))
.Where(decl => !(decl.Type is FunctionType))
.Select(decl => new SerializedDeclaration(decl)).ToList();

Expand Down

0 comments on commit 5d42767

Please sign in to comment.