Skip to content

Commit

Permalink
Merge pull request #218 from trullock/bug_215
Browse files Browse the repository at this point in the history
fixes #215
  • Loading branch information
trullock authored Dec 28, 2020
2 parents ce67dc0 + 55f5f31 commit 65af79c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Changelog

## vNext (unpublished)
- Fixes but methods called `set` or `get` on classes

## v1.11.6 (28 December 2020)
- Fixed bug with unused setter `value` parameters being removed
- Fixes tagged template literals
- Fixed bug with unused setter `value` parameters being removed

## v1.11.5 (10 December 2020)
- Fixes bug with `<br>`s when HtmlToText()ing
Expand Down
7 changes: 6 additions & 1 deletion src/NUglify.Tests/JavaScript/Bugs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,18 @@ public void Bug204()
TestHelper.Instance.RunTest("-rename:all");
}


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

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

[Test]
public void Bug216()
{
Expand Down
6 changes: 6 additions & 0 deletions src/NUglify.Tests/NUglify.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@
<Content Include="TestData\JS\Expected\Bugs\Bug204.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Expected\Bugs\Bug215.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Expected\Bugs\Bug70.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2750,6 +2753,9 @@
<Content Include="TestData\JS\Input\Bugs\Bug199JSON.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Input\Bugs\Bug215.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="TestData\JS\Input\Bugs\Bug204.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
1 change: 1 addition & 0 deletions src/NUglify.Tests/TestData/JS/Expected/Bugs/Bug215.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Loader{set(n,t,i){alert(n+t+i)}}
5 changes: 5 additions & 0 deletions src/NUglify.Tests/TestData/JS/Input/Bugs/Bug215.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Loader {
set(not, a, setter) {
alert(not + a + setter);
}
}
14 changes: 10 additions & 4 deletions src/NUglify/JavaScript/JSParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3219,10 +3219,16 @@ private AstNode ParseClassElement()
}

// see if this is a getter/setter or a regular method
var funcType = m_currentToken.Is(JSToken.Get)
? FunctionType.Getter
: m_currentToken.Is(JSToken.Set) ? FunctionType.Setter : FunctionType.Method;

var funcType = FunctionType.Method;
var nextToken = PeekToken();
if (nextToken != JSToken.LeftParenthesis)
{
if (m_currentToken.Is(JSToken.Get))
funcType = FunctionType.Getter;
else if (m_currentToken.Is(JSToken.Set))
funcType = FunctionType.Setter;
}

// right now the ES6 spec just has method declarations.
var method = ParseFunction(funcType, m_currentToken.FlattenToStart());
if (method != null && staticContext != null)
Expand Down

0 comments on commit 65af79c

Please sign in to comment.