Skip to content

Commit 38ccbb5

Browse files
committed
refactoring of overload check +semver:none
1 parent 411a3f6 commit 38ccbb5

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/Application/HydraScript.Application.StaticAnalysis/Visitors/DeclarationVisitor.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,8 @@ public VisitUnit Visit(FunctionDeclaration visitable)
8787
parameters,
8888
visitable.ReturnTypeValue.Accept(_typeBuilder),
8989
visitable.IsEmpty);
90-
if (parentTable.ContainsSymbol(functionSymbolId))
91-
{
92-
if (!(parentTable.FindSymbol(functionSymbolId)! > functionSymbol))
93-
throw new OverloadAlreadyExists(visitable.Name, functionSymbolId);
94-
}
90+
if (functionSymbolId.Equals(parentTable.FindSymbol(functionSymbolId)?.Id))
91+
throw new OverloadAlreadyExists(visitable.Name, functionSymbolId);
9592

9693
for (var i = 0; i < parameters.Count; i++)
9794
{

tests/HydraScript.IntegrationTests/samples/defaultparams.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ function g(a:number, b = 0){
77
g(1)
88
g(1,2)
99

10-
function f(){
11-
>>>"f()"
12-
}
13-
function f(a = 0){
14-
>>> "f(number)"
15-
>>> a
16-
}
1710
function f(a = 0, b = 1){
1811
>>> "f(number, number)"
1912
>>> a
2013
>>> b
2114
}
2215

16+
function f(){
17+
>>>"f()"
18+
}
19+
20+
function f(a = 0){
21+
>>> "f(number)"
22+
>>> a
23+
}
24+
2325
f()
2426
f(1)
2527
f(1,2)

0 commit comments

Comments
 (0)