Skip to content

Commit

Permalink
fixes #391
Browse files Browse the repository at this point in the history
  • Loading branch information
trullock committed Apr 23, 2024
1 parent cf5b607 commit 5c49d39
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v1.21.5 (23 April 2024)
- Fixes bug parsing arrow and anonymous functions as object properties within object destructuring.

## v1.21.4 (05 February 2024)
- Fixes NullReferenceException when parsing object literal with computed property name expression starting with (

Expand Down
6 changes: 6 additions & 0 deletions src/NUglify.Tests/JavaScript/Bugs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,11 @@ public void Bug375()
TestHelper.Instance.RunTest("-rename:all");
}

[Test]
public void Bug391()
{
TestHelper.Instance.RunTest("-rename:all");
}

}
}
6 changes: 6 additions & 0 deletions src/NUglify.Tests/NUglify.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@
<Content Include="TestData\JS\Expected\Bugs\Bug375.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Expected\Bugs\Bug391.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Expected\Bugs\Bug70.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2872,6 +2875,9 @@
<Content Include="TestData\JS\Input\Bugs\Bug138.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Input\Bugs\Bug391.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Input\Bugs\Bug375.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
6 changes: 4 additions & 2 deletions src/NUglify/JavaScript/Syntax/FunctionScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ internal FunctionScope(ActivationObject parent, bool isExpression, CodeSettings
/// </summary>
public override void DeclareScope()
{
var functionObject = (FunctionObject)Owner;

// we are a function expression that points to a function object.
// if the function object points back to us, then this is the main
// function scope. But if it doesn't, then this is actually the parent
// scope for named function expressions that should contain just a field
// for the function name
if (((FunctionObject)Owner).EnclosingScope == this)
if (functionObject.EnclosingScope == this)
{
// first bind any parameter names
DefineParameters();
Expand All @@ -64,7 +66,7 @@ public override void DeclareScope()
// bind the variable declarations
DefineVarDeclarations();
}
else
else if (functionObject.Binding != null)
{
// we just need to define the function name in this scope
DefineFunctionExpressionName();
Expand Down
2 changes: 1 addition & 1 deletion src/NUglify/NUglify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/trullock/NUglify</RepositoryUrl>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.3' ">1.6.0</NetStandardImplicitPackageVersion>
<Version>1.21.4</Version>
<Version>1.21.5</Version>
<PackageLicenseExpression></PackageLicenseExpression>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down

0 comments on commit 5c49d39

Please sign in to comment.