Skip to content

Commit

Permalink
Merge pull request #790 from mousetraps/1.1-cherry
Browse files Browse the repository at this point in the history
cherry-pick stability fixes into v1.1.x
  • Loading branch information
mousetraps committed Mar 29, 2016
2 parents 15cf649 + cbd9d18 commit 8e7e74a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
9 changes: 7 additions & 2 deletions Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ internal AnalysisUnit(JsAst ast, EnvironmentRecord environment)
internal virtual void AnalyzeWorker(DDG ddg, CancellationToken cancel) {
Debug.Assert(Ast != null, "Ast has unexpected null value");
Debug.Assert(ProjectEntry != null, "ProjectEntry has unexpected null value");
Debug.Assert(DeclaringModuleEnvironment != null, "DeclaringModuleEnvironment has unexpected null value");
Debug.Assert(DeclaringModuleEnvironment.GlobalEnvironment != null, "DeclaringModuleEnvironment.GlobalEnvironment has unexpected null value");

if (Ast == null || ProjectEntry == null || Tree != ProjectEntry.Tree) {
if (Ast == null || ProjectEntry == null || Tree != ProjectEntry.Tree || DeclaringModuleEnvironment == null) {
// analysis unit properties are invalid or we were enqueued and a new version became available
// don't re-analyze against the old version.
return;
Expand All @@ -216,7 +218,10 @@ internal AnalysisUnit(JsAst ast, EnvironmentRecord environment)
}

foreach (var nameValue in toRemove) {
DeclaringModuleEnvironment.GlobalEnvironment.RemoveVariable(nameValue.Key);
var globalEnvironment = DeclaringModuleEnvironment.GlobalEnvironment;
if (globalEnvironment != null) {
globalEnvironment.RemoveVariable(nameValue.Key);
}

// if anyone read this value it could now be gone (e.g. user
// deletes a class definition) so anyone dependent upon it
Expand Down
17 changes: 10 additions & 7 deletions Nodejs/Product/Analysis/JavaScript/jsparser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using Microsoft.Ajax.Utilities;


namespace Microsoft.NodejsTools.Parsing
{
/// <summary>
Expand Down Expand Up @@ -1086,7 +1085,7 @@ private Statement ParseForStatement()
Statement lhs = null;
Statement initializer = null;
int headerEnd = -1;
List<VariableDeclaration> varList = new List<VariableDeclaration>();
var varList = new List<VariableDeclaration>();
try
{
if (JSToken.Var == _curToken
Expand All @@ -1108,16 +1107,20 @@ private Statement ParseForStatement()
}

var varInitializer = ParseIdentifierInitializer(JSToken.In);
varList.Add(varInitializer);
UpdateWithOtherNode(declaration, varInitializer);
if (varInitializer != null) {
varList.Add(varInitializer);
UpdateWithOtherNode(declaration, varInitializer);
}

// a list of variable initializers is allowed only in a for(;;)
while (JSToken.Comma == _curToken)
{
isForIn = false;
varInitializer = ParseIdentifierInitializer(JSToken.In);
varList.Add(varInitializer);
UpdateWithOtherNode(declaration, initializer);
if (varInitializer != null) {
varList.Add(varInitializer);
UpdateWithOtherNode(declaration, initializer);
}
//initializer = new Comma(initializer.context.CombineWith(var.context), initializer, var);
}

Expand Down

0 comments on commit 8e7e74a

Please sign in to comment.